Search in sources :

Example 56 with TupleWriter

use of org.apache.drill.exec.vector.accessor.TupleWriter in project drill by apache.

the class HttpdLogRecord method setWildcard.

/**
 * This method is referenced and called via reflection. When the parser processes a field like:
 * HTTP.URI:request.firstline.uri.query.* where star is an arbitrary field that the parser found this method will be
 * invoked. <br>
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void setWildcard(String field, String value) {
    if (value != null) {
        String cleanedField = HttpdUtils.getFieldNameFromMap(field);
        if (flattenWildcards) {
            String drillFieldName = HttpdUtils.drillFormattedFieldName(field);
            ScalarWriter writer = getColWriter(rootRowWriter, drillFieldName, MinorType.VARCHAR);
            writer.setString(value);
        } else {
            final TupleWriter mapWriter = getWildcardWriter(field);
            logger.debug("Parsed wildcard field: {}, as String: {}", field, value);
            writeStringColumn(mapWriter, cleanedField, value);
        }
    }
}
Also used : TupleWriter(org.apache.drill.exec.vector.accessor.TupleWriter) ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 57 with TupleWriter

use of org.apache.drill.exec.vector.accessor.TupleWriter in project drill by apache.

the class HttpdLogRecord method setWildcard.

/**
 * This method is referenced and called via reflection. When the parser processes a field like:
 * HTTP.URI:request.firstline.uri.query.* where star is an arbitrary field that the parser found this method will be
 * invoked. <br>
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void setWildcard(String field, Long value) {
    if (value != null) {
        String cleanedField = HttpdUtils.getFieldNameFromMap(field);
        if (flattenWildcards) {
            String drillFieldName = HttpdUtils.drillFormattedFieldName(field);
            ScalarWriter writer = getColWriter(rootRowWriter, drillFieldName, MinorType.BIGINT);
            writer.setLong(value);
        } else {
            final TupleWriter mapWriter = getWildcardWriter(field);
            logger.debug("Parsed wildcard field: {}, as long: {}", field, value);
            writeLongColumn(mapWriter, cleanedField, value);
        }
    }
}
Also used : TupleWriter(org.apache.drill.exec.vector.accessor.TupleWriter) ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 58 with TupleWriter

use of org.apache.drill.exec.vector.accessor.TupleWriter in project drill by apache.

the class HttpdLogRecord method setWildcard.

/**
 * This method is referenced and called via reflection. When the parser processes a field like:
 * HTTP.URI:request.firstline.uri.query.* where star is an arbitrary field that the parser found this method will be
 * invoked. <br>
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void setWildcard(String field, Double value) {
    if (value != null) {
        String cleanedField = HttpdUtils.getFieldNameFromMap(field);
        if (flattenWildcards) {
            String drillFieldName = HttpdUtils.drillFormattedFieldName(field);
            ScalarWriter writer = getColWriter(rootRowWriter, drillFieldName, MinorType.FLOAT8);
            writer.setDouble(value);
        } else {
            final TupleWriter mapWriter = getWildcardWriter(field);
            logger.debug("Parsed wildcard field: {}, as double: {}", field, value);
            writeFloatColumn(mapWriter, cleanedField, value);
        }
    }
}
Also used : TupleWriter(org.apache.drill.exec.vector.accessor.TupleWriter) ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 59 with TupleWriter

use of org.apache.drill.exec.vector.accessor.TupleWriter 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

TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)59 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)52 SubOperatorTest (org.apache.drill.test.SubOperatorTest)50 Test (org.junit.Test)50 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)35 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)33 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)26 ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)25 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)23 TupleReader (org.apache.drill.exec.vector.accessor.TupleReader)20 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)19 ArrayWriter (org.apache.drill.exec.vector.accessor.ArrayWriter)18 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)16 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)15 ResultSetLoader (org.apache.drill.exec.physical.rowSet.ResultSetLoader)14 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)14 RowSet (org.apache.drill.test.rowSet.RowSet)13 ArrayReader (org.apache.drill.exec.vector.accessor.ArrayReader)12 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)12 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)10