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);
}
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);
}
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;
}
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);
}
Aggregations