Search in sources :

Example 1 with OperatorFactory

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

the class TestLocalExchangeSourceOperator method createOperator.

private LocalExchangeSourceOperator createOperator(LocalExchange.LocalExchangeFactory localExchangeFactory, int totalInputChannels, Session session, int driverId) {
    if (pipelineContext == null) {
        ScheduledExecutorService scheduler = newScheduledThreadPool(4, daemonThreadsNamed("test-%s"));
        ScheduledExecutorService scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s"));
        OperatorFactory operatorFactory = new LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory(0, new PlanNodeId("test"), localExchangeFactory, totalInputChannels);
        pipelineContext = createTaskContext(scheduler, scheduledExecutor, session).addPipelineContext(0, true, true, false);
    }
    DriverContext driverContext = pipelineContext.addDriverContext(Lifespan.taskWide(), driverId);
    OperatorFactory operatorFactory = new LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory(0, new PlanNodeId("test"), localExchangeFactory, totalInputChannels);
    Operator operator = operatorFactory.createOperator(driverContext);
    assertEquals(operator.getOperatorContext().getOperatorStats().getSystemMemoryReservation().toBytes(), 0);
    return (LocalExchangeSourceOperator) operator;
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Operator(io.prestosql.operator.Operator) DriverContext(io.prestosql.operator.DriverContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OperatorFactory(io.prestosql.operator.OperatorFactory)

Example 2 with OperatorFactory

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

the class HandTpchQuery1 method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    // select
    // returnflag,
    // linestatus,
    // sum(quantity) as sum_qty,
    // sum(extendedprice) as sum_base_price,
    // sum(extendedprice * (1 - discount)) as sum_disc_price,
    // sum(extendedprice * (1 - discount) * (1 + tax)) as sum_charge,
    // avg(quantity) as avg_qty,
    // avg(extendedprice) as avg_price,
    // avg(discount) as avg_disc,
    // count(*) as count_order
    // from
    // lineitem
    // where
    // shipdate <= '1998-09-02'
    // group by
    // returnflag,
    // linestatus
    // order by
    // returnflag,
    // linestatus
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "returnflag", "linestatus", "quantity", "extendedprice", "discount", "tax", "shipdate");
    TpchQuery1OperatorFactory tpchQuery1Operator = new TpchQuery1OperatorFactory(1);
    HashAggregationOperatorFactory aggregationOperator = new HashAggregationOperatorFactory(2, new PlanNodeId("test"), getColumnTypes("lineitem", "returnflag", "linestatus"), Ints.asList(0, 1), ImmutableList.of(), Step.SINGLE, ImmutableList.of(doubleSum.bind(ImmutableList.of(2), Optional.empty()), doubleSum.bind(ImmutableList.of(3), Optional.empty()), doubleSum.bind(ImmutableList.of(4), Optional.empty()), longAverage.bind(ImmutableList.of(2), Optional.empty()), doubleAverage.bind(ImmutableList.of(5), Optional.empty()), doubleAverage.bind(ImmutableList.of(6), Optional.empty()), countFunction.bind(ImmutableList.of(2), Optional.empty())), Optional.empty(), Optional.empty(), 10_000, Optional.of(new DataSize(16, MEGABYTE)), JOIN_COMPILER, false);
    return ImmutableList.of(tableScanOperator, tpchQuery1Operator, aggregationOperator);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) OperatorFactory(io.prestosql.operator.OperatorFactory) HashAggregationOperatorFactory(io.prestosql.operator.HashAggregationOperator.HashAggregationOperatorFactory) TpchQuery1OperatorFactory(io.prestosql.benchmark.HandTpchQuery1.TpchQuery1Operator.TpchQuery1OperatorFactory) TpchQuery1OperatorFactory(io.prestosql.benchmark.HandTpchQuery1.TpchQuery1Operator.TpchQuery1OperatorFactory) DataSize(io.airlift.units.DataSize) HashAggregationOperatorFactory(io.prestosql.operator.HashAggregationOperator.HashAggregationOperatorFactory)

Example 3 with OperatorFactory

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

the class HandTpchQuery6 method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    // select sum(extendedprice * discount) as revenue
    // from lineitem
    // where shipdate >= '1994-01-01'
    // and shipdate < '1995-01-01'
    // and discount >= 0.05
    // and discount <= 0.07
    // and quantity < 24;
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "extendedprice", "discount", "shipdate", "quantity");
    Supplier<PageProjection> projection = new PageFunctionCompiler(localQueryRunner.getMetadata(), 0).compileProjection(field(0, BIGINT), Optional.empty());
    FilterAndProjectOperator.FilterAndProjectOperatorFactory tpchQuery6Operator = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(1, new PlanNodeId("test"), () -> new PageProcessor(Optional.of(new TpchQuery6Filter()), ImmutableList.of(projection.get())), ImmutableList.of(DOUBLE), new DataSize(0, BYTE), 0);
    AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(2, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(doubleSum.bind(ImmutableList.of(0), Optional.empty())), false);
    return ImmutableList.of(tableScanOperator, tpchQuery6Operator, aggregationOperator);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PageProjection(io.prestosql.operator.project.PageProjection) PageFunctionCompiler(io.prestosql.sql.gen.PageFunctionCompiler) PageProcessor(io.prestosql.operator.project.PageProcessor) OperatorFactory(io.prestosql.operator.OperatorFactory) AggregationOperatorFactory(io.prestosql.operator.AggregationOperator.AggregationOperatorFactory) AggregationOperatorFactory(io.prestosql.operator.AggregationOperator.AggregationOperatorFactory) DataSize(io.airlift.units.DataSize) FilterAndProjectOperator(io.prestosql.operator.FilterAndProjectOperator)

Example 4 with OperatorFactory

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

the class HashBuildBenchmark method createDrivers.

@Override
protected List<Driver> createDrivers(TaskContext taskContext) {
    // hash build
    List<Type> ordersTypes = getColumnTypes("orders", "orderkey", "totalprice");
    OperatorFactory ordersTableScan = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey", "totalprice");
    JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = JoinBridgeManager.lookupAllAtOnce(new PartitionedLookupSourceFactory(ordersTypes, ImmutableList.of(0, 1).stream().map(ordersTypes::get).collect(toImmutableList()), Ints.asList(0).stream().map(ordersTypes::get).collect(toImmutableList()), 1, requireNonNull(ImmutableMap.of(), "layout is null"), false, false));
    HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory(1, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(0, 1), Ints.asList(0), OptionalInt.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), 1_500_000, new PagesIndex.TestingFactory(false), false, SingleStreamSpillerFactory.unsupportedSingleStreamSpillerFactory());
    DriverFactory hashBuildDriverFactory = new DriverFactory(0, true, true, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION);
    // empty join so build finishes
    ImmutableList.Builder<OperatorFactory> joinDriversBuilder = ImmutableList.builder();
    joinDriversBuilder.add(new ValuesOperatorFactory(0, new PlanNodeId("values"), ImmutableList.of()));
    OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(2, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(BIGINT), Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory());
    joinDriversBuilder.add(joinOperator);
    joinDriversBuilder.add(new NullOutputOperatorFactory(3, new PlanNodeId("test")));
    DriverFactory joinDriverFactory = new DriverFactory(1, true, true, joinDriversBuilder.build(), OptionalInt.empty(), UNGROUPED_EXECUTION);
    Driver hashBuildDriver = hashBuildDriverFactory.createDriver(taskContext.addPipelineContext(0, true, true, false).addDriverContext());
    hashBuildDriverFactory.noMoreDrivers();
    Driver joinDriver = joinDriverFactory.createDriver(taskContext.addPipelineContext(1, true, true, false).addDriverContext());
    joinDriverFactory.noMoreDrivers();
    return ImmutableList.of(hashBuildDriver, joinDriver);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) Driver(io.prestosql.operator.Driver) PagesIndex(io.prestosql.operator.PagesIndex) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) OperatorFactory(io.prestosql.operator.OperatorFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) DriverFactory(io.prestosql.operator.DriverFactory) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) PartitionedLookupSourceFactory(io.prestosql.operator.PartitionedLookupSourceFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory)

Example 5 with OperatorFactory

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

the class HashJoinBenchmark method createDrivers.

/*
    select orderkey, quantity, totalprice
    from lineitem join orders using (orderkey)
     */
@Override
protected List<Driver> createDrivers(TaskContext taskContext) {
    if (probeDriverFactory == null) {
        List<Type> ordersTypes = getColumnTypes("orders", "orderkey", "totalprice");
        OperatorFactory ordersTableScan = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey", "totalprice");
        JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = JoinBridgeManager.lookupAllAtOnce(new PartitionedLookupSourceFactory(ordersTypes, ImmutableList.of(0, 1).stream().map(ordersTypes::get).collect(toImmutableList()), Ints.asList(0).stream().map(ordersTypes::get).collect(toImmutableList()), 1, requireNonNull(ImmutableMap.of(), "layout is null"), false, false));
        HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory(1, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(0, 1), Ints.asList(0), OptionalInt.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), 1_500_000, new PagesIndex.TestingFactory(false), false, SingleStreamSpillerFactory.unsupportedSingleStreamSpillerFactory());
        DriverContext driverContext = taskContext.addPipelineContext(0, false, false, false).addDriverContext();
        DriverFactory buildDriverFactory = new DriverFactory(0, false, false, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION);
        List<Type> lineItemTypes = getColumnTypes("lineitem", "orderkey", "quantity");
        OperatorFactory lineItemTableScan = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "orderkey", "quantity");
        OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(1, new PlanNodeId("test"), lookupSourceFactoryManager, lineItemTypes, Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory());
        NullOutputOperatorFactory output = new NullOutputOperatorFactory(2, new PlanNodeId("test"));
        this.probeDriverFactory = new DriverFactory(1, true, true, ImmutableList.of(lineItemTableScan, joinOperator, output), OptionalInt.empty(), UNGROUPED_EXECUTION);
        Driver driver = buildDriverFactory.createDriver(driverContext);
        Future<LookupSourceProvider> lookupSourceProvider = lookupSourceFactoryManager.getJoinBridge(Lifespan.taskWide()).createLookupSourceProvider();
        while (!lookupSourceProvider.isDone()) {
            driver.process();
        }
        getFutureValue(lookupSourceProvider).close();
    }
    DriverContext driverContext = taskContext.addPipelineContext(1, true, true, false).addDriverContext();
    Driver driver = probeDriverFactory.createDriver(driverContext);
    return ImmutableList.of(driver);
}
Also used : DriverContext(io.prestosql.operator.DriverContext) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) Driver(io.prestosql.operator.Driver) PagesIndex(io.prestosql.operator.PagesIndex) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) OperatorFactory(io.prestosql.operator.OperatorFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory) DriverFactory(io.prestosql.operator.DriverFactory) PartitionedLookupSourceFactory(io.prestosql.operator.PartitionedLookupSourceFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory) LookupSourceProvider(io.prestosql.operator.LookupSourceProvider)

Aggregations

OperatorFactory (io.prestosql.operator.OperatorFactory)31 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)25 Type (io.prestosql.spi.type.Type)12 MaterializedResult (io.prestosql.testing.MaterializedResult)12 DriverContext (io.prestosql.operator.DriverContext)10 Test (org.testng.annotations.Test)10 SpatialIndexBuilderOperatorFactory (io.prestosql.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)9 SpatialJoinOperatorFactory (io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory)9 DriverFactory (io.prestosql.operator.DriverFactory)7 PagesSpatialIndexFactory (io.prestosql.operator.PagesSpatialIndexFactory)7 Page (io.prestosql.spi.Page)7 ImmutableList (com.google.common.collect.ImmutableList)6 Metadata (io.prestosql.metadata.Metadata)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 TaskContext (io.prestosql.operator.TaskContext)5 TestingTaskContext (io.prestosql.testing.TestingTaskContext)5 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4