Search in sources :

Example 11 with ColumnChunk

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());
}
Also used : IntArrayBlock(com.facebook.presto.common.block.IntArrayBlock) Int32ValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int32ValuesDecoder) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) IntArrayBlock(com.facebook.presto.common.block.IntArrayBlock) Block(com.facebook.presto.common.block.Block) ColumnChunk(com.facebook.presto.parquet.reader.ColumnChunk)

Aggregations

ColumnChunk (com.facebook.presto.parquet.reader.ColumnChunk)11 Block (com.facebook.presto.common.block.Block)8 RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)8 IntArrayBlock (com.facebook.presto.common.block.IntArrayBlock)4 VariableWidthBlock (com.facebook.presto.common.block.VariableWidthBlock)4 BinaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.BinaryValuesDecoder)4 ValueBuffer (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.BinaryValuesDecoder.ValueBuffer)4 Slice (io.airlift.slice.Slice)4 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 ParquetDecodingException (org.apache.parquet.io.ParquetDecodingException)3 Int32ValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int32ValuesDecoder)2 PrestoException (com.facebook.presto.spi.PrestoException)2