Search in sources :

Example 21 with OperatorFactory

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

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));
        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(), false);
        DriverContext driverContext = taskContext.addPipelineContext(0, false, false, false).addDriverContext();
        DriverFactory buildDriverFactory = new DriverFactory(0, false, false, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION, Optional.empty());
        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, Optional.empty());
        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(com.facebook.presto.operator.DriverContext) HashBuilderOperatorFactory(com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory) Driver(com.facebook.presto.operator.Driver) PagesIndex(com.facebook.presto.operator.PagesIndex) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) Type(com.facebook.presto.common.type.Type) OperatorFactory(com.facebook.presto.operator.OperatorFactory) HashBuilderOperatorFactory(com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory) NullOutputOperatorFactory(com.facebook.presto.testing.NullOutputOperator.NullOutputOperatorFactory) DriverFactory(com.facebook.presto.operator.DriverFactory) PartitionedLookupSourceFactory(com.facebook.presto.operator.PartitionedLookupSourceFactory) NullOutputOperatorFactory(com.facebook.presto.testing.NullOutputOperator.NullOutputOperatorFactory) LookupSourceProvider(com.facebook.presto.operator.LookupSourceProvider)

Example 22 with OperatorFactory

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

the class AbstractSimpleOperatorBenchmark method createDriverFactory.

protected DriverFactory createDriverFactory() {
    List<OperatorFactory> operatorFactories = new ArrayList<>(createOperatorFactories());
    operatorFactories.add(new NullOutputOperatorFactory(999, new PlanNodeId("test")));
    return new DriverFactory(0, true, true, operatorFactories, OptionalInt.empty(), UNGROUPED_EXECUTION, Optional.empty());
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) OperatorFactory(com.facebook.presto.operator.OperatorFactory) NullOutputOperatorFactory(com.facebook.presto.testing.NullOutputOperator.NullOutputOperatorFactory) ArrayList(java.util.ArrayList) DriverFactory(com.facebook.presto.operator.DriverFactory) NullOutputOperatorFactory(com.facebook.presto.testing.NullOutputOperator.NullOutputOperatorFactory)

Example 23 with OperatorFactory

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

the class DoubleSumAggregationBenchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
    FunctionAndTypeManager functionAndTypeManager = MetadataManager.createTestMetadataManager().getFunctionAndTypeManager();
    InternalAggregationFunction doubleSum = functionAndTypeManager.getAggregateFunctionImplementation(functionAndTypeManager.lookupFunction("sum", fromTypes(DOUBLE)));
    AggregationOperatorFactory aggregationOperator = new AggregationOperatorFactory(1, new PlanNodeId("test"), Step.SINGLE, ImmutableList.of(doubleSum.bind(ImmutableList.of(0), Optional.empty())), false);
    return ImmutableList.of(tableScanOperator, aggregationOperator);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) OperatorFactory(com.facebook.presto.operator.OperatorFactory) AggregationOperatorFactory(com.facebook.presto.operator.AggregationOperator.AggregationOperatorFactory) AggregationOperatorFactory(com.facebook.presto.operator.AggregationOperator.AggregationOperatorFactory) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction)

Example 24 with OperatorFactory

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

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(com.facebook.presto.spi.plan.PlanNodeId) OperatorFactory(com.facebook.presto.operator.OperatorFactory) TpchQuery1OperatorFactory(com.facebook.presto.benchmark.HandTpchQuery1.TpchQuery1Operator.TpchQuery1OperatorFactory) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory) TpchQuery1OperatorFactory(com.facebook.presto.benchmark.HandTpchQuery1.TpchQuery1Operator.TpchQuery1OperatorFactory) DataSize(io.airlift.units.DataSize) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)

Example 25 with OperatorFactory

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

the class HashAggregationBenchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    List<Type> tableTypes = getColumnTypes("orders", "orderstatus", "totalprice");
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderstatus", "totalprice");
    HashAggregationOperatorFactory aggregationOperator = new HashAggregationOperatorFactory(1, new PlanNodeId("test"), ImmutableList.of(tableTypes.get(0)), Ints.asList(0), ImmutableList.of(), Step.SINGLE, ImmutableList.of(doubleSum.bind(ImmutableList.of(1), Optional.empty())), Optional.empty(), Optional.empty(), 100_000, Optional.of(new DataSize(16, MEGABYTE)), JOIN_COMPILER, false);
    return ImmutableList.of(tableScanOperator, aggregationOperator);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) Type(com.facebook.presto.common.type.Type) OperatorFactory(com.facebook.presto.operator.OperatorFactory) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory) DataSize(io.airlift.units.DataSize) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)

Aggregations

OperatorFactory (com.facebook.presto.operator.OperatorFactory)32 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)23 Type (com.facebook.presto.common.type.Type)13 MaterializedResult (com.facebook.presto.testing.MaterializedResult)11 Page (com.facebook.presto.common.Page)8 DriverContext (com.facebook.presto.operator.DriverContext)8 DriverFactory (com.facebook.presto.operator.DriverFactory)7 ImmutableList (com.google.common.collect.ImmutableList)7 Test (org.testng.annotations.Test)7 BlockAssertions.createMapType (com.facebook.presto.block.BlockAssertions.createMapType)6 ArrayType (com.facebook.presto.common.type.ArrayType)6 DecimalType.createDecimalType (com.facebook.presto.common.type.DecimalType.createDecimalType)6 RowType (com.facebook.presto.common.type.RowType)6 AggregationOperatorFactory (com.facebook.presto.operator.AggregationOperator.AggregationOperatorFactory)6 SourceOperatorFactory (com.facebook.presto.operator.SourceOperatorFactory)6 SpatialIndexBuilderOperatorFactory (com.facebook.presto.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)6 SpatialJoinOperatorFactory (com.facebook.presto.operator.SpatialJoinOperator.SpatialJoinOperatorFactory)6 MetadataManager (com.facebook.presto.metadata.MetadataManager)5 MetadataManager.createTestMetadataManager (com.facebook.presto.metadata.MetadataManager.createTestMetadataManager)5 HashBuilderOperatorFactory (com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory)5