Search in sources :

Example 1 with RichColumnDescriptor

use of com.facebook.presto.hive.parquet.RichColumnDescriptor in project presto by prestodb.

the class ParquetReader method initializeColumnReaders.

private void initializeColumnReaders() {
    for (PrimitiveColumnIO columnIO : getColumns(fileSchema, requestedSchema)) {
        ColumnDescriptor descriptor = columnIO.getColumnDescriptor();
        RichColumnDescriptor column = new RichColumnDescriptor(descriptor.getPath(), columnIO.getType().asPrimitiveType(), descriptor.getMaxRepetitionLevel(), descriptor.getMaxDefinitionLevel());
        columnReadersMap.put(column, ParquetColumnReader.createReader(column));
    }
}
Also used : RichColumnDescriptor(com.facebook.presto.hive.parquet.RichColumnDescriptor) RichColumnDescriptor(com.facebook.presto.hive.parquet.RichColumnDescriptor) ColumnDescriptor(parquet.column.ColumnDescriptor) PrimitiveColumnIO(parquet.io.PrimitiveColumnIO)

Example 2 with RichColumnDescriptor

use of com.facebook.presto.hive.parquet.RichColumnDescriptor in project presto by prestodb.

the class ParquetReader method readBlock.

private Block readBlock(String name, Type type, List<String> path, IntList offsets) throws IOException {
    path.add(name);
    Optional<RichColumnDescriptor> descriptor = getDescriptor(fileSchema, requestedSchema, path);
    if (!descriptor.isPresent()) {
        path.remove(name);
        return RunLengthEncodedBlock.create(type, null, batchSize);
    }
    Block block;
    if (ROW.equals(type.getTypeSignature().getBase())) {
        block = readStruct(type, path, offsets);
    } else if (MAP.equals(type.getTypeSignature().getBase())) {
        block = readMap(type, path, offsets);
    } else if (ARRAY.equals(type.getTypeSignature().getBase())) {
        block = readArray(type, path, offsets);
    } else {
        block = readPrimitive(descriptor.get(), type, offsets);
    }
    path.remove(name);
    return block;
}
Also used : RichColumnDescriptor(com.facebook.presto.hive.parquet.RichColumnDescriptor) 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)

Example 3 with RichColumnDescriptor

use of com.facebook.presto.hive.parquet.RichColumnDescriptor in project presto by prestodb.

the class ParquetReader method nextBatch.

public int nextBatch() {
    if (nextRowInGroup >= currentGroupRowCount && !advanceToNextRowGroup()) {
        return -1;
    }
    batchSize = toIntExact(min(MAX_VECTOR_LENGTH, currentGroupRowCount - nextRowInGroup));
    nextRowInGroup += batchSize;
    currentPosition += batchSize;
    for (PrimitiveColumnIO columnIO : getColumns(fileSchema, requestedSchema)) {
        ColumnDescriptor descriptor = columnIO.getColumnDescriptor();
        RichColumnDescriptor column = new RichColumnDescriptor(descriptor.getPath(), columnIO.getType().asPrimitiveType(), descriptor.getMaxRepetitionLevel(), descriptor.getMaxDefinitionLevel());
        ParquetColumnReader columnReader = columnReadersMap.get(column);
        columnReader.prepareNextRead(batchSize);
    }
    return batchSize;
}
Also used : RichColumnDescriptor(com.facebook.presto.hive.parquet.RichColumnDescriptor) RichColumnDescriptor(com.facebook.presto.hive.parquet.RichColumnDescriptor) ColumnDescriptor(parquet.column.ColumnDescriptor) PrimitiveColumnIO(parquet.io.PrimitiveColumnIO)

Aggregations

RichColumnDescriptor (com.facebook.presto.hive.parquet.RichColumnDescriptor)3 ColumnDescriptor (parquet.column.ColumnDescriptor)2 PrimitiveColumnIO (parquet.io.PrimitiveColumnIO)2 ArrayBlock (com.facebook.presto.spi.block.ArrayBlock)1 Block (com.facebook.presto.spi.block.Block)1 InterleavedBlock (com.facebook.presto.spi.block.InterleavedBlock)1 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)1