Search in sources :

Example 11 with RowPagesBuilder

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

the class TestHashSemiJoinOperator method testSemiJoin.

@Test(dataProvider = "hashEnabledValues")
public void testSemiJoin(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT);
    Operator buildOperator = createValuesOperator(operatorContext, rowPagesBuilder.row(10L).row(30L).row(30L).row(35L).row(36L).row(37L).row(50L).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), rowPagesBuilder.getTypes().get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(createTestMetadataManager()));
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT, BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT, BIGINT);
    List<Page> probeInput = rowPagesBuilderProbe.addSequencePage(10, 30, 0).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    HashSemiJoinOperatorFactory joinOperatorFactory = new HashSemiJoinOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(30L, 0L, true).row(31L, 1L, false).row(32L, 2L, false).row(33L, 3L, false).row(34L, 4L, false).row(35L, 5L, true).row(36L, 6L, true).row(37L, 7L, true).row(38L, 8L, false).row(39L, 9L, false).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.prestosql.sql.gen.JoinCompiler) RowPagesBuilder(io.prestosql.RowPagesBuilder) SetBuilderOperatorFactory(io.prestosql.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.prestosql.spi.Page) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) MaterializedResult(io.prestosql.testing.MaterializedResult) HashSemiJoinOperatorFactory(io.prestosql.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 12 with RowPagesBuilder

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

the class TestHashSemiJoinOperator method testProbeAndBuildNulls.

@Test(dataProvider = "hashEnabledValues")
public void testProbeAndBuildNulls(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    List<Type> buildTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), buildTypes);
    Operator buildOperator = createValuesOperator(operatorContext, rowPagesBuilder.row(0L).row(1L).row((Object) null).row(3L).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), buildTypes.get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(createTestMetadataManager()));
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), probeTypes);
    List<Page> probeInput = rowPagesBuilderProbe.row(0L).row((Object) null).row(1L).row(2L).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    HashSemiJoinOperatorFactory joinOperatorFactory = new HashSemiJoinOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(0L, true).row(null, null).row(1L, true).row(2L, null).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.prestosql.sql.gen.JoinCompiler) RowPagesBuilder(io.prestosql.RowPagesBuilder) SetBuilderOperatorFactory(io.prestosql.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.prestosql.spi.Page) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) MaterializedResult(io.prestosql.testing.MaterializedResult) HashSemiJoinOperatorFactory(io.prestosql.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 13 with RowPagesBuilder

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

the class TestStreamingAggregationOperator method testSinglePage.

@Test
public void testSinglePage() {
    RowPagesBuilder rowPagesBuilder = RowPagesBuilder.rowPagesBuilder(BOOLEAN, VARCHAR, BIGINT);
    List<Page> input = rowPagesBuilder.row(false, "a", 5).build();
    MaterializedResult expected = resultBuilder(driverContext.getSession(), VARCHAR, BIGINT, BIGINT).row("a", 1L, 5L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : RowPagesBuilder(io.prestosql.RowPagesBuilder) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 14 with RowPagesBuilder

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

the class TestStreamingAggregationOperator method testSnapshot.

@Test
public void testSnapshot() {
    RowPagesBuilder rowPagesBuilder = RowPagesBuilder.rowPagesBuilder(BOOLEAN, VARCHAR, BIGINT);
    List<Page> input = rowPagesBuilder.addSequencePage(3, 0, 0, 1).row(true, "3", 4).row(false, "3", 5).pageBreak().row(true, "3", 6).row(false, "4", 7).row(true, "4", 8).row(false, "4", 9).row(true, "4", 10).pageBreak().row(false, "5", 11).row(true, "5", 12).row(false, "5", 13).row(true, "5", 14).row(false, "5", 15).pageBreak().addSequencePage(3, 0, 6, 16).build();
    MaterializedResult expected = resultBuilder(driverContext.getSession(), VARCHAR, BIGINT, BIGINT).row("0", 1L, 1L).row("1", 1L, 2L).row("2", 1L, 3L).row("3", 3L, 15L).row("4", 4L, 34L).row("5", 5L, 65L).row("6", 1L, 16L).row("7", 1L, 17L).row("8", 1L, 18L).build();
    assertOperatorEqualsWithSimpleSelfStateComparison(operatorFactory, driverContext, input, expected, createExpectedMapping());
}
Also used : RowPagesBuilder(io.prestosql.RowPagesBuilder) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 15 with RowPagesBuilder

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

the class TestStreamingAggregationOperator method testUniqueGroupingValues.

@Test
public void testUniqueGroupingValues() {
    RowPagesBuilder rowPagesBuilder = RowPagesBuilder.rowPagesBuilder(BOOLEAN, VARCHAR, BIGINT);
    List<Page> input = rowPagesBuilder.addSequencePage(10, 0, 0, 0).addSequencePage(10, 0, 10, 10).build();
    MaterializedResult.Builder builder = resultBuilder(driverContext.getSession(), VARCHAR, BIGINT, BIGINT);
    for (int i = 0; i < 20; i++) {
        builder.row(format("%s", i), 1L, Long.valueOf(i));
    }
    assertOperatorEquals(operatorFactory, driverContext, input, builder.build());
}
Also used : RowPagesBuilder(io.prestosql.RowPagesBuilder) Page(io.prestosql.spi.Page) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

RowPagesBuilder (io.prestosql.RowPagesBuilder)87 Test (org.testng.annotations.Test)83 Page (io.prestosql.spi.Page)74 MaterializedResult (io.prestosql.testing.MaterializedResult)69 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)49 TestingTaskContext (io.prestosql.testing.TestingTaskContext)44 Type (io.prestosql.spi.type.Type)37 DataSize (io.airlift.units.DataSize)21 HashBuilderOperatorFactory (io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory)21 ValuesOperatorFactory (io.prestosql.operator.ValuesOperator.ValuesOperatorFactory)21 LocalExchangeSinkOperatorFactory (io.prestosql.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory)21 LocalExchangeSourceOperatorFactory (io.prestosql.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory)21 PageBufferOperatorFactory (io.prestosql.operator.index.PageBufferOperator.PageBufferOperatorFactory)21 MarkerPage (io.prestosql.spi.snapshot.MarkerPage)21 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)18 HashAggregationOperatorFactory (io.prestosql.operator.HashAggregationOperator.HashAggregationOperatorFactory)12 TaskContext (io.prestosql.operator.TaskContext)11 NestedLoopJoinOperatorFactory (io.prestosql.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)10 LocalExchangeSourceOperator (io.prestosql.operator.exchange.LocalExchangeSourceOperator)9 RowPagesBuilder.rowPagesBuilder (io.prestosql.RowPagesBuilder.rowPagesBuilder)8