Search in sources :

Example 11 with LazyBlock

use of com.facebook.presto.common.block.LazyBlock 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)11 Block (com.facebook.presto.common.block.Block)11 LazyBlock (com.facebook.presto.common.block.LazyBlock)11 RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)4 Test (org.testng.annotations.Test)4 Threads.daemonThreadsNamed (com.facebook.airlift.concurrent.Threads.daemonThreadsNamed)3 BlockAssertions (com.facebook.presto.block.BlockAssertions)3 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)3 BOOLEAN (com.facebook.presto.common.type.BooleanType.BOOLEAN)3 VARCHAR (com.facebook.presto.common.type.VarcharType.VARCHAR)3 MetadataManager (com.facebook.presto.metadata.MetadataManager)3 MetadataManager.createTestMetadataManager (com.facebook.presto.metadata.MetadataManager.createTestMetadataManager)3 PageAssertions.assertPageEquals (com.facebook.presto.operator.PageAssertions.assertPageEquals)3 MAX_BATCH_SIZE (com.facebook.presto.operator.project.PageProcessor.MAX_BATCH_SIZE)3 PrestoException (com.facebook.presto.spi.PrestoException)3 TypeSignatureProvider.fromTypes (com.facebook.presto.sql.analyzer.TypeSignatureProvider.fromTypes)3 PageFunctionCompiler (com.facebook.presto.sql.gen.PageFunctionCompiler)3 Expressions.call (com.facebook.presto.sql.relational.Expressions.call)3 Expressions.constant (com.facebook.presto.sql.relational.Expressions.constant)3 Expressions.field (com.facebook.presto.sql.relational.Expressions.field)3