use of io.prestosql.operator.aggregation.AccumulatorFactory in project hetu-core by openlookeng.
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());
Rectangle expectedExtent = new Rectangle(-10, -10, Math.nextUp(10.0), Math.nextUp(10.0));
String expectedValue = getSpatialPartitioning(expectedExtent, geometries, partitionCount);
AccumulatorFactory accumulatorFactory = function.bind(Ints.asList(0, 1, 2), Optional.empty());
Page page = new Page(geometryBlock, partitionCountBlock);
Accumulator accumulator = accumulatorFactory.createAccumulator();
accumulator.addInput(page);
String aggregation = (String) BlockAssertions.getOnlyValue(accumulator.getFinalType(), getFinalBlock(accumulator));
assertEquals(aggregation, expectedValue);
GroupedAccumulator groupedAggregation = accumulatorFactory.createGroupedAccumulator();
groupedAggregation.addInput(createGroupByIdBlock(0, page.getPositionCount()), page);
String groupValue = (String) getGroupValue(groupedAggregation, 0);
assertEquals(groupValue, expectedValue);
}
use of io.prestosql.operator.aggregation.AccumulatorFactory in project hetu-core by openlookeng.
the class InMemoryHashAggregationBuilder method toTypes.
public static List<Type> toTypes(List<? extends Type> groupByType, Step step, List<AccumulatorFactory> factories, Optional<Integer> hashChannel) {
ImmutableList.Builder<Type> types = ImmutableList.builder();
types.addAll(groupByType);
if (hashChannel.isPresent()) {
types.add(BIGINT);
}
for (AccumulatorFactory factory : factories) {
types.add(new Aggregator(factory, step, Optional.empty()).getType());
}
return types.build();
}
Aggregations