Search in sources :

Example 1 with FieldConverter

use of org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter in project drill by apache.

the class MetadataControllerBatch method appendStatistics.

private void appendStatistics(StatisticsRecordCollector statisticsCollector) {
    if (context.getOptions().getOption(PlannerSettings.STATISTICS_USE)) {
        List<FieldConverter> fieldConverters = new ArrayList<>();
        int fieldId = 0;
        for (VectorWrapper<?> wrapper : right) {
            if (wrapper.getField().getName().equalsIgnoreCase(WriterPrel.PARTITION_COMPARATOR_FIELD)) {
                continue;
            }
            FieldReader reader = wrapper.getValueVector().getReader();
            FieldConverter converter = StatisticsRecordWriterImpl.getConverter(statisticsCollector, fieldId++, wrapper.getField().getName(), reader);
            fieldConverters.add(converter);
        }
        try {
            for (int counter = 0; counter < right.getRecordCount(); counter++) {
                statisticsCollector.startStatisticsRecord();
                // write the current record
                for (FieldConverter converter : fieldConverters) {
                    converter.setPosition(counter);
                    converter.startField();
                    converter.writeField();
                    converter.endField();
                }
                statisticsCollector.endStatisticsRecord();
            }
        } catch (IOException e) {
            throw UserException.dataWriteError(e).addContext("Failed to write metadata").build(logger);
        }
    }
}
Also used : FieldConverter(org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FieldReader(org.apache.drill.exec.vector.complex.reader.FieldReader)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 FieldConverter (org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter)1 FieldReader (org.apache.drill.exec.vector.complex.reader.FieldReader)1