Search in sources :

Example 1 with RowsToKeepResult

use of com.facebook.presto.raptor.storage.DeltaShardLoader.RowsToKeepResult in project presto by prestodb.

the class OrcPageSource method getNextPage.

@Override
public Page getNextPage() {
    try {
        batchId++;
        int batchSize = recordReader.nextBatch();
        if (batchSize <= 0) {
            close();
            return null;
        }
        completedPositions += batchSize;
        long filePosition = recordReader.getFilePosition();
        // for every page, will generate its rowsToKeep
        RowsToKeepResult rowsToKeep = deltaShardLoader.getRowsToKeep(batchSize, filePosition);
        Block[] blocks = new Block[columnIndexes.length];
        for (int fieldId = 0; fieldId < blocks.length; fieldId++) {
            if (constantBlocks[fieldId] != null) {
                blocks[fieldId] = constantBlocks[fieldId].getRegion(0, rowsToKeep.keepAll() ? batchSize : rowsToKeep.size());
            } else if (columnIndexes[fieldId] == ROWID_COLUMN) {
                blocks[fieldId] = buildSequenceBlock(filePosition, batchSize, rowsToKeep);
            } else {
                blocks[fieldId] = new LazyBlock(batchSize, new OrcBlockLoader(columnIndexes[fieldId], rowsToKeep));
            }
        }
        return new Page(rowsToKeep.keepAll() ? batchSize : rowsToKeep.size(), blocks);
    } catch (IOException | RuntimeException e) {
        closeWithSuppression(e);
        throw new PrestoException(RAPTOR_ERROR, e);
    }
}
Also used : LazyBlock(com.facebook.presto.common.block.LazyBlock) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) Utils.nativeValueToBlock(com.facebook.presto.common.Utils.nativeValueToBlock) Block(com.facebook.presto.common.block.Block) LazyBlock(com.facebook.presto.common.block.LazyBlock) Page(com.facebook.presto.common.Page) PrestoException(com.facebook.presto.spi.PrestoException) IOException(java.io.IOException) RowsToKeepResult(com.facebook.presto.raptor.storage.DeltaShardLoader.RowsToKeepResult)

Aggregations

Page (com.facebook.presto.common.Page)1 Utils.nativeValueToBlock (com.facebook.presto.common.Utils.nativeValueToBlock)1 Block (com.facebook.presto.common.block.Block)1 LazyBlock (com.facebook.presto.common.block.LazyBlock)1 RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)1 RowsToKeepResult (com.facebook.presto.raptor.storage.DeltaShardLoader.RowsToKeepResult)1 PrestoException (com.facebook.presto.spi.PrestoException)1 IOException (java.io.IOException)1