Search in sources :

Example 6 with TaskContext

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

the class TestSpatialJoinOperator method testEmptyBuild.

@Test
public void testEmptyBuild() {
    TaskContext taskContext = createTaskContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR));
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POINT_X, "x").row(null, "null").row(POINT_Y, "y").pageBreak().row(POINT_Z, "z").pageBreak().row(POINT_W, "w");
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).build();
    assertSpatialJoin(taskContext, INNER, buildPages, probePages, expected);
}
Also used : TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) MaterializedResult(io.prestosql.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Example 7 with TaskContext

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

the class TestSpatialJoinOperator method testDistanceQuery.

@Test
public void testDistanceQuery() {
    TaskContext taskContext = createTaskContext();
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR, DOUBLE)).row(stPoint(0, 0), "0_0", 1.5).row(null, "null", 1.5).row(stPoint(1, 0), "1_0", 1.5).pageBreak().row(stPoint(3, 0), "3_0", 1.5).pageBreak().row(stPoint(10, 0), "10_0", 1.5);
    PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (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").row(null, "null").row(stPoint(1, 1), "1_1").pageBreak().row(stPoint(3, 1), "3_1").pageBreak().row(stPoint(10, 1), "10_1");
    OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), INNER, probePages.getTypes(), Ints.asList(1), 0, Optional.empty(), pagesSpatialIndexFactory);
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).row("0_1", "0_0").row("0_1", "1_0").row("1_1", "0_0").row("1_1", "1_0").row("3_1", "3_0").row("10_1", "10_0").build();
    assertOperatorEquals(joinOperatorFactory, driverContext, probePages.build(), expected);
}
Also used : SpatialJoinOperatorFactory(io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) DriverContext(io.prestosql.operator.DriverContext) TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) 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) Test(org.testng.annotations.Test)

Example 8 with TaskContext

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

the class TestSpatialJoinOperator method testSpatialJoinSnapshot.

@Test
public void testSpatialJoinSnapshot() {
    TaskContext taskContext = createTaskContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POLYGON_A, "A").row(null, "null").pageBreak().row(POLYGON_B, "B");
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POINT_X, "x").row(null, "null").row(POINT_Y, "y").pageBreak().row(POINT_Z, "z").pageBreak().row(POINT_W, "w").pageBreak().row(POINT_R, "r");
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).row("x", "A").row("y", "A").row("y", "B").row("z", "B").row("r", "A").row("r", "B").build();
    assertSpatialJoinSnapshot(taskContext, INNER, buildPages, probePages, expected);
}
Also used : TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) MaterializedResult(io.prestosql.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Example 9 with TaskContext

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

the class TestSpatialJoinOperator method testSpatialLeftJoin.

@Test
public void testSpatialLeftJoin() {
    TaskContext taskContext = createTaskContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POLYGON_A, "A").row(null, "null").pageBreak().row(POLYGON_B, "B");
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POINT_X, "x").row(null, "null").row(POINT_Y, "y").pageBreak().row(POINT_Z, "z").pageBreak().row(POINT_W, "w");
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).row("x", "A").row("null", null).row("y", "A").row("y", "B").row("z", "B").row("w", null).build();
    assertSpatialJoin(taskContext, LEFT, buildPages, probePages, expected);
}
Also used : TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) MaterializedResult(io.prestosql.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Example 10 with TaskContext

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

the class TestSpatialJoinOperator method testEmptyProbe.

@Test
public void testEmptyProbe() {
    TaskContext taskContext = createTaskContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POLYGON_A, "A").row(null, "null").pageBreak().row(POLYGON_B, "B");
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR));
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).build();
    assertSpatialJoin(taskContext, INNER, buildPages, probePages, expected);
}
Also used : TaskContext(io.prestosql.operator.TaskContext) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) MaterializedResult(io.prestosql.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Aggregations

TaskContext (io.prestosql.operator.TaskContext)39 Test (org.testng.annotations.Test)24 TestingTaskContext (io.prestosql.testing.TestingTaskContext)14 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)12 MaterializedResult (io.prestosql.testing.MaterializedResult)12 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)12 RowPagesBuilder (io.prestosql.RowPagesBuilder)11 DriverContext (io.prestosql.operator.DriverContext)11 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)11 DataSize (io.airlift.units.DataSize)7 LocalExecutionPlan (io.prestosql.sql.planner.LocalExecutionPlanner.LocalExecutionPlan)7 TestingTaskContext.createTaskContext (io.prestosql.testing.TestingTaskContext.createTaskContext)7 OperatorContext (io.prestosql.operator.OperatorContext)6 Session (io.prestosql.Session)5 DriverFactory (io.prestosql.operator.DriverFactory)5 OperatorFactory (io.prestosql.operator.OperatorFactory)5 PagesSpatialIndexFactory (io.prestosql.operator.PagesSpatialIndexFactory)5 PipelineContext (io.prestosql.operator.PipelineContext)5 SpatialIndexBuilderOperatorFactory (io.prestosql.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)5 SpatialJoinOperatorFactory (io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory)5