use of com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder 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);
}
use of com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder 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));
}
}
use of com.facebook.presto.operator.aggregation.groupByAggregations.AggregationTestInputBuilder 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);
}
Aggregations