Search in sources :

Example 6 with PageBuilder

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();
}
Also used : SequencePageBuilder(com.facebook.presto.SequencePageBuilder) PageBuilder(com.facebook.presto.spi.PageBuilder) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 7 with PageBuilder

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();
}
Also used : PageProcessor(com.facebook.presto.operator.PageProcessor) ImmutableList(com.google.common.collect.ImmutableList) Page(com.facebook.presto.spi.Page) PageBuilder(com.facebook.presto.spi.PageBuilder)

Example 8 with PageBuilder

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();
}
Also used : PageBuilder(com.facebook.presto.spi.PageBuilder) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) InterleavedBlockBuilder(com.facebook.presto.spi.block.InterleavedBlockBuilder)

Example 9 with PageBuilder

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);
}
Also used : HashMap(java.util.HashMap) DictionaryId.randomDictionaryId(com.facebook.presto.spi.block.DictionaryId.randomDictionaryId) DictionaryId(com.facebook.presto.spi.block.DictionaryId) Block(com.facebook.presto.spi.block.Block) DictionaryBlock(com.facebook.presto.spi.block.DictionaryBlock) LazyBlock(com.facebook.presto.spi.block.LazyBlock) RunLengthEncodedBlock(com.facebook.presto.spi.block.RunLengthEncodedBlock) Page(com.facebook.presto.spi.Page) PageBuilder(com.facebook.presto.spi.PageBuilder)

Example 10 with PageBuilder

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();
}
Also used : PageBuilder(com.facebook.presto.spi.PageBuilder)

Aggregations

PageBuilder (com.facebook.presto.spi.PageBuilder)45 Page (com.facebook.presto.spi.Page)23 Block (com.facebook.presto.spi.block.Block)16 Type (com.facebook.presto.spi.type.Type)15 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)14 ImmutableList (com.google.common.collect.ImmutableList)12 Test (org.testng.annotations.Test)10 List (java.util.List)7 Benchmark (org.openjdk.jmh.annotations.Benchmark)6 BytecodeBlock (com.facebook.presto.bytecode.BytecodeBlock)4 MethodDefinition (com.facebook.presto.bytecode.MethodDefinition)4 Parameter (com.facebook.presto.bytecode.Parameter)4 Variable (com.facebook.presto.bytecode.Variable)4 DictionaryBlock (com.facebook.presto.spi.block.DictionaryBlock)4 LazyBlock (com.facebook.presto.spi.block.LazyBlock)4 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)4 ArrayList (java.util.ArrayList)4 SequencePageBuilder (com.facebook.presto.SequencePageBuilder)3 Scope (com.facebook.presto.bytecode.Scope)3 IfStatement (com.facebook.presto.bytecode.control.IfStatement)3