Search in sources :

Example 1 with StatisticsRecordWriterImpl

use of org.apache.drill.exec.store.StatisticsRecordWriterImpl in project drill by apache.

the class StatisticsWriterRecordBatch method setupNewSchema.

protected void setupNewSchema() {
    try {
        // update the schema in RecordWriter
        stats.startSetup();
        recordWriter.updateSchema(incoming);
        // Create two vectors for:
        // 1. Fragment unique id.
        // 2. Summary: currently contains number of records written.
        final MaterializedField fragmentIdField = MaterializedField.create("Fragment", Types.required(TypeProtos.MinorType.VARCHAR));
        final MaterializedField summaryField = MaterializedField.create("Number of records written", Types.required(TypeProtos.MinorType.BIGINT));
        container.addOrGet(fragmentIdField);
        container.addOrGet(summaryField);
        container.buildSchema(BatchSchema.SelectionVectorMode.NONE);
    } finally {
        stats.stopSetup();
    }
    try {
        statsRecordWriterImpl = new StatisticsRecordWriterImpl(incoming, recordWriter);
    } catch (IOException e) {
        throw UserException.dataWriteError(e).addContext("Failure when creating the statistics record writer").build(logger);
    }
    container.buildSchema(BatchSchema.SelectionVectorMode.NONE);
    schema = container.getSchema();
}
Also used : MaterializedField(org.apache.drill.exec.record.MaterializedField) IOException(java.io.IOException) StatisticsRecordWriterImpl(org.apache.drill.exec.store.StatisticsRecordWriterImpl)

Aggregations

IOException (java.io.IOException)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 StatisticsRecordWriterImpl (org.apache.drill.exec.store.StatisticsRecordWriterImpl)1