Search in sources :

Example 31 with OperatorFactory

use of io.prestosql.operator.OperatorFactory in project hetu-core by openlookeng.

the class CountAggregationBenchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey");
    InternalAggregationFunction countFunction = localQueryRunner.getMetadata().getFunctionAndTypeManager().getAggregateFunctionImplementation(new Signature(QualifiedObjectName.valueOfDefaultFunction("count"), AGGREGATE, BIGINT.getTypeSignature()));
    AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(countFunction.bind(ImmutableList.of(0), Optional.empty())), false);
    return ImmutableList.of(tableScanOperator, aggregationOperator);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) OperatorFactory(io.prestosql.operator.OperatorFactory) AggregationOperatorFactory(io.prestosql.operator.AggregationOperator.AggregationOperatorFactory) AggregationOperatorFactory(io.prestosql.operator.AggregationOperator.AggregationOperatorFactory) Signature(io.prestosql.spi.function.Signature) InternalAggregationFunction(io.prestosql.operator.aggregation.InternalAggregationFunction)

Example 32 with OperatorFactory

use of io.prestosql.operator.OperatorFactory in project hetu-core by openlookeng.

the class PredicateFilterBenchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
    RowExpression filter = call(GREATER_THAN_OR_EQUAL.name(), localQueryRunner.getMetadata().getFunctionAndTypeManager().resolveOperatorFunctionHandle(GREATER_THAN_OR_EQUAL, fromTypes(DOUBLE, DOUBLE)), BOOLEAN, field(0, DOUBLE), constant(50000.0, DOUBLE));
    ExpressionCompiler expressionCompiler = new ExpressionCompiler(localQueryRunner.getMetadata(), new PageFunctionCompiler(localQueryRunner.getMetadata(), 0));
    Supplier<PageProcessor> pageProcessor = expressionCompiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field(0, DOUBLE)));
    FilterAndProjectOperator.FilterAndProjectOperatorFactory filterAndProjectOperator = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(1, new PlanNodeId("test"), pageProcessor, ImmutableList.of(DOUBLE), new DataSize(0, BYTE), 0);
    return ImmutableList.of(tableScanOperator, filterAndProjectOperator);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PageFunctionCompiler(io.prestosql.sql.gen.PageFunctionCompiler) PageProcessor(io.prestosql.operator.project.PageProcessor) OperatorFactory(io.prestosql.operator.OperatorFactory) DataSize(io.airlift.units.DataSize) RowExpression(io.prestosql.spi.relation.RowExpression) ExpressionCompiler(io.prestosql.sql.gen.ExpressionCompiler) FilterAndProjectOperator(io.prestosql.operator.FilterAndProjectOperator)

Example 33 with OperatorFactory

use of io.prestosql.operator.OperatorFactory in project hetu-core by openlookeng.

the class TestUnnestOperator method testUnnestNonNumericDoubles.

@Test
public void testUnnestNonNumericDoubles() {
    Metadata metadata = createTestMetadataManager();
    Type arrayType = metadata.getType(parseTypeSignature("array(double)"));
    Type mapType = metadata.getType(parseTypeSignature("map(bigint,double)"));
    List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(DOUBLE, NEGATIVE_INFINITY, POSITIVE_INFINITY, NaN), mapBlockOf(BIGINT, DOUBLE, ImmutableMap.of(1, NEGATIVE_INFINITY, 2, POSITIVE_INFINITY, 3, NaN))).build();
    OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), false);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE, BIGINT, DOUBLE).row(1L, NEGATIVE_INFINITY, 1L, NEGATIVE_INFINITY).row(1L, POSITIVE_INFINITY, 2L, POSITIVE_INFINITY).row(1L, NaN, 3L, NaN).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) ArrayType(io.prestosql.spi.type.ArrayType) OperatorFactory(io.prestosql.operator.OperatorFactory) Metadata(io.prestosql.metadata.Metadata) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 34 with OperatorFactory

use of io.prestosql.operator.OperatorFactory in project hetu-core by openlookeng.

the class TestUnnestOperator method testUnnest.

@Test
public void testUnnest() {
    Metadata metadata = createTestMetadataManager();
    Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
    Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
    List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(BIGINT, 2, 3), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(4, 5))).row(2L, arrayBlockOf(BIGINT, 99), null).row(3L, null, null).pageBreak().row(6L, arrayBlockOf(BIGINT, 7, 8), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(9, 10, 11, 12))).build();
    OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), false);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, BIGINT, BIGINT).row(1L, 2L, 4L, 5L).row(1L, 3L, null, null).row(2L, 99L, null, null).row(6L, 7L, 9L, 10L).row(6L, 8L, 11L, 12L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) ArrayType(io.prestosql.spi.type.ArrayType) OperatorFactory(io.prestosql.operator.OperatorFactory) Metadata(io.prestosql.metadata.Metadata) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 35 with OperatorFactory

use of io.prestosql.operator.OperatorFactory in project boostkit-bigdata by kunpengcompute.

the class OmniLocalExecutionPlanner method plan.

@Override
public LocalExecutionPlan plan(TaskContext taskContext, StageExecutionDescriptor stageExecutionDescriptor, PlanNode plan, List<Symbol> outputLayout, TypeProvider types, List<PlanNodeId> partitionedSourceOrder, OutputBuffer outputBuffer, OutputFactory outputOperatorFactory, Optional<PlanFragmentId> feederCTEId, Optional<PlanNodeId> feederCTEParentId, Map<String, CommonTableExecutionContext> cteCtx) {
    VecAllocatorHelper.createTaskLevelAllocator(taskContext);
    Session session = taskContext.getSession();
    LocalExecutionPlanContext context = new OmniLocalExecutionPlanContext(taskContext, types, metadata, dynamicFilterCacheManager, feederCTEId, feederCTEParentId, cteCtx);
    PhysicalOperation physicalOperation;
    try {
        physicalOperation = plan.accept(new OmniVisitor(session, stageExecutionDescriptor), context);
    } catch (Exception e) {
        log.warn("Unable to plan with OmniRuntime Operators for task: " + taskContext.getTaskId() + ", cause: " + e.getLocalizedMessage());
        return null;
    }
    for (DriverFactory driverFactory : context.getDriverFactories()) {
        for (OperatorFactory operatorFactory : driverFactory.getOperatorFactories()) {
            // if there is a data type not support by OmniRuntime, then fall back
            if (notSupportTypes(operatorFactory.getSourceTypes())) {
                log.warn("There is a data type not support by OmniRuntime: %s", operatorFactory.getSourceTypes().toString());
                return null;
            }
        }
    }
    Function<Page, Page> pagePreprocessor = enforceLayoutProcessor(outputLayout, physicalOperation.getLayout());
    List<Type> outputTypes = outputLayout.stream().map(types::get).collect(toImmutableList());
    context.addDriverFactory(context.isInputDriver(), true, ImmutableList.<OperatorFactory>builder().addAll(physicalOperation.getOperatorFactories()).add(outputOperatorFactory.createOutputOperator(context.getNextOperatorId(), plan.getId(), outputTypes, pagePreprocessor, taskContext)).build(), context.getDriverInstanceCount(), physicalOperation.getPipelineExecutionStrategy());
    addLookupOuterDrivers(context);
    addTransformOperators(context);
    // notify operator factories that planning has completed
    context.getDriverFactories().stream().map(DriverFactory::getOperatorFactories).flatMap(List::stream).filter(LocalPlannerAware.class::isInstance).map(LocalPlannerAware.class::cast).forEach(LocalPlannerAware::localPlannerComplete);
    log.debug("create the omni local execution plan successful!");
    return new LocalExecutionPlan(context.getDriverFactories(), partitionedSourceOrder, stageExecutionDescriptor, feederCTEId);
}
Also used : Page(io.prestosql.spi.Page) LocalPlannerAware(io.prestosql.operator.LocalPlannerAware) Type(io.prestosql.spi.type.Type) DataType(nova.hetu.omniruntime.type.DataType) FunctionType(nova.hetu.omniruntime.constants.FunctionType) LookupJoinOperatorFactory(io.prestosql.operator.LookupJoinOperatorFactory) SourceOperatorFactory(io.prestosql.operator.SourceOperatorFactory) OperatorFactory(io.prestosql.operator.OperatorFactory) OrderByOmniOperatorFactory.createOrderByOmniOperatorFactory(nova.hetu.olk.operator.OrderByOmniOperator.OrderByOmniOperatorFactory.createOrderByOmniOperatorFactory) HashBuilderOmniOperatorFactory(nova.hetu.olk.operator.HashBuilderOmniOperator.HashBuilderOmniOperatorFactory) DriverFactory(io.prestosql.operator.DriverFactory) Session(io.prestosql.Session)

Aggregations

OperatorFactory (io.prestosql.operator.OperatorFactory)36 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)28 Type (io.prestosql.spi.type.Type)14 DriverContext (io.prestosql.operator.DriverContext)12 MaterializedResult (io.prestosql.testing.MaterializedResult)12 Test (org.testng.annotations.Test)11 DriverFactory (io.prestosql.operator.DriverFactory)9 SpatialIndexBuilderOperatorFactory (io.prestosql.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)9 SpatialJoinOperatorFactory (io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory)9 Page (io.prestosql.spi.Page)9 PagesSpatialIndexFactory (io.prestosql.operator.PagesSpatialIndexFactory)7 ImmutableList (com.google.common.collect.ImmutableList)6 Metadata (io.prestosql.metadata.Metadata)6 SourceOperatorFactory (io.prestosql.operator.SourceOperatorFactory)6 TaskContext (io.prestosql.operator.TaskContext)6 ArrayList (java.util.ArrayList)6 RowPagesBuilder (io.prestosql.RowPagesBuilder)5 AggregationOperatorFactory (io.prestosql.operator.AggregationOperator.AggregationOperatorFactory)5 HashBuilderOperatorFactory (io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory)5 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)5