use of com.facebook.presto.operator.aggregation.GroupedAccumulator in project presto by prestodb.
the class TestSpatialPartitioningInternalAggregation method test.
@Test(dataProvider = "partitionCount")
public void test(int partitionCount) {
InternalAggregationFunction function = getFunction();
List<OGCGeometry> geometries = makeGeometries();
Block geometryBlock = makeGeometryBlock(geometries);
Block partitionCountBlock = BlockAssertions.createRLEBlock(partitionCount, geometries.size());
String expectedValue = getSpatialPartitioning(geometries, partitionCount);
AccumulatorFactory accumulatorFactory = function.bind(Ints.asList(0, 1), Optional.empty());
Page page = new Page(geometryBlock, partitionCountBlock);
Accumulator accumulator = accumulatorFactory.createAccumulator(UpdateMemory.NOOP);
accumulator.addInput(page);
String aggregation = (String) BlockAssertions.getOnlyValue(accumulator.getFinalType(), getFinalBlock(accumulator));
assertEquals(aggregation, expectedValue);
GroupedAccumulator groupedAggregation = accumulatorFactory.createGroupedAccumulator(UpdateMemory.NOOP);
groupedAggregation.addInput(createGroupByIdBlock(0, page.getPositionCount()), page);
String groupValue = (String) getGroupValue(groupedAggregation, 0);
assertEquals(groupValue, expectedValue);
}
use of com.facebook.presto.operator.aggregation.GroupedAccumulator in project presto by prestodb.
the class AggregationTestInput method runPagesOnAccumulatorWithAssertion.
public void runPagesOnAccumulatorWithAssertion(long groupId, GroupedAccumulator groupedAccumulator, AggregationTestOutput expectedValue) {
GroupedAccumulator accumulator = Suppliers.ofInstance(groupedAccumulator).get();
for (Page page : getPages()) {
accumulator.addInput(getGroupIdBlock(groupId, page), page);
}
expectedValue.validateAccumulator(accumulator, groupId);
}
Aggregations