Search in sources :

Example 1 with NestedLoopBuildOperatorFactory

use of io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory in project trino by trinodb.

the class TestNestedLoopBuildOperator method testNestedLoopBuild.

@Test
public void testNestedLoopBuild() throws Exception {
    TaskContext taskContext = createTaskContext();
    List<Type> buildTypes = ImmutableList.of(BIGINT);
    JoinBridgeManager<NestedLoopJoinBridge> nestedLoopJoinBridgeManager = new JoinBridgeManager<>(false, PipelineExecutionStrategy.UNGROUPED_EXECUTION, PipelineExecutionStrategy.UNGROUPED_EXECUTION, lifespan -> new NestedLoopJoinPagesSupplier(), buildTypes);
    NestedLoopBuildOperatorFactory nestedLoopBuildOperatorFactory = new NestedLoopBuildOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinBridgeManager);
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    NestedLoopBuildOperator nestedLoopBuildOperator = (NestedLoopBuildOperator) nestedLoopBuildOperatorFactory.createOperator(driverContext);
    NestedLoopJoinBridge nestedLoopJoinBridge = nestedLoopJoinBridgeManager.getJoinBridge(Lifespan.taskWide());
    assertFalse(nestedLoopJoinBridge.getPagesFuture().isDone());
    // build pages
    Page buildPage1 = new Page(3, createLongSequenceBlock(11, 14));
    Page buildPageEmpty = new Page(0);
    Page buildPage2 = new Page(3000, createLongSequenceBlock(4000, 7000));
    nestedLoopBuildOperator.addInput(buildPage1);
    nestedLoopBuildOperator.addInput(buildPageEmpty);
    nestedLoopBuildOperator.addInput(buildPage2);
    nestedLoopBuildOperator.finish();
    assertTrue(nestedLoopJoinBridge.getPagesFuture().isDone());
    List<Page> buildPages = nestedLoopJoinBridge.getPagesFuture().get().getPages();
    assertEquals(buildPages.get(0), buildPage1);
    assertEquals(buildPages.get(1), buildPage2);
    assertEquals(buildPages.size(), 2);
}
Also used : DriverContext(io.trino.operator.DriverContext) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) NestedLoopBuildOperatorFactory(io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory) Test(org.testng.annotations.Test)

Example 2 with NestedLoopBuildOperatorFactory

use of io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory in project trino by trinodb.

the class TestNestedLoopBuildOperator method testNestedLoopNoBlocksMaxSizeLimit.

@Test
public void testNestedLoopNoBlocksMaxSizeLimit() throws Exception {
    TaskContext taskContext = createTaskContext();
    List<Type> buildTypes = ImmutableList.of();
    JoinBridgeManager<NestedLoopJoinBridge> nestedLoopJoinBridgeManager = new JoinBridgeManager<>(false, PipelineExecutionStrategy.UNGROUPED_EXECUTION, PipelineExecutionStrategy.UNGROUPED_EXECUTION, lifespan -> new NestedLoopJoinPagesSupplier(), buildTypes);
    NestedLoopBuildOperatorFactory nestedLoopBuildOperatorFactory = new NestedLoopBuildOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinBridgeManager);
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    NestedLoopBuildOperator nestedLoopBuildOperator = (NestedLoopBuildOperator) nestedLoopBuildOperatorFactory.createOperator(driverContext);
    NestedLoopJoinBridge nestedLoopJoinBridge = nestedLoopJoinBridgeManager.getJoinBridge(Lifespan.taskWide());
    assertFalse(nestedLoopJoinBridge.getPagesFuture().isDone());
    // build pages
    Page massivePage = new Page(PageProcessor.MAX_BATCH_SIZE + 100);
    nestedLoopBuildOperator.addInput(massivePage);
    nestedLoopBuildOperator.finish();
    assertTrue(nestedLoopJoinBridge.getPagesFuture().isDone());
    List<Page> buildPages = nestedLoopJoinBridge.getPagesFuture().get().getPages();
    assertEquals(buildPages.size(), 2);
    assertEquals(buildPages.get(0).getPositionCount(), PageProcessor.MAX_BATCH_SIZE);
    assertEquals(buildPages.get(1).getPositionCount(), 100);
}
Also used : DriverContext(io.trino.operator.DriverContext) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) NestedLoopBuildOperatorFactory(io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory) Test(org.testng.annotations.Test)

Example 3 with NestedLoopBuildOperatorFactory

use of io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory in project trino by trinodb.

the class TestNestedLoopJoinOperator method newJoinOperatorFactoryWithCompletedBuild.

private static NestedLoopJoinOperatorFactory newJoinOperatorFactoryWithCompletedBuild(TaskContext taskContext, RowPagesBuilder buildPages, List<Integer> probeChannels, List<Integer> buildChannels) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    ValuesOperatorFactory valuesOperatorFactory = new ValuesOperatorFactory(0, new PlanNodeId("test"), buildPages.build());
    JoinBridgeManager<NestedLoopJoinBridge> nestedLoopJoinBridgeManager = new JoinBridgeManager<>(false, PipelineExecutionStrategy.UNGROUPED_EXECUTION, PipelineExecutionStrategy.UNGROUPED_EXECUTION, lifespan -> new NestedLoopJoinPagesSupplier(), buildPages.getTypes());
    NestedLoopBuildOperatorFactory nestedLoopBuildOperatorFactory = new NestedLoopBuildOperatorFactory(1, new PlanNodeId("test"), nestedLoopJoinBridgeManager);
    NestedLoopJoinOperatorFactory joinOperatorFactory = new NestedLoopJoinOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinBridgeManager, probeChannels, buildChannels);
    Operator valuesOperator = valuesOperatorFactory.createOperator(driverContext);
    Operator nestedLoopBuildOperator = nestedLoopBuildOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, valuesOperator, nestedLoopBuildOperator);
    valuesOperatorFactory.noMoreOperators();
    nestedLoopBuildOperatorFactory.noMoreOperators();
    while (nestedLoopBuildOperator.isBlocked().isDone()) {
        driver.process();
    }
    return joinOperatorFactory;
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Operator(io.trino.operator.Operator) DriverContext(io.trino.operator.DriverContext) NestedLoopBuildOperatorFactory(io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory) ValuesOperatorFactory(io.trino.operator.ValuesOperator.ValuesOperatorFactory) Driver(io.trino.operator.Driver) NestedLoopJoinOperatorFactory(io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)

Example 4 with NestedLoopBuildOperatorFactory

use of io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory in project trino by trinodb.

the class TestNestedLoopBuildOperator method testNestedLoopBuildNoBlock.

@Test
public void testNestedLoopBuildNoBlock() throws Exception {
    TaskContext taskContext = createTaskContext();
    List<Type> buildTypes = ImmutableList.of();
    JoinBridgeManager<NestedLoopJoinBridge> nestedLoopJoinBridgeManager = new JoinBridgeManager<>(false, PipelineExecutionStrategy.UNGROUPED_EXECUTION, PipelineExecutionStrategy.UNGROUPED_EXECUTION, lifespan -> new NestedLoopJoinPagesSupplier(), buildTypes);
    NestedLoopBuildOperatorFactory nestedLoopBuildOperatorFactory = new NestedLoopBuildOperatorFactory(3, new PlanNodeId("test"), nestedLoopJoinBridgeManager);
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    NestedLoopBuildOperator nestedLoopBuildOperator = (NestedLoopBuildOperator) nestedLoopBuildOperatorFactory.createOperator(driverContext);
    NestedLoopJoinBridge nestedLoopJoinBridge = nestedLoopJoinBridgeManager.getJoinBridge(Lifespan.taskWide());
    assertFalse(nestedLoopJoinBridge.getPagesFuture().isDone());
    // build pages
    Page buildPage1 = new Page(3);
    Page buildPageEmpty = new Page(0);
    Page buildPage2 = new Page(3000);
    nestedLoopBuildOperator.addInput(buildPage1);
    nestedLoopBuildOperator.addInput(buildPageEmpty);
    nestedLoopBuildOperator.addInput(buildPage2);
    nestedLoopBuildOperator.finish();
    assertTrue(nestedLoopJoinBridge.getPagesFuture().isDone());
    List<Page> buildPages = nestedLoopJoinBridge.getPagesFuture().get().getPages();
    assertEquals(buildPages.size(), 1);
    assertEquals(buildPages.get(0).getPositionCount(), 3003);
}
Also used : DriverContext(io.trino.operator.DriverContext) TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) NestedLoopBuildOperatorFactory(io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

DriverContext (io.trino.operator.DriverContext)4 NestedLoopBuildOperatorFactory (io.trino.operator.join.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory)4 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)4 TaskContext (io.trino.operator.TaskContext)3 Page (io.trino.spi.Page)3 Type (io.trino.spi.type.Type)3 TestingTaskContext (io.trino.testing.TestingTaskContext)3 Test (org.testng.annotations.Test)3 Driver (io.trino.operator.Driver)1 Operator (io.trino.operator.Operator)1 ValuesOperatorFactory (io.trino.operator.ValuesOperator.ValuesOperatorFactory)1 NestedLoopJoinOperatorFactory (io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)1