Search in sources :

Example 1 with RelInfo

use of org.apache.apex.malhar.sql.planner.RelInfo in project apex-malhar by apache.

the class KafkaEndpoint method populateOutputDAG.

@Override
public RelInfo populateOutputDAG(DAG dag, JavaTypeFactory typeFactory) {
    RelInfo spec = messageFormat.populateOutputDAG(dag, typeFactory);
    KafkaSinglePortOutputOperator kafkaOutput = dag.addOperator(OperatorUtils.getUniqueOperatorName("KafkaOutput"), KafkaSinglePortOutputOperator.class);
    kafkaOutput.setTopic((String) operands.get(KAFKA_TOPICS));
    Properties props = new Properties();
    props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, VALUE_SERIALIZER);
    props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, KEY_SERIALIZER);
    props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, operands.get(KAFKA_SERVERS));
    kafkaOutput.setProperties(props);
    dag.addStream(OperatorUtils.getUniqueStreamName("Formatter", "Kafka"), spec.getOutPort(), kafkaOutput.inputPort);
    return new RelInfo("Output", spec.getInputPorts(), spec.getOperator(), null, messageFormat.getRowType(typeFactory));
}
Also used : RelInfo(org.apache.apex.malhar.sql.planner.RelInfo) Properties(java.util.Properties) KafkaSinglePortOutputOperator(org.apache.apex.malhar.kafka.KafkaSinglePortOutputOperator)

Example 2 with RelInfo

use of org.apache.apex.malhar.sql.planner.RelInfo in project apex-malhar by apache.

the class FileEndpoint method populateInputDAG.

@Override
public RelInfo populateInputDAG(DAG dag, JavaTypeFactory typeFactory) {
    LineReader fileInput = dag.addOperator(OperatorUtils.getUniqueOperatorName("FileInput"), LineReader.class);
    fileInput.setDirectory((String) operands.get(FILE_INPUT_DIRECTORY));
    RelInfo spec = messageFormat.populateInputDAG(dag, typeFactory);
    dag.addStream(OperatorUtils.getUniqueStreamName("File", "Parser"), fileInput.output, spec.getInputPorts().get(0));
    return new RelInfo("Input", Lists.<Operator.InputPort>newArrayList(), spec.getOperator(), spec.getOutPort(), messageFormat.getRowType(typeFactory));
}
Also used : Operator(com.datatorrent.api.Operator) GenericFileOutputOperator(org.apache.apex.malhar.lib.fs.GenericFileOutputOperator) LineReader(org.apache.apex.malhar.sql.operators.LineReader) RelInfo(org.apache.apex.malhar.sql.planner.RelInfo)

Example 3 with RelInfo

use of org.apache.apex.malhar.sql.planner.RelInfo in project apex-malhar by apache.

the class CSVMessageFormat method populateOutputDAG.

@Override
public RelInfo populateOutputDAG(DAG dag, JavaTypeFactory typeFactory) {
    CsvFormatter formatter = dag.addOperator(OperatorUtils.getUniqueOperatorName("CSVFormatter"), CsvFormatter.class);
    formatter.setSchema((String) operands.get(CSV_SCHEMA));
    return new RelInfo("CSVFormatter", Lists.<Operator.InputPort>newArrayList(formatter.in), formatter, formatter.out, getRowType(typeFactory));
}
Also used : Operator(com.datatorrent.api.Operator) CsvFormatter(org.apache.apex.malhar.contrib.formatter.CsvFormatter) RelInfo(org.apache.apex.malhar.sql.planner.RelInfo)

Example 4 with RelInfo

use of org.apache.apex.malhar.sql.planner.RelInfo in project apex-malhar by apache.

the class CSVMessageFormat method populateInputDAG.

@Override
public RelInfo populateInputDAG(DAG dag, JavaTypeFactory typeFactory) {
    CsvParser csvParser = dag.addOperator(OperatorUtils.getUniqueOperatorName("CSVParser"), CsvParser.class);
    csvParser.setSchema((String) operands.get(CSV_SCHEMA));
    return new RelInfo("CSVParser", Lists.<Operator.InputPort>newArrayList(csvParser.in), csvParser, csvParser.out, getRowType(typeFactory));
}
Also used : Operator(com.datatorrent.api.Operator) CsvParser(org.apache.apex.malhar.contrib.parser.CsvParser) RelInfo(org.apache.apex.malhar.sql.planner.RelInfo)

Example 5 with RelInfo

use of org.apache.apex.malhar.sql.planner.RelInfo in project apex-malhar by apache.

the class FileEndpoint method populateOutputDAG.

@Override
public RelInfo populateOutputDAG(DAG dag, JavaTypeFactory typeFactory) {
    RelInfo spec = messageFormat.populateOutputDAG(dag, typeFactory);
    GenericFileOutputOperator.StringFileOutputOperator fileOutput = dag.addOperator(OperatorUtils.getUniqueOperatorName("FileOutput"), GenericFileOutputOperator.StringFileOutputOperator.class);
    fileOutput.setFilePath((String) operands.get(FILE_OUT_PATH));
    fileOutput.setOutputFileName((String) operands.get(FILE_OUT_NAME));
    dag.addStream(OperatorUtils.getUniqueStreamName("Formatter", "File"), spec.getOutPort(), fileOutput.input);
    return new RelInfo("Output", spec.getInputPorts(), spec.getOperator(), null, messageFormat.getRowType(typeFactory));
}
Also used : GenericFileOutputOperator(org.apache.apex.malhar.lib.fs.GenericFileOutputOperator) RelInfo(org.apache.apex.malhar.sql.planner.RelInfo)

Aggregations

RelInfo (org.apache.apex.malhar.sql.planner.RelInfo)6 Operator (com.datatorrent.api.Operator)4 Properties (java.util.Properties)2 KafkaSinglePortOutputOperator (org.apache.apex.malhar.kafka.KafkaSinglePortOutputOperator)2 GenericFileOutputOperator (org.apache.apex.malhar.lib.fs.GenericFileOutputOperator)2 CsvFormatter (org.apache.apex.malhar.contrib.formatter.CsvFormatter)1 CsvParser (org.apache.apex.malhar.contrib.parser.CsvParser)1 KafkaSinglePortInputOperator (org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator)1 LineReader (org.apache.apex.malhar.sql.operators.LineReader)1