Search in sources :

Example 16 with DriverContext

use of io.prestosql.operator.DriverContext in project hetu-core by openlookeng.

the class TestSpatialJoinOperator method testDuplicateProbeFactory.

@Test(dataProvider = "testDuplicateProbeFactoryDataProvider")
public void testDuplicateProbeFactory(boolean createSecondaryOperators) throws Exception {
    TaskContext taskContext = createTaskContext();
    PipelineContext pipelineContext = taskContext.addPipelineContext(0, true, true, false);
    DriverContext probeDriver = pipelineContext.addDriverContext();
    DriverContext buildDriver = pipelineContext.addDriverContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR, DOUBLE)).row(stPoint(0, 0), "0_0", 1.5);
    PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(buildDriver, (build, probe, r) -> build.distance(probe) <= r.getAsDouble(), Optional.of(2), Optional.empty(), buildPages);
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(stPoint(0, 1), "0_1");
    OperatorFactory firstFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), INNER, probePages.getTypes(), Ints.asList(1), 0, Optional.empty(), pagesSpatialIndexFactory);
    for (int i = 0; i < 3; i++) {
        DriverContext secondDriver = pipelineContext.addDriverContext();
        OperatorFactory secondFactory = firstFactory.duplicate();
        if (createSecondaryOperators) {
            try (Operator secondOperator = secondFactory.createOperator(secondDriver)) {
                assertEquals(toPages(secondOperator, emptyIterator()), ImmutableList.of());
            }
        }
        secondFactory.noMoreOperators();
    }
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).row("0_1", "0_0").build();
    assertOperatorEquals(firstFactory, probeDriver, probePages.build(), expected);
}
Also used : SpatialJoinOperatorFactory(io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) ValuesOperator(io.prestosql.operator.ValuesOperator) Operator(io.prestosql.operator.Operator) DriverContext(io.prestosql.operator.DriverContext) TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) PipelineContext(io.prestosql.operator.PipelineContext) SpatialJoinOperatorFactory(io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory) OperatorFactory(io.prestosql.operator.OperatorFactory) SpatialIndexBuilderOperatorFactory(io.prestosql.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory) PagesSpatialIndexFactory(io.prestosql.operator.PagesSpatialIndexFactory) MaterializedResult(io.prestosql.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) GeoFunctions.stPoint(io.prestosql.plugin.geospatial.GeoFunctions.stPoint) Test(org.testng.annotations.Test)

Example 17 with DriverContext

use of io.prestosql.operator.DriverContext in project hetu-core by openlookeng.

the class TestOrcPageSourceMemoryTracking method testScanFilterAndProjectOperator.

@Test
public void testScanFilterAndProjectOperator() {
    // Numbers used in assertions in this test may change when implementation is modified,
    // feel free to change them if they break in the future
    DriverContext driverContext = testPreparer.newDriverContext();
    SourceOperator operator = testPreparer.newScanFilterAndProjectOperator(driverContext);
    assertEquals(driverContext.getSystemMemoryUsage(), 0);
    int totalRows = 0;
    while (totalRows < NUM_ROWS) {
        assertFalse(operator.isFinished());
        Page page = operator.getOutput();
        assertNotNull(page);
        assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 90_000L, 499_999L);
        totalRows += page.getPositionCount();
    }
    // done... in the current implementation finish is not set until output returns a null page
    assertNull(operator.getOutput());
    assertTrue(operator.isFinished());
    assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 0L, 500L);
}
Also used : DriverContext(io.prestosql.operator.DriverContext) SourceOperator(io.prestosql.operator.SourceOperator) Page(io.prestosql.spi.Page) Test(org.testng.annotations.Test)

Example 18 with DriverContext

use of io.prestosql.operator.DriverContext in project hetu-core by openlookeng.

the class TestMultiInputSnapshotState method testStaticConstructor.

@Test
public void testStaticConstructor() {
    ScheduledExecutorService scheduler = newScheduledThreadPool(4);
    TaskContext taskContext = createTaskContext(scheduler, scheduler, TEST_SNAPSHOT_SESSION);
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    OperatorContext operatorContext = driverContext.addOperatorContext(1, new PlanNodeId("planNodeId"), "test");
    MultiInputSnapshotState inputSnapshotState = MultiInputSnapshotState.forOperator(mock(MultiInputRestorable.class), operatorContext);
    processPage(inputSnapshotState, source1, regularPage);
    inputSnapshotState = MultiInputSnapshotState.forTaskComponent(mock(MultiInputRestorable.class), taskContext, TestMultiInputSnapshotState::createSnapshotStateId);
    processPage(inputSnapshotState, source1, regularPage);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) DriverContext(io.prestosql.operator.DriverContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext.createTaskContext(io.prestosql.testing.TestingTaskContext.createTaskContext) OperatorContext(io.prestosql.operator.OperatorContext) Test(org.testng.annotations.Test)

Example 19 with DriverContext

use of io.prestosql.operator.DriverContext in project hetu-core by openlookeng.

the class TestCrossRegionDynamicFilterOperator method createBloomFilterOperator.

private CrossRegionDynamicFilterOperator createBloomFilterOperator(String queryId, DynamicFilterCacheManager dynamicFilterCacheManager) {
    int filterOperatorId = operatorId.getAndIncrement();
    CrossRegionDynamicFilterOperator.CrossRegionDynamicFilterOperatorFactory factory = new CrossRegionDynamicFilterOperator.CrossRegionDynamicFilterOperatorFactory(filterOperatorId, planNodeId, queryId, createSymbolList(), createTypeProvider(), dynamicFilterCacheManager, createColumns(), createSymbolList());
    DriverContext driverContext = createTaskContext(executor, executor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
    return (CrossRegionDynamicFilterOperator) factory.createOperator(driverContext);
}
Also used : DriverContext(io.prestosql.operator.DriverContext)

Example 20 with DriverContext

use of io.prestosql.operator.DriverContext in project hetu-core by openlookeng.

the class SnapshotStateId method forOperator.

public static SnapshotStateId forOperator(long snapshotId, OperatorContext operatorContext) {
    DriverContext driverContext = operatorContext.getDriverContext();
    TaskId taskIdGen = driverContext.getTaskId();
    int pipelineId = driverContext.getPipelineContext().getPipelineId();
    int driverId = driverContext.getDriverId();
    return new SnapshotStateId(snapshotId, taskIdGen, pipelineId, driverId, operatorContext.getOperatorId());
}
Also used : DriverContext(io.prestosql.operator.DriverContext) TaskId(io.prestosql.execution.TaskId)

Aggregations

DriverContext (io.prestosql.operator.DriverContext)27 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)17 Test (org.testng.annotations.Test)14 OperatorFactory (io.prestosql.operator.OperatorFactory)10 TaskContext (io.prestosql.operator.TaskContext)10 OperatorContext (io.prestosql.operator.OperatorContext)7 PagesSpatialIndexFactory (io.prestosql.operator.PagesSpatialIndexFactory)7 SpatialIndexBuilderOperatorFactory (io.prestosql.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)7 SpatialJoinOperatorFactory (io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory)7 Driver (io.prestosql.operator.Driver)6 RowPagesBuilder (io.prestosql.RowPagesBuilder)5 Operator (io.prestosql.operator.Operator)5 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)5 Page (io.prestosql.spi.Page)5 MaterializedResult (io.prestosql.testing.MaterializedResult)5 TestingTaskContext (io.prestosql.testing.TestingTaskContext)5 DriverFactory (io.prestosql.operator.DriverFactory)4 PipelineContext (io.prestosql.operator.PipelineContext)4 SourceOperator (io.prestosql.operator.SourceOperator)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4