Search in sources :

Example 16 with PageBuilder

use of com.facebook.presto.common.PageBuilder in project presto by prestodb.

the class TestRealHistogramAggregation method makeInput.

private static Page makeInput(int numberOfBuckets) {
    PageBuilder builder = new PageBuilder(ImmutableList.of(BIGINT, REAL, DOUBLE));
    for (int i = 0; i < 100; i++) {
        builder.declarePosition();
        BIGINT.writeLong(builder.getBlockBuilder(0), numberOfBuckets);
        // value
        REAL.writeLong(builder.getBlockBuilder(1), i);
        // weight
        DOUBLE.writeDouble(builder.getBlockBuilder(2), 1);
    }
    return builder.build();
}
Also used : PageBuilder(com.facebook.presto.common.PageBuilder)

Example 17 with PageBuilder

use of com.facebook.presto.common.PageBuilder in project presto by prestodb.

the class CommonSubExpressionBenchmark method ComputeRecordSet.

@Benchmark
public Optional<Page> ComputeRecordSet() {
    List<Type> types = ImmutableList.of(TYPE_MAP.get(this.functionType));
    PageBuilder pageBuilder = new PageBuilder(projectionTypes);
    RecordSet recordSet = new PageRecordSet(types, inputPage);
    cursorProcessor.process(null, new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    return Optional.of(pageBuilder.build());
}
Also used : Type(com.facebook.presto.common.type.Type) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) PageBuilder(com.facebook.presto.common.PageBuilder) SequencePageBuilder(com.facebook.presto.SequencePageBuilder) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 18 with PageBuilder

use of com.facebook.presto.common.PageBuilder in project presto by prestodb.

the class PageProcessorBenchmark method rowOriented.

@Benchmark
public Page rowOriented() {
    PageBuilder pageBuilder = new PageBuilder(types);
    cursorProcessor.process(null, yieldSignal, recordSet.cursor(), pageBuilder);
    return pageBuilder.build();
}
Also used : PageBuilder(com.facebook.presto.common.PageBuilder) SequencePageBuilder(com.facebook.presto.SequencePageBuilder) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 19 with PageBuilder

use of com.facebook.presto.common.PageBuilder in project presto by prestodb.

the class TestCursorProcessorCompiler method testCompilerWithCSE.

@Test
public void testCompilerWithCSE() {
    PageFunctionCompiler functionCompiler = new PageFunctionCompiler(METADATA, 0);
    ExpressionCompiler expressionCompiler = new ExpressionCompiler(METADATA, functionCompiler);
    RowExpression filter = new SpecialFormExpression(AND, BIGINT, ADD_X_Y_GREATER_THAN_2, ADD_X_Y_LESS_THAN_10);
    List<? extends RowExpression> projections = createIfProjectionList(5);
    Supplier<CursorProcessor> cseCursorProcessorSupplier = expressionCompiler.compileCursorProcessor(SESSION.getSqlFunctionProperties(), Optional.of(filter), projections, "key", true);
    Supplier<CursorProcessor> noCseSECursorProcessorSupplier = expressionCompiler.compileCursorProcessor(SESSION.getSqlFunctionProperties(), Optional.of(filter), projections, "key", false);
    Page input = createLongBlockPage(2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    List<Type> types = ImmutableList.of(BIGINT, BIGINT);
    PageBuilder pageBuilder = new PageBuilder(projections.stream().map(RowExpression::getType).collect(toList()));
    RecordSet recordSet = new PageRecordSet(types, input);
    cseCursorProcessorSupplier.get().process(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    Page pageFromCSE = pageBuilder.build();
    pageBuilder.reset();
    noCseSECursorProcessorSupplier.get().process(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    Page pageFromNoCSE = pageBuilder.build();
    checkPageEqual(pageFromCSE, pageFromNoCSE);
}
Also used : CursorProcessor(com.facebook.presto.operator.project.CursorProcessor) RowExpression(com.facebook.presto.spi.relation.RowExpression) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) Page(com.facebook.presto.common.Page) PageBuilder(com.facebook.presto.common.PageBuilder) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) Type(com.facebook.presto.common.type.Type) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) SpecialFormExpression(com.facebook.presto.spi.relation.SpecialFormExpression) Test(org.testng.annotations.Test)

Example 20 with PageBuilder

use of com.facebook.presto.common.PageBuilder in project presto by prestodb.

the class BenchmarkPageProcessor method handCoded.

@Benchmark
public Page handCoded(BenchmarkData data) {
    PageBuilder pageBuilder = new PageBuilder(ImmutableList.of(DOUBLE));
    int count = data.handcodedProcessor.process(data.inputPage, 0, data.inputPage.getPositionCount(), pageBuilder);
    checkState(count == data.inputPage.getPositionCount());
    return pageBuilder.build();
}
Also used : PageBuilder(com.facebook.presto.common.PageBuilder) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

PageBuilder (com.facebook.presto.common.PageBuilder)57 Page (com.facebook.presto.common.Page)27 Type (com.facebook.presto.common.type.Type)25 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)23 ImmutableList (com.google.common.collect.ImmutableList)14 Block (com.facebook.presto.common.block.Block)11 Test (org.testng.annotations.Test)11 ArrayType (com.facebook.presto.common.type.ArrayType)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Benchmark (org.openjdk.jmh.annotations.Benchmark)7 INTEGER (com.facebook.presto.common.type.IntegerType.INTEGER)4 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)3 DOUBLE (com.facebook.presto.common.type.DoubleType.DOUBLE)3 VarcharType.createUnboundedVarcharType (com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType)3 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)3 ConnectorSession (com.facebook.presto.spi.ConnectorSession)3 MaterializedResult (com.facebook.presto.testing.MaterializedResult)3 Slices (io.airlift.slice.Slices)3 File (java.io.File)3