Search in sources :

Example 6 with AggregationTestOutput

use of com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput in project presto by prestodb.

the class TestArrayAggregation method testMultipleGroupsWithMultiplePages.

@Test
public void testMultipleGroupsWithMultiplePages() {
    InternalAggregationFunction varcharAgg = getAggregation(VARCHAR);
    Block block1 = createStringsBlock("a", "b", "c", "d", "e");
    Block block2 = createStringsBlock("f", "g", "h", "i", "j");
    AggregationTestOutput aggregationTestOutput1 = new AggregationTestOutput(ImmutableList.of("a", "b", "c", "d", "e"));
    AggregationTestInputBuilder testInputBuilder1 = new AggregationTestInputBuilder(new Block[] { block1 }, varcharAgg);
    AggregationTestInput test1 = testInputBuilder1.build();
    GroupedAccumulator groupedAccumulator = test1.createGroupedAccumulator();
    test1.runPagesOnAccumulatorWithAssertion(0L, groupedAccumulator, aggregationTestOutput1);
    AggregationTestOutput aggregationTestOutput2 = new AggregationTestOutput(ImmutableList.of("f", "g", "h", "i", "j"));
    AggregationTestInputBuilder testBuilder2 = new AggregationTestInputBuilder(new Block[] { block2 }, varcharAgg);
    AggregationTestInput test2 = testBuilder2.build();
    test2.runPagesOnAccumulatorWithAssertion(255L, groupedAccumulator, aggregationTestOutput2);
}
Also used : AggregationTestOutput(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput) BlockAssertions.createLongsBlock(com.facebook.presto.block.BlockAssertions.createLongsBlock) BlockAssertions.createStringsBlock(com.facebook.presto.block.BlockAssertions.createStringsBlock) BlockAssertions.createArrayBigintBlock(com.facebook.presto.block.BlockAssertions.createArrayBigintBlock) BlockAssertions.createBooleansBlock(com.facebook.presto.block.BlockAssertions.createBooleansBlock) BlockAssertions.createTypedLongsBlock(com.facebook.presto.block.BlockAssertions.createTypedLongsBlock) Block(com.facebook.presto.common.block.Block) AggregationTestInput(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInput) AggregationTestInputBuilder(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder) Test(org.testng.annotations.Test)

Example 7 with AggregationTestOutput

use of com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput in project presto by prestodb.

the class TestArrayAggregation method testManyValues.

@Test
public void testManyValues() {
    // Test many values so multiple BlockBuilders will be used to store group state.
    InternalAggregationFunction varcharAgg = getAggregation(VARCHAR);
    int numGroups = 50000;
    int arraySize = 30;
    Random random = new Random();
    GroupedAccumulator groupedAccumulator = createGroupedAccumulator(varcharAgg);
    for (int j = 0; j < numGroups; j++) {
        List<String> expectedValues = new ArrayList<>();
        List<String> valueList = new ArrayList<>();
        for (int i = 0; i < arraySize; i++) {
            String str = String.valueOf(random.nextInt());
            valueList.add(str);
            expectedValues.add(str);
        }
        Block block = createStringsBlock(valueList);
        AggregationTestInputBuilder testInputBuilder = new AggregationTestInputBuilder(new Block[] { block }, varcharAgg);
        AggregationTestInput test1 = testInputBuilder.build();
        test1.runPagesOnAccumulatorWithAssertion(j, groupedAccumulator, new AggregationTestOutput(expectedValues));
    }
}
Also used : Random(java.util.Random) AggregationTestOutput(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput) ArrayList(java.util.ArrayList) BlockAssertions.createLongsBlock(com.facebook.presto.block.BlockAssertions.createLongsBlock) BlockAssertions.createStringsBlock(com.facebook.presto.block.BlockAssertions.createStringsBlock) BlockAssertions.createArrayBigintBlock(com.facebook.presto.block.BlockAssertions.createArrayBigintBlock) BlockAssertions.createBooleansBlock(com.facebook.presto.block.BlockAssertions.createBooleansBlock) BlockAssertions.createTypedLongsBlock(com.facebook.presto.block.BlockAssertions.createTypedLongsBlock) Block(com.facebook.presto.common.block.Block) AggregationTestInput(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInput) AggregationTestInputBuilder(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder) Test(org.testng.annotations.Test)

Example 8 with AggregationTestOutput

use of com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput in project presto by prestodb.

the class TestArrayAggregation method testWithMultiplePages.

@Test
public void testWithMultiplePages() {
    InternalAggregationFunction varcharAgg = getAggregation(VARCHAR);
    AggregationTestInputBuilder testInputBuilder = new AggregationTestInputBuilder(new Block[] { createStringsBlock("hello", "world", "hello2", "world2", "hello3", "world3", "goodbye") }, varcharAgg);
    AggregationTestOutput testOutput = new AggregationTestOutput(ImmutableList.of("hello", "world", "hello2", "world2", "hello3", "world3", "goodbye"));
    AggregationTestInput testInput = testInputBuilder.build();
    testInput.runPagesOnAccumulatorWithAssertion(0L, testInput.createGroupedAccumulator(), testOutput);
}
Also used : AggregationTestOutput(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput) AggregationTestInput(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInput) AggregationTestInputBuilder(com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder) Test(org.testng.annotations.Test)

Aggregations

AggregationTestInput (com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInput)8 AggregationTestInputBuilder (com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder)8 AggregationTestOutput (com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestOutput)8 Block (com.facebook.presto.common.block.Block)7 BlockAssertions.createBooleansBlock (com.facebook.presto.block.BlockAssertions.createBooleansBlock)6 BlockAssertions.createLongsBlock (com.facebook.presto.block.BlockAssertions.createLongsBlock)6 BlockAssertions.createStringsBlock (com.facebook.presto.block.BlockAssertions.createStringsBlock)6 BlockAssertions.createDoublesBlock (com.facebook.presto.block.BlockAssertions.createDoublesBlock)4 BlockAssertions.createStringArraysBlock (com.facebook.presto.block.BlockAssertions.createStringArraysBlock)4 Test (org.testng.annotations.Test)4 BlockAssertions.createArrayBigintBlock (com.facebook.presto.block.BlockAssertions.createArrayBigintBlock)2 BlockAssertions.createTypedLongsBlock (com.facebook.presto.block.BlockAssertions.createTypedLongsBlock)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 RowPageBuilder (com.facebook.presto.RowPageBuilder)1 Page (com.facebook.presto.common.Page)1 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 ArrayType (com.facebook.presto.common.type.ArrayType)1 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)1 BOOLEAN (com.facebook.presto.common.type.BooleanType.BOOLEAN)1