Search in sources :

Example 21 with ScalarWriter

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

the class HttpdLogRecord method set.

/**
 * This method is referenced and called via reflection. This is added as a parsing target for the parser. It will get
 * called when the value of a log field is a String data type.
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void set(String field, String value) {
    if (value != null) {
        final ScalarWriter w = strings.get(field);
        if (w != null) {
            logger.debug("Parsed field: {}, as string: {}", field, value);
            w.setString(value);
        } else {
            logger.warn("No 'string' writer found for field: {}", field);
        }
    }
}
Also used : ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 22 with ScalarWriter

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

the class HttpdLogRecord method writeLongColumn.

/**
 * Helper function to write a 1D long column
 *
 * @param rowWriter The row to which the data will be written
 * @param name The column name
 * @param value The value to be written
 */
private void writeLongColumn(TupleWriter rowWriter, String name, long value) {
    ScalarWriter colWriter = getColWriter(rowWriter, name, MinorType.BIGINT);
    colWriter.setLong(value);
}
Also used : ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 23 with ScalarWriter

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

the class HttpdLogRecord method setTime.

/**
 * This method is referenced and called via reflection. This is added as a parsing target for the parser. It will get
 * called when the value of a log field is a Time data type.
 *
 * @param field name of field
 * @param value value of field
 */
@SuppressWarnings("unused")
public void setTime(String field, String value) {
    if (value != null) {
        final ScalarWriter w = times.get(field);
        if (w != null) {
            logger.debug("Parsed field: {}, as long: {}", field, value);
            w.setTime(LocalTime.parse(value));
        } else {
            logger.warn("No 'date' writer found for field: {}", field);
        }
    }
}
Also used : ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 24 with ScalarWriter

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

the class HDF5BatchReader method writeFloat4Column.

private void writeFloat4Column(TupleWriter rowWriter, String name, float value) {
    ScalarWriter colWriter = getColWriter(rowWriter, name, TypeProtos.MinorType.FLOAT4);
    colWriter.setDouble(value);
}
Also used : ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Example 25 with ScalarWriter

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

the class HDF5BatchReader method writeTimestampListColumn.

private void writeTimestampListColumn(TupleWriter rowWriter, String name, long[] list) {
    int index = rowWriter.tupleSchema().index(name);
    if (index == -1) {
        ColumnMetadata colSchema = MetadataUtils.newScalar(name, TypeProtos.MinorType.TIMESTAMP, TypeProtos.DataMode.REPEATED);
        index = rowWriter.addColumn(colSchema);
    }
    ScalarWriter arrayWriter = rowWriter.column(index).array().scalar();
    for (long l : list) {
        arrayWriter.setTimestamp(Instant.ofEpochMilli(l));
    }
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) ScalarWriter(org.apache.drill.exec.vector.accessor.ScalarWriter)

Aggregations

ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)120 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)69 SubOperatorTest (org.apache.drill.test.SubOperatorTest)68 Test (org.junit.Test)68 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)51 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)44 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)31 ArrayWriter (org.apache.drill.exec.vector.accessor.ArrayWriter)26 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)25 ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)24 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)23 ArrayReader (org.apache.drill.exec.vector.accessor.ArrayReader)22 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)21 ExtendableRowSet (org.apache.drill.exec.physical.rowSet.RowSet.ExtendableRowSet)19 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)18 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)17 TupleReader (org.apache.drill.exec.vector.accessor.TupleReader)17 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)14 RowSetReader (org.apache.drill.test.rowSet.RowSetReader)14 ResultSetLoader (org.apache.drill.exec.physical.rowSet.ResultSetLoader)13