Search in sources :

Example 1 with PageProcessor

use of com.facebook.presto.operator.PageProcessor 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 2 with PageProcessor

use of com.facebook.presto.operator.PageProcessor in project presto by prestodb.

the class FunctionAssertions method compileScanFilterProject.

private SourceOperatorFactory compileScanFilterProject(Expression filter, Expression projection, ExpressionCompiler compiler) {
    filter = new SymbolToInputRewriter(INPUT_MAPPING).rewrite(filter);
    projection = new SymbolToInputRewriter(INPUT_MAPPING).rewrite(projection);
    IdentityLinkedHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(TEST_SESSION, metadata, SQL_PARSER, INPUT_TYPES, ImmutableList.of(filter, projection), emptyList());
    try {
        Supplier<CursorProcessor> cursorProcessor = compiler.compileCursorProcessor(toRowExpression(filter, expressionTypes), ImmutableList.of(toRowExpression(projection, expressionTypes)), SOURCE_ID);
        Supplier<PageProcessor> pageProcessor = compiler.compilePageProcessor(toRowExpression(filter, expressionTypes), ImmutableList.of(toRowExpression(projection, expressionTypes)));
        return new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), SOURCE_ID, PAGE_SOURCE_PROVIDER, cursorProcessor, pageProcessor, ImmutableList.of(), ImmutableList.of(expressionTypes.get(projection)));
    } catch (Throwable e) {
        if (e instanceof UncheckedExecutionException) {
            e = e.getCause();
        }
        throw new RuntimeException("Error compiling " + projection + ": " + e.getMessage(), e);
    }
}
Also used : CursorProcessor(com.facebook.presto.operator.CursorProcessor) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) PageProcessor(com.facebook.presto.operator.PageProcessor) GenericPageProcessor(com.facebook.presto.operator.GenericPageProcessor) RowExpression(com.facebook.presto.sql.relational.RowExpression) CanonicalizeExpressions.canonicalizeExpression(com.facebook.presto.sql.planner.optimizations.CanonicalizeExpressions.canonicalizeExpression) DereferenceExpression(com.facebook.presto.sql.tree.DereferenceExpression) Expression(com.facebook.presto.sql.tree.Expression) SymbolToInputRewriter(com.facebook.presto.sql.planner.SymbolToInputRewriter)

Example 3 with PageProcessor

use of com.facebook.presto.operator.PageProcessor in project presto by prestodb.

the class FunctionAssertions method compileFilterWithNoInputColumns.

private OperatorFactory compileFilterWithNoInputColumns(Expression filter, ExpressionCompiler compiler) {
    filter = new SymbolToInputRewriter(ImmutableMap.of()).rewrite(filter);
    IdentityLinkedHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(TEST_SESSION, metadata, SQL_PARSER, INPUT_TYPES, ImmutableList.of(filter), emptyList());
    try {
        Supplier<PageProcessor> processor = compiler.compilePageProcessor(toRowExpression(filter, expressionTypes), ImmutableList.of());
        return new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of());
    } catch (Throwable e) {
        if (e instanceof UncheckedExecutionException) {
            e = e.getCause();
        }
        throw new RuntimeException("Error compiling " + filter + ": " + e.getMessage(), e);
    }
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) PageProcessor(com.facebook.presto.operator.PageProcessor) GenericPageProcessor(com.facebook.presto.operator.GenericPageProcessor) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) RowExpression(com.facebook.presto.sql.relational.RowExpression) CanonicalizeExpressions.canonicalizeExpression(com.facebook.presto.sql.planner.optimizations.CanonicalizeExpressions.canonicalizeExpression) DereferenceExpression(com.facebook.presto.sql.tree.DereferenceExpression) Expression(com.facebook.presto.sql.tree.Expression) SymbolToInputRewriter(com.facebook.presto.sql.planner.SymbolToInputRewriter)

Example 4 with PageProcessor

use of com.facebook.presto.operator.PageProcessor in project presto by prestodb.

the class FunctionAssertions method compileFilterProject.

private OperatorFactory compileFilterProject(Expression filter, Expression projection, ExpressionCompiler compiler) {
    filter = new SymbolToInputRewriter(INPUT_MAPPING).rewrite(filter);
    projection = new SymbolToInputRewriter(INPUT_MAPPING).rewrite(projection);
    IdentityLinkedHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(TEST_SESSION, metadata, SQL_PARSER, INPUT_TYPES, ImmutableList.of(filter, projection), emptyList());
    try {
        List<RowExpression> projections = ImmutableList.of(toRowExpression(projection, expressionTypes));
        Supplier<PageProcessor> processor = compiler.compilePageProcessor(toRowExpression(filter, expressionTypes), projections);
        return new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of(expressionTypes.get(projection)));
    } catch (Throwable e) {
        if (e instanceof UncheckedExecutionException) {
            e = e.getCause();
        }
        throw new RuntimeException("Error compiling " + projection + ": " + e.getMessage(), e);
    }
}
Also used : UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) RowExpression(com.facebook.presto.sql.relational.RowExpression) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) PageProcessor(com.facebook.presto.operator.PageProcessor) GenericPageProcessor(com.facebook.presto.operator.GenericPageProcessor) RowExpression(com.facebook.presto.sql.relational.RowExpression) CanonicalizeExpressions.canonicalizeExpression(com.facebook.presto.sql.planner.optimizations.CanonicalizeExpressions.canonicalizeExpression) DereferenceExpression(com.facebook.presto.sql.tree.DereferenceExpression) Expression(com.facebook.presto.sql.tree.Expression) SymbolToInputRewriter(com.facebook.presto.sql.planner.SymbolToInputRewriter)

Example 5 with PageProcessor

use of com.facebook.presto.operator.PageProcessor in project presto by prestodb.

the class DynamicTupleFilterFactory method filterWithTuple.

public OperatorFactory filterWithTuple(Page tuplePage) {
    Page normalizedTuplePage = normalizeTuplePage(tuplePage);
    Supplier<PageProcessor> processor = () -> new TupleFilterProcessor(normalizedTuplePage, outputTypes, outputFilterChannels);
    return new FilterAndProjectOperatorFactory(filterOperatorId, planNodeId, processor, outputTypes);
}
Also used : FilterAndProjectOperatorFactory(com.facebook.presto.operator.FilterAndProjectOperator.FilterAndProjectOperatorFactory) PageProcessor(com.facebook.presto.operator.PageProcessor) Page(com.facebook.presto.spi.Page)

Aggregations

PageProcessor (com.facebook.presto.operator.PageProcessor)5 GenericPageProcessor (com.facebook.presto.operator.GenericPageProcessor)3 Type (com.facebook.presto.spi.type.Type)3 SymbolToInputRewriter (com.facebook.presto.sql.planner.SymbolToInputRewriter)3 CanonicalizeExpressions.canonicalizeExpression (com.facebook.presto.sql.planner.optimizations.CanonicalizeExpressions.canonicalizeExpression)3 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)3 RowExpression (com.facebook.presto.sql.relational.RowExpression)3 DereferenceExpression (com.facebook.presto.sql.tree.DereferenceExpression)3 Expression (com.facebook.presto.sql.tree.Expression)3 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)3 Page (com.facebook.presto.spi.Page)2 CursorProcessor (com.facebook.presto.operator.CursorProcessor)1 FilterAndProjectOperatorFactory (com.facebook.presto.operator.FilterAndProjectOperator.FilterAndProjectOperatorFactory)1 PageBuilder (com.facebook.presto.spi.PageBuilder)1 ImmutableList (com.google.common.collect.ImmutableList)1