Search in sources :

Example 1 with JsonFSLoader

use of org.apache.apex.malhar.contrib.enrich.JsonFSLoader in project apex-malhar by apache.

the class EnricherAppWithJSONFile method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    dataGenerator = dag.addOperator("DataGenerator", DataGenerator.class);
    JsonParser parser = dag.addOperator("Parser", JsonParser.class);
    /**
     * FSLoader is used to configure Enricher backend. Property of FSLoader file which is fileName is set in
     * properties.xml file.
     * The format that is used to read the file is present as an example in resources/circleMapping.txt file.
     */
    JsonFSLoader fsLoader = new JsonFSLoader();
    POJOEnricher enrich = dag.addOperator("Enrich", POJOEnricher.class);
    enrich.setStore(fsLoader);
    ArrayList<String> includeFields = new ArrayList<>();
    includeFields.add("circleName");
    ArrayList<String> lookupFields = new ArrayList<>();
    lookupFields.add("circleId");
    enrich.setIncludeFields(includeFields);
    enrich.setLookupFields(lookupFields);
    MapFunctionOperator<Object, ?> out = dag.addOperator("out", new MapFunctionOperator<>(outputFn));
    dag.addStream("Parse", dataGenerator.output, parser.in);
    dag.addStream("Enrich", parser.out, enrich.input);
    dag.addStream("Console", enrich.output, out.input);
}
Also used : ArrayList(java.util.ArrayList) POJOEnricher(org.apache.apex.malhar.contrib.enrich.POJOEnricher) JsonParser(org.apache.apex.malhar.contrib.parser.JsonParser) JsonFSLoader(org.apache.apex.malhar.contrib.enrich.JsonFSLoader)

Aggregations

ArrayList (java.util.ArrayList)1 JsonFSLoader (org.apache.apex.malhar.contrib.enrich.JsonFSLoader)1 POJOEnricher (org.apache.apex.malhar.contrib.enrich.POJOEnricher)1 JsonParser (org.apache.apex.malhar.contrib.parser.JsonParser)1