Search in sources :

Example 36 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

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");
    BlockTypeOperators blockTypeOperators = new BlockTypeOperators(new TypeOperators());
    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, false, blockTypeOperators));
    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(), incrementalLoadFactorHashArraySizeSupplier(session));
    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 = operatorFactories.innerJoin(2, new PlanNodeId("test"), lookupSourceFactoryManager, false, false, false, ImmutableList.of(BIGINT), Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory(), blockTypeOperators);
    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.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory) Driver(io.trino.operator.Driver) PagesIndex(io.trino.operator.PagesIndex) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) BlockTypeOperators(io.trino.type.BlockTypeOperators) ValuesOperatorFactory(io.trino.operator.ValuesOperator.ValuesOperatorFactory) HashBuilderOperatorFactory(io.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory) NullOutputOperatorFactory(io.trino.testing.NullOutputOperator.NullOutputOperatorFactory) OperatorFactory(io.trino.operator.OperatorFactory) DriverFactory(io.trino.operator.DriverFactory) ValuesOperatorFactory(io.trino.operator.ValuesOperator.ValuesOperatorFactory) PartitionedLookupSourceFactory(io.trino.operator.join.PartitionedLookupSourceFactory) NullOutputOperatorFactory(io.trino.testing.NullOutputOperator.NullOutputOperatorFactory) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators)

Example 37 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

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");
        BlockTypeOperators blockTypeOperators = new BlockTypeOperators(new TypeOperators());
        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, false, blockTypeOperators));
        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(), incrementalLoadFactorHashArraySizeSupplier(session));
        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 = operatorFactories.innerJoin(1, new PlanNodeId("test"), lookupSourceFactoryManager, false, false, false, lineItemTypes, Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory(), blockTypeOperators);
        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.trino.operator.DriverContext) HashBuilderOperatorFactory(io.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory) Driver(io.trino.operator.Driver) PagesIndex(io.trino.operator.PagesIndex) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) BlockTypeOperators(io.trino.type.BlockTypeOperators) HashBuilderOperatorFactory(io.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory) NullOutputOperatorFactory(io.trino.testing.NullOutputOperator.NullOutputOperatorFactory) OperatorFactory(io.trino.operator.OperatorFactory) DriverFactory(io.trino.operator.DriverFactory) PartitionedLookupSourceFactory(io.trino.operator.join.PartitionedLookupSourceFactory) NullOutputOperatorFactory(io.trino.testing.NullOutputOperator.NullOutputOperatorFactory) LookupSourceProvider(io.trino.operator.join.LookupSourceProvider) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators)

Aggregations

TypeOperators (io.trino.spi.type.TypeOperators)37 BlockTypeOperators (io.trino.type.BlockTypeOperators)23 Test (org.testng.annotations.Test)18 MapType (io.trino.spi.type.MapType)10 Type (io.trino.spi.type.Type)9 BeforeMethod (org.testng.annotations.BeforeMethod)9 Page (io.trino.spi.Page)8 JoinCompiler (io.trino.sql.gen.JoinCompiler)6 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)6 ImmutableList (com.google.common.collect.ImmutableList)4 FeaturesConfig (io.trino.FeaturesConfig)4 Driver (io.trino.operator.Driver)3 DriverFactory (io.trino.operator.DriverFactory)3 GroupByHashPageIndexerFactory (io.trino.operator.GroupByHashPageIndexerFactory)3 OperatorFactory (io.trino.operator.OperatorFactory)3 PagesIndex (io.trino.operator.PagesIndex)3 HashBuilderOperatorFactory (io.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory)3 PartitionedLookupSourceFactory (io.trino.operator.join.PartitionedLookupSourceFactory)3 Block (io.trino.spi.block.Block)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2