Search in sources :

Example 6 with ArrayBlock

use of com.facebook.presto.spi.block.ArrayBlock in project presto by prestodb.

the class ParquetReader method readArray.

private Block readArray(Type type, List<String> path, IntList elementOffsets) throws IOException {
    List<Type> parameters = type.getTypeParameters();
    checkArgument(parameters.size() == 1, "Arrays must have a single type parameter, found %d", parameters.size());
    path.add(ARRAY_TYPE_NAME);
    Type elementType = parameters.get(0);
    Block block = readBlock(ARRAY_ELEMENT_NAME, elementType, path, elementOffsets);
    path.remove(ARRAY_TYPE_NAME);
    if (elementOffsets.isEmpty()) {
        for (int i = 0; i < batchSize; i++) {
            elementOffsets.add(0);
        }
        return RunLengthEncodedBlock.create(elementType, null, batchSize);
    }
    int[] offsets = new int[batchSize + 1];
    for (int i = 1; i < offsets.length; i++) {
        offsets[i] = offsets[i - 1] + elementOffsets.getInt(i - 1);
    }
    return new ArrayBlock(batchSize, new boolean[batchSize], offsets, block);
}
Also used : Type(com.facebook.presto.spi.type.Type) MessageType(parquet.schema.MessageType) ArrayBlock(com.facebook.presto.spi.block.ArrayBlock) Block(com.facebook.presto.spi.block.Block) RunLengthEncodedBlock(com.facebook.presto.spi.block.RunLengthEncodedBlock) ArrayBlock(com.facebook.presto.spi.block.ArrayBlock) InterleavedBlock(com.facebook.presto.spi.block.InterleavedBlock)

Aggregations

ArrayBlock (com.facebook.presto.spi.block.ArrayBlock)6 Block (com.facebook.presto.spi.block.Block)6 Type (com.facebook.presto.spi.type.Type)6 InterleavedBlock (com.facebook.presto.spi.block.InterleavedBlock)5 BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)3 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)3 MessageType (parquet.schema.MessageType)3 OrcCorruptionException (com.facebook.presto.orc.OrcCorruptionException)2 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)2 StreamReaders.createStreamReader (com.facebook.presto.orc.reader.StreamReaders.createStreamReader)1 NamedTypeSignature (com.facebook.presto.spi.type.NamedTypeSignature)1 TypeSignatureParameter (com.facebook.presto.spi.type.TypeSignatureParameter)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1