use of com.facebook.presto.parquet.reader.ColumnChunk in project presto by prestodb.
the class Int32NestedBatchReader method readNestedNoNull.
@Override
protected ColumnChunk readNestedNoNull() throws IOException {
int maxDefinitionLevel = columnDescriptor.getMaxDefinitionLevel();
RepetitionLevelDecodingContext repetitionLevelDecodingContext = readRepetitionLevels(nextBatchSize);
DefinitionLevelDecodingContext definitionLevelDecodingContext = readDefinitionLevels(repetitionLevelDecodingContext.getDLValuesDecoderContexts(), repetitionLevelDecodingContext.getRepetitionLevels().length);
int[] definitionLevels = definitionLevelDecodingContext.getDefinitionLevels();
int newBatchSize = 0;
for (ValuesDecoderContext valuesDecoderContext : definitionLevelDecodingContext.getValuesDecoderContexts()) {
int valueCount = 0;
for (int i = valuesDecoderContext.getStart(); i < valuesDecoderContext.getEnd(); i++) {
valueCount += (definitionLevels[i] == maxDefinitionLevel ? 1 : 0);
}
newBatchSize += valueCount;
valuesDecoderContext.setNonNullCount(valueCount);
valuesDecoderContext.setValueCount(valueCount);
}
int[] values = new int[newBatchSize];
int offset = 0;
for (ValuesDecoderContext valuesDecoderContext : definitionLevelDecodingContext.getValuesDecoderContexts()) {
((Int32ValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNext(values, offset, valuesDecoderContext.getNonNullCount());
offset += valuesDecoderContext.getValueCount();
}
Block block = new IntArrayBlock(newBatchSize, Optional.empty(), values);
return new ColumnChunk(block, definitionLevels, repetitionLevelDecodingContext.getRepetitionLevels());
}
Aggregations