Search in sources :

Example 1 with LookupSourceProvider

use of com.facebook.presto.operator.LookupSourceProvider 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)

Aggregations

Type (com.facebook.presto.common.type.Type)1 Driver (com.facebook.presto.operator.Driver)1 DriverContext (com.facebook.presto.operator.DriverContext)1 DriverFactory (com.facebook.presto.operator.DriverFactory)1 HashBuilderOperatorFactory (com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory)1 LookupSourceProvider (com.facebook.presto.operator.LookupSourceProvider)1 OperatorFactory (com.facebook.presto.operator.OperatorFactory)1 PagesIndex (com.facebook.presto.operator.PagesIndex)1 PartitionedLookupSourceFactory (com.facebook.presto.operator.PartitionedLookupSourceFactory)1 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)1 NullOutputOperatorFactory (com.facebook.presto.testing.NullOutputOperator.NullOutputOperatorFactory)1