Search in sources :

Example 11 with OperatorFactory

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

the class TestSpatialJoinOperator method testDistributedSpatialJoin.

@Test
public void testDistributedSpatialJoin() {
    TaskContext taskContext = createTaskContext();
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, true).addDriverContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR, INTEGER)).row(POLYGON_A, "A", 1).row(POLYGON_A, "A", 2).row(null, "null", null).pageBreak().row(POLYGON_B, "B", 0).row(POLYGON_B, "B", 2);
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR, INTEGER)).row(POINT_X, "x", 2).row(null, "null", null).row(POINT_Y, "y", 2).pageBreak().row(POINT_Z, "z", 0);
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).row("x", "A").row("y", "A").row("y", "B").row("z", "B").build();
    PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.of(2), Optional.of(KDB_TREE_JSON), Optional.empty(), buildPages);
    OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), INNER, probePages.getTypes(), Ints.asList(1), 0, Optional.of(2), pagesSpatialIndexFactory);
    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) MaterializedResult(io.prestosql.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) PagesSpatialIndexFactory(io.prestosql.operator.PagesSpatialIndexFactory) Test(org.testng.annotations.Test)

Example 12 with OperatorFactory

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

the class TestUnnestOperator method testUnnestWithArray.

@Test
public void testUnnestWithArray() {
    Metadata metadata = createTestMetadataManager();
    Type arrayType = metadata.getType(parseTypeSignature("array(array(bigint))"));
    Type mapType = metadata.getType(parseTypeSignature("map(array(bigint),array(bigint))"));
    List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(2, 4), ImmutableList.of(3, 6)), mapBlockOf(new ArrayType(BIGINT), new ArrayType(BIGINT), ImmutableMap.of(ImmutableList.of(4, 8), ImmutableList.of(5, 10)))).row(2L, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(99, 198)), null).row(3L, null, null).pageBreak().row(6, arrayBlockOf(new ArrayType(BIGINT), ImmutableList.of(7, 14), ImmutableList.of(8, 16)), mapBlockOf(new ArrayType(BIGINT), new ArrayType(BIGINT), ImmutableMap.of(ImmutableList.of(9, 18), ImmutableList.of(10, 20), ImmutableList.of(11, 22), ImmutableList.of(12, 24)))).build();
    OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), false);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, new ArrayType(BIGINT), new ArrayType(BIGINT), new ArrayType(BIGINT)).row(1L, ImmutableList.of(2L, 4L), ImmutableList.of(4L, 8L), ImmutableList.of(5L, 10L)).row(1L, ImmutableList.of(3L, 6L), null, null).row(2L, ImmutableList.of(99L, 198L), null, null).row(6L, ImmutableList.of(7L, 14L), ImmutableList.of(9L, 18L), ImmutableList.of(10L, 20L)).row(6L, ImmutableList.of(8L, 16L), ImmutableList.of(11L, 22L), ImmutableList.of(12L, 24L)).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : ArrayType(io.prestosql.spi.type.ArrayType) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) ArrayType(io.prestosql.spi.type.ArrayType) OperatorFactory(io.prestosql.operator.OperatorFactory) Metadata(io.prestosql.metadata.Metadata) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 13 with OperatorFactory

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

the class TestUnnestOperator method testUnnestWithOrdinality.

@Test
public void testUnnestWithOrdinality() {
    Metadata metadata = createTestMetadataManager();
    Type arrayType = metadata.getType(parseTypeSignature("array(bigint)"));
    Type mapType = metadata.getType(parseTypeSignature("map(bigint,bigint)"));
    List<Page> input = rowPagesBuilder(BIGINT, arrayType, mapType).row(1L, arrayBlockOf(BIGINT, 2, 3), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(4, 5))).row(2L, arrayBlockOf(BIGINT, 99), null).row(3L, null, null).pageBreak().row(6L, arrayBlockOf(BIGINT, 7, 8), mapBlockOf(BIGINT, BIGINT, ImmutableMap.of(9, 10, 11, 12))).build();
    OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1, 2), ImmutableList.of(arrayType, mapType), true);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, BIGINT, BIGINT, BIGINT).row(1L, 2L, 4L, 5L, 1L).row(1L, 3L, null, null, 2L).row(2L, 99L, null, null, 1L).row(6L, 7L, 9L, 10L, 1L).row(6L, 8L, 11L, 12L, 2L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) ArrayType(io.prestosql.spi.type.ArrayType) OperatorFactory(io.prestosql.operator.OperatorFactory) Metadata(io.prestosql.metadata.Metadata) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 14 with OperatorFactory

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

the class TestUnnestOperator method testUnnestWithArrayOfRows.

@Test
public void testUnnestWithArrayOfRows() {
    Metadata metadata = createTestMetadataManager();
    Type arrayOfRowType = metadata.getType(parseTypeSignature("array(row(bigint, double, varchar))"));
    Type elementType = RowType.anonymous(ImmutableList.of(BIGINT, DOUBLE, VARCHAR));
    List<Page> input = rowPagesBuilder(BIGINT, arrayOfRowType).row(1, arrayBlockOf(elementType, ImmutableList.of(2, 4.2, "abc"), ImmutableList.of(3, 6.6, "def"))).row(2, arrayBlockOf(elementType, ImmutableList.of(99, 3.14, "pi"), null)).row(3, null).pageBreak().row(6, arrayBlockOf(elementType, null, ImmutableList.of(8, 1.111, "tt"))).build();
    OperatorFactory operatorFactory = new UnnestOperator.UnnestOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(0), ImmutableList.of(BIGINT), ImmutableList.of(1), ImmutableList.of(arrayOfRowType), false);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, BIGINT, DOUBLE, VARCHAR).row(1L, 2L, 4.2, "abc").row(1L, 3L, 6.6, "def").row(2L, 99L, 3.14, "pi").row(2L, null, null, null).row(6L, null, null, null).row(6L, 8L, 1.111, "tt").build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) ArrayType(io.prestosql.spi.type.ArrayType) OperatorFactory(io.prestosql.operator.OperatorFactory) Metadata(io.prestosql.metadata.Metadata) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 15 with OperatorFactory

use of io.prestosql.operator.OperatorFactory in project boostkit-bigdata by kunpengcompute.

the class TestOmniLocalExecutionPlanner method mockSupports.

private void mockSupports() throws Exception {
    // mock VecAllocator
    VecAllocator vecAllocator = mock(VecAllocator.class);
    mockStatic(OpenLooKengAllocatorFactory.class);
    when(OpenLooKengAllocatorFactory.create(anyString(), any(OpenLooKengAllocatorFactory.CallBack.class))).thenReturn(vecAllocator);
    // mock AggOmniOperator
    AggregationOmniOperator aggregationOmniOperator = mock(AggregationOmniOperator.class);
    AggregationOmniOperator.AggregationOmniOperatorFactory aggregationOmniOperatorFactory = mock(AggregationOmniOperator.AggregationOmniOperatorFactory.class);
    whenNew(AggregationOmniOperator.AggregationOmniOperatorFactory.class).withAnyArguments().thenReturn(aggregationOmniOperatorFactory);
    when(aggregationOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(aggregationOmniOperator);
    // mock TopNOmniOperator
    TopNOmniOperator topNOmniOperator = mock(TopNOmniOperator.class);
    TopNOmniOperator.TopNOmniOperatorFactory topNOmniOperatorFactory = mock(TopNOmniOperator.TopNOmniOperatorFactory.class);
    whenNew(TopNOmniOperator.TopNOmniOperatorFactory.class).withAnyArguments().thenReturn(topNOmniOperatorFactory);
    when(topNOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(topNOmniOperator);
    // mock HashAggOmniOperator
    HashAggregationOmniOperator hashAggregationOmniOperator = mock(HashAggregationOmniOperator.class);
    HashAggregationOmniOperator.HashAggregationOmniOperatorFactory hashAggregationOmniOperatorFactory = mock(HashAggregationOmniOperator.HashAggregationOmniOperatorFactory.class);
    whenNew(HashAggregationOmniOperator.HashAggregationOmniOperatorFactory.class).withAnyArguments().thenReturn(hashAggregationOmniOperatorFactory);
    when(hashAggregationOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(hashAggregationOmniOperator);
    // mock HashBuilderOmniOperator
    HashBuilderOmniOperator hashBuilderOmniOperator = mock(HashBuilderOmniOperator.class);
    HashBuilderOmniOperator.HashBuilderOmniOperatorFactory hashBuilderOmniOperatorFactory = mock(HashBuilderOmniOperator.HashBuilderOmniOperatorFactory.class);
    whenNew(HashBuilderOmniOperator.HashBuilderOmniOperatorFactory.class).withAnyArguments().thenReturn(hashBuilderOmniOperatorFactory);
    when(hashBuilderOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(hashBuilderOmniOperator);
    // mock LookupJoinOmniOperator
    LookupJoinOmniOperator lookupJoinOmniOperator = mock(LookupJoinOmniOperator.class);
    LookupJoinOmniOperator.LookupJoinOmniOperatorFactory lookupJoinOmniOperatorFactory = mock(LookupJoinOmniOperator.LookupJoinOmniOperatorFactory.class);
    whenNew(LookupJoinOmniOperator.LookupJoinOmniOperatorFactory.class).withAnyArguments().thenReturn(lookupJoinOmniOperatorFactory);
    when(lookupJoinOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(lookupJoinOmniOperator);
    // mock LomitOmniOperator
    LimitOmniOperator limitOmniOperator = mock(LimitOmniOperator.class);
    LimitOmniOperator.LimitOmniOperatorFactory limitOmniOperatorFactory = mock(LimitOmniOperator.LimitOmniOperatorFactory.class);
    whenNew(LimitOmniOperator.LimitOmniOperatorFactory.class).withAnyArguments().thenReturn(limitOmniOperatorFactory);
    when(limitOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(limitOmniOperator);
    // mock WindowOmniOperator
    WindowOmniOperator windowOmniOperator = mock(WindowOmniOperator.class);
    WindowOmniOperator.WindowOmniOperatorFactory windowOmniOperatorFactory = mock(WindowOmniOperator.WindowOmniOperatorFactory.class);
    whenNew(WindowOmniOperator.WindowOmniOperatorFactory.class).withAnyArguments().thenReturn(windowOmniOperatorFactory);
    when(windowOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(windowOmniOperator);
    // mock DistinctLimitOmniOperator
    DistinctLimitOmniOperator distinctLimitOmniOperator = mock(DistinctLimitOmniOperator.class);
    DistinctLimitOmniOperator.DistinctLimitOmniOperatorFactory distinctLimitOmniOperatorFactory = mock(DistinctLimitOmniOperator.DistinctLimitOmniOperatorFactory.class);
    whenNew(DistinctLimitOmniOperator.DistinctLimitOmniOperatorFactory.class).withAnyArguments().thenReturn(distinctLimitOmniOperatorFactory);
    when(distinctLimitOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(distinctLimitOmniOperator);
    // mock PartitionedOutputOmniOperator
    PartitionedOutputOmniOperator partitionedOutputOmniOperator = mock(PartitionedOutputOmniOperator.class);
    OperatorFactory operatorFactory = mock(OperatorFactory.class);
    when(operatorFactory.duplicate()).thenReturn(operatorFactory);
    PartitionedOutputOmniOperator.PartitionedOutputOmniFactory partitionedOutputOmniFactory = mock(PartitionedOutputOmniOperator.PartitionedOutputOmniFactory.class);
    whenNew(PartitionedOutputOmniOperator.PartitionedOutputOmniFactory.class).withAnyArguments().thenReturn(partitionedOutputOmniFactory);
    when(partitionedOutputOmniFactory.createOutputOperator(anyInt(), any(PlanNodeId.class), anyList(), any(Function.class), any(TaskContext.class))).thenReturn(operatorFactory);
    when(operatorFactory.createOperator(any(DriverContext.class))).thenReturn(partitionedOutputOmniOperator);
    // mock OrderByOmniOperator
    OrderByOmniOperator orderByOmniOperator = mock(OrderByOmniOperator.class);
    OrderByOmniOperator.OrderByOmniOperatorFactory orderByOmniOperatorFactory = mock(OrderByOmniOperator.OrderByOmniOperatorFactory.class);
    mockStatic(OrderByOmniOperator.OrderByOmniOperatorFactory.class);
    when(OrderByOmniOperator.OrderByOmniOperatorFactory.createOrderByOmniOperatorFactory(anyInt(), any(PlanNodeId.class), anyList(), anyList(), anyList(), anyList())).thenReturn(orderByOmniOperatorFactory);
    whenNew(OrderByOmniOperator.OrderByOmniOperatorFactory.class).withAnyArguments().thenReturn(orderByOmniOperatorFactory);
    when(orderByOmniOperatorFactory.createOperator(any(DriverContext.class))).thenReturn(orderByOmniOperator);
    // mock supplier
    Supplier supplier = mock(Supplier.class);
    OmniExpressionCompiler omniExpressionCompiler = mock(OmniExpressionCompiler.class);
    when(omniExpressionCompiler.compilePageProcessor(any(Optional.class), anyList(), any(Optional.class), any(OptionalInt.class), anyList(), any(TaskId.class), any(OmniLocalExecutionPlanner.OmniLocalExecutionPlanContext.class))).thenReturn(supplier);
    whenNew(OmniExpressionCompiler.class).withAnyArguments().thenReturn(omniExpressionCompiler);
    // mock PartitionFunction
    PartitionFunction partitionFunction = mock(PartitionFunction.class);
    NodePartitioningManager nodePartitioningManager = mock(NodePartitioningManager.class);
    whenNew(NodePartitioningManager.class).withAnyArguments().thenReturn(nodePartitioningManager);
    when(nodePartitioningManager.getPartitionFunction(any(Session.class), any(PartitioningScheme.class), anyList())).thenReturn(partitionFunction);
}
Also used : PartitionFunction(io.prestosql.operator.PartitionFunction) DriverContext(io.prestosql.operator.DriverContext) WindowOmniOperator(nova.hetu.olk.operator.WindowOmniOperator) HashBuilderOmniOperator(nova.hetu.olk.operator.HashBuilderOmniOperator) LimitOmniOperator(nova.hetu.olk.operator.LimitOmniOperator) DistinctLimitOmniOperator(nova.hetu.olk.operator.DistinctLimitOmniOperator) TaskId(io.prestosql.execution.TaskId) DistinctLimitOmniOperator(nova.hetu.olk.operator.DistinctLimitOmniOperator) NodePartitioningManager(io.prestosql.sql.planner.NodePartitioningManager) PartitionedOutputOmniOperator(nova.hetu.olk.operator.PartitionedOutputOmniOperator) HashAggregationOmniOperator(nova.hetu.olk.operator.HashAggregationOmniOperator) AggregationOmniOperator(nova.hetu.olk.operator.AggregationOmniOperator) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Function(java.util.function.Function) PartitionFunction(io.prestosql.operator.PartitionFunction) Supplier(java.util.function.Supplier) TaskContext(io.prestosql.operator.TaskContext) Optional(java.util.Optional) PartitioningScheme(io.prestosql.sql.planner.PartitioningScheme) OptionalInt(java.util.OptionalInt) VecAllocator(nova.hetu.omniruntime.vector.VecAllocator) OmniExpressionCompiler(nova.hetu.olk.operator.filterandproject.OmniExpressionCompiler) LookupJoinOmniOperator(nova.hetu.olk.operator.LookupJoinOmniOperator) OperatorFactory(io.prestosql.operator.OperatorFactory) OrderByOmniOperator(nova.hetu.olk.operator.OrderByOmniOperator) HashAggregationOmniOperator(nova.hetu.olk.operator.HashAggregationOmniOperator) TopNOmniOperator(nova.hetu.olk.operator.TopNOmniOperator) Session(io.prestosql.Session)

Aggregations

OperatorFactory (io.prestosql.operator.OperatorFactory)36 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)28 Type (io.prestosql.spi.type.Type)14 DriverContext (io.prestosql.operator.DriverContext)12 MaterializedResult (io.prestosql.testing.MaterializedResult)12 Test (org.testng.annotations.Test)11 DriverFactory (io.prestosql.operator.DriverFactory)9 SpatialIndexBuilderOperatorFactory (io.prestosql.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory)9 SpatialJoinOperatorFactory (io.prestosql.operator.SpatialJoinOperator.SpatialJoinOperatorFactory)9 Page (io.prestosql.spi.Page)9 PagesSpatialIndexFactory (io.prestosql.operator.PagesSpatialIndexFactory)7 ImmutableList (com.google.common.collect.ImmutableList)6 Metadata (io.prestosql.metadata.Metadata)6 SourceOperatorFactory (io.prestosql.operator.SourceOperatorFactory)6 TaskContext (io.prestosql.operator.TaskContext)6 ArrayList (java.util.ArrayList)6 RowPagesBuilder (io.prestosql.RowPagesBuilder)5 AggregationOperatorFactory (io.prestosql.operator.AggregationOperator.AggregationOperatorFactory)5 HashBuilderOperatorFactory (io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory)5 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)5