Search in sources :

Example 1 with DelimitedSchema

use of org.apache.apex.malhar.contrib.parser.DelimitedSchema in project apex-malhar by apache.

the class CsvFormatter method setup.

@Override
public void setup(Context.OperatorContext context) {
    super.setup(context);
    delimitedParserSchema = new DelimitedSchema(schema);
    preference = new CsvPreference.Builder(delimitedParserSchema.getQuoteChar(), delimitedParserSchema.getDelimiterChar(), delimitedParserSchema.getLineDelimiter()).build();
    nameMapping = delimitedParserSchema.getFieldNames().toArray(new String[delimitedParserSchema.getFieldNames().size()]);
    processors = getProcessor(delimitedParserSchema.getFields());
}
Also used : DelimitedSchema(org.apache.apex.malhar.contrib.parser.DelimitedSchema)

Example 2 with DelimitedSchema

use of org.apache.apex.malhar.contrib.parser.DelimitedSchema in project apex-malhar by apache.

the class DelimitedFSLoader method init.

private void init() {
    delimitedParserSchema = new DelimitedSchema(schema);
    preference = new CsvPreference.Builder(delimitedParserSchema.getQuoteChar(), delimitedParserSchema.getDelimiterChar(), delimitedParserSchema.getLineDelimiter()).build();
    nameMapping = delimitedParserSchema.getFieldNames().toArray(new String[delimitedParserSchema.getFieldNames().size()]);
    header = StringUtils.join(nameMapping, (char) delimitedParserSchema.getDelimiterChar() + "");
    processors = getProcessor(delimitedParserSchema.getFields());
    csvStringReader = new ReusableStringReader();
    csvMapReader = new CsvMapReader(csvStringReader, preference);
}
Also used : DelimitedSchema(org.apache.apex.malhar.contrib.parser.DelimitedSchema) ReusableStringReader(org.apache.apex.malhar.lib.util.ReusableStringReader) CellProcessorBuilder(org.apache.apex.malhar.contrib.parser.CellProcessorBuilder) CsvMapReader(org.supercsv.io.CsvMapReader)

Example 3 with DelimitedSchema

use of org.apache.apex.malhar.contrib.parser.DelimitedSchema in project apex-malhar by apache.

the class CSVMessageFormat method getRowType.

@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
    String schema = (String) operands.get(CSV_SCHEMA);
    RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
    DelimitedSchema delimitedSchema = new DelimitedSchema(schema);
    for (DelimitedSchema.Field field : delimitedSchema.getFields()) {
        builder.add(field.getName(), convertField(typeFactory, field.getType()));
    }
    return builder.build();
}
Also used : DelimitedSchema(org.apache.apex.malhar.contrib.parser.DelimitedSchema) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory)

Aggregations

DelimitedSchema (org.apache.apex.malhar.contrib.parser.DelimitedSchema)3 CellProcessorBuilder (org.apache.apex.malhar.contrib.parser.CellProcessorBuilder)1 ReusableStringReader (org.apache.apex.malhar.lib.util.ReusableStringReader)1 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)1 CsvMapReader (org.supercsv.io.CsvMapReader)1