use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class PageProcessorBenchmark method rowOriented.
@Benchmark
public Page rowOriented() {
PageBuilder pageBuilder = new PageBuilder(types);
int end = processor.process(null, inputPage, 0, inputPage.getPositionCount(), pageBuilder);
return pageBuilder.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class BenchmarkDecimalOperators method execute.
private List<Page> execute(BaseState state) {
ImmutableList.Builder<Page> pages = ImmutableList.builder();
Page inputPage = state.getInputPage();
PageBuilder pageBuilder = state.getPageBuilder();
PageProcessor processor = state.getProcessor();
int currentPosition = 0;
while (currentPosition < PAGE_SIZE) {
pageBuilder.reset();
currentPosition = processor.process(null, inputPage, currentPosition, inputPage.getPositionCount(), pageBuilder);
pages.add(pageBuilder.build());
}
return pages.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class MongoPageSource method getNextPage.
@Override
public Page getNextPage() {
PageBuilder pageBuilder = new PageBuilder(columnTypes);
count = 0;
for (int i = 0; i < ROWS_PER_REQUEST; i++) {
if (!cursor.hasNext()) {
finished = true;
break;
}
currentDoc = cursor.next();
count++;
pageBuilder.declarePosition();
for (int column = 0; column < columnTypes.size(); column++) {
BlockBuilder output = pageBuilder.getBlockBuilder(column);
appendTo(columnTypes.get(column), currentDoc.get(columnNames.get(column)), output);
}
}
totalCount += count;
return pageBuilder.build();
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class GenericPageProcessor method processColumnarDictionary.
@Override
public Page processColumnarDictionary(ConnectorSession session, Page page, List<? extends Type> types) {
Page inputPage = getNonLazyPage(page);
int[] selectedPositions = filterPage(inputPage);
Map<DictionaryId, DictionaryId> dictionarySourceIds = new HashMap<>();
if (selectedPositions.length == 0) {
return null;
}
if (projections.isEmpty()) {
return new Page(selectedPositions.length);
}
PageBuilder pageBuilder = new PageBuilder(types);
Block[] inputBlocks = page.getBlocks();
Block[] outputBlocks = new Block[projections.size()];
for (int projectionIndex = 0; projectionIndex < projections.size(); projectionIndex++) {
ProjectionFunction projection = projections.get(projectionIndex);
if (canDictionaryProcess(projection, inputPage)) {
outputBlocks[projectionIndex] = projectColumnarDictionary(inputPage, selectedPositions, projection, dictionarySourceIds);
} else {
outputBlocks[projectionIndex] = projectColumnar(selectedPositions, pageBuilder.getBlockBuilder(projectionIndex), inputBlocks, projection).build();
}
}
for (Block block : outputBlocks) {
verify(block.getPositionCount() == selectedPositions.length);
}
return new Page(selectedPositions.length, outputBlocks);
}
use of com.facebook.presto.spi.PageBuilder in project presto by prestodb.
the class TableFinishOperator method getOutput.
@Override
public Page getOutput() {
if (state != State.FINISHING) {
return null;
}
state = State.FINISHED;
outputMetadata = tableFinisher.finishTable(fragmentBuilder.build());
PageBuilder page = new PageBuilder(getTypes());
page.declarePosition();
BIGINT.writeLong(page.getBlockBuilder(0), rowCount);
return page.build();
}
Aggregations