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);
}
}
Aggregations