use of org.apache.apex.malhar.contrib.parser.JsonParser 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);
}
use of org.apache.apex.malhar.contrib.parser.JsonParser in project apex-malhar by apache.
the class Application method populateDAG.
@Override
public void populateDAG(DAG dag, Configuration conf) {
JsonGenerator generator = dag.addOperator("JsonGenerator", JsonGenerator.class);
JsonParser jsonParser = dag.addOperator("jsonParser", JsonParser.class);
CsvFormatter formatter = dag.addOperator("formatter", CsvFormatter.class);
formatter.setSchema(SchemaUtils.jarResourceFileToString(filename));
dag.setInputPortAttribute(formatter.in, PortContext.TUPLE_CLASS, PojoEvent.class);
HDFSOutputOperator<String> hdfsOutput = dag.addOperator("HDFSOutputOperator", HDFSOutputOperator.class);
hdfsOutput.setLineDelimiter("");
dag.addStream("parserStream", generator.out, jsonParser.in);
dag.addStream("formatterStream", jsonParser.out, formatter.in);
dag.addStream("outputStream", formatter.out, hdfsOutput.input);
}
Aggregations