Search in sources :

Example 1 with ColumnConverter

use of org.apache.drill.exec.record.ColumnConverter in project drill by apache.

the class AvroColumnConverterFactory method buildMapMembers.

public void buildMapMembers(GenericRecord genericRecord, TupleMetadata providedSchema, TupleWriter tupleWriter, List<ColumnConverter> converters) {
    // fill in tuple schema for cases when it contains recursive named record types
    TupleMetadata readerSchema = AvroSchemaUtil.convert(genericRecord.getSchema());
    TupleMetadata tableSchema = FixedReceiver.Builder.mergeSchemas(providedSchema, readerSchema);
    tableSchema.toMetadataList().forEach(tupleWriter::addColumn);
    IntStream.range(0, tableSchema.size()).mapToObj(i -> getConverter(providedSchema, readerSchema.metadata(i), tupleWriter.column(i))).forEach(converters::add);
}
Also used : IntStream(java.util.stream.IntStream) Utf8(org.apache.avro.util.Utf8) Period(org.joda.time.Period) GenericRecord(org.apache.avro.generic.GenericRecord) GenericFixed(org.apache.avro.generic.GenericFixed) Charsets(org.apache.drill.shaded.guava.com.google.common.base.Charsets) ColumnConverter(org.apache.drill.exec.record.ColumnConverter) ColumnConverterFactory(org.apache.drill.exec.record.ColumnConverterFactory) TupleWriter(org.apache.drill.exec.vector.accessor.TupleWriter) Collectors(java.util.stream.Collectors) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) ByteBuffer(java.nio.ByteBuffer) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) ByteOrder(java.nio.ByteOrder) RowSetLoader(org.apache.drill.exec.physical.resultSet.RowSetLoader) List(java.util.List) FixedReceiver(org.apache.drill.exec.physical.impl.scan.v3.FixedReceiver) IntBuffer(java.nio.IntBuffer) BigInteger(java.math.BigInteger) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) ValueWriter(org.apache.drill.exec.vector.accessor.ValueWriter) DateTimeConstants(org.joda.time.DateTimeConstants) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata)

Aggregations

BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 ByteBuffer (java.nio.ByteBuffer)1 ByteOrder (java.nio.ByteOrder)1 IntBuffer (java.nio.IntBuffer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 GenericFixed (org.apache.avro.generic.GenericFixed)1 GenericRecord (org.apache.avro.generic.GenericRecord)1 Utf8 (org.apache.avro.util.Utf8)1 FixedReceiver (org.apache.drill.exec.physical.impl.scan.v3.FixedReceiver)1 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)1 ColumnConverter (org.apache.drill.exec.record.ColumnConverter)1 ColumnConverterFactory (org.apache.drill.exec.record.ColumnConverterFactory)1 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)1 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)1 ValueWriter (org.apache.drill.exec.vector.accessor.ValueWriter)1