use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class GenericPageProcessor method processColumnar.
@Override
public Page processColumnar(ConnectorSession session, Page page, List<? extends Type> types) {
int[] selectedPositions = filterPage(page);
if (selectedPositions.length == 0) {
return null;
}
if (projections.isEmpty()) {
return new Page(selectedPositions.length);
}
PageBuilder pageBuilder = new PageBuilder(types);
Block[] inputBlocks = page.getBlocks();
for (int projectionIndex = 0; projectionIndex < projections.size(); projectionIndex++) {
ProjectionFunction projection = projections.get(projectionIndex);
projectColumnar(selectedPositions, pageBuilder.getBlockBuilder(projectionIndex), inputBlocks, projection);
}
pageBuilder.declarePositions(selectedPositions.length);
return pageBuilder.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class DeleteOperator method getOutput.
@Override
public Page getOutput() {
if ((state != State.FINISHING) || !finishFuture.isDone()) {
return null;
}
state = State.FINISHED;
Collection<Slice> fragments = getFutureValue(finishFuture);
PageBuilder page = new PageBuilder(TYPES);
BlockBuilder rowsBuilder = page.getBlockBuilder(0);
BlockBuilder fragmentBuilder = page.getBlockBuilder(1);
// write row count
page.declarePosition();
BIGINT.writeLong(rowsBuilder, rowCount);
fragmentBuilder.appendNull();
// write fragments
for (Slice fragment : fragments) {
page.declarePosition();
rowsBuilder.appendNull();
VARBINARY.writeSlice(fragmentBuilder, fragment);
}
return page.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class MetadataDeleteOperator method getOutput.
@Override
public Page getOutput() {
if (finished) {
return null;
}
finished = true;
OptionalLong rowsDeletedCount = metadata.metadataDelete(session, tableHandle, tableLayout);
PageBuilder page = new PageBuilder(TYPES);
BlockBuilder rowsBuilder = page.getBlockBuilder(0);
page.declarePosition();
if (rowsDeletedCount.isPresent()) {
BIGINT.writeLong(rowsBuilder, rowsDeletedCount.getAsLong());
} else {
rowsBuilder.appendNull();
}
return page.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class RowNumberOperator method getSelectedRows.
private Page getSelectedRows() {
PageBuilder pageBuilder = new PageBuilder(types);
int rowNumberChannel = types.size() - 1;
for (int currentPosition = 0; currentPosition < inputPage.getPositionCount(); currentPosition++) {
long partitionId = getPartitionId(currentPosition);
long rowCount = partitionRowCount.get(partitionId);
if (rowCount == maxRowsPerPartition.get()) {
continue;
}
pageBuilder.declarePosition();
for (int i = 0; i < outputChannels.length; i++) {
int channel = outputChannels[i];
Type type = types.get(i);
type.appendTo(inputPage.getBlock(channel), currentPosition, pageBuilder.getBlockBuilder(i));
}
BIGINT.writeLong(pageBuilder.getBlockBuilder(rowNumberChannel), rowCount + 1);
partitionRowCount.set(partitionId, rowCount + 1);
}
if (pageBuilder.isEmpty()) {
return null;
}
return pageBuilder.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class TupleFilterProcessor method processColumnar.
@Override
public Page processColumnar(ConnectorSession session, Page page, List<? extends Type> types) {
PageBuilder pageBuilder = new PageBuilder(types);
int positionCount = page.getPositionCount();
int[] selectedPositions = new int[positionCount];
int selectedCount = 0;
for (int i = 0; i < positionCount; i++) {
if (matches(i, page)) {
selectedPositions[selectedCount++] = i;
}
}
for (int i = 0; i < outputTypes.size(); i++) {
Type type = outputTypes.get(i);
Block block = page.getBlock(i);
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i);
for (int position : selectedPositions) {
type.appendTo(block, position, blockBuilder);
}
}
pageBuilder.declarePositions(selectedCount);
return pageBuilder.build();
}
Aggregations