Search in sources :

Example 1 with GroupedAccumulator

use of io.prestosql.operator.aggregation.GroupedAccumulator in project hetu-core by openlookeng.

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);
}
Also used : Page(io.prestosql.spi.Page) GroupedAccumulator(io.prestosql.operator.aggregation.GroupedAccumulator)

Example 2 with GroupedAccumulator

use of io.prestosql.operator.aggregation.GroupedAccumulator 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);
}
Also used : OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) Accumulator(io.prestosql.operator.aggregation.Accumulator) GroupedAccumulator(io.prestosql.operator.aggregation.GroupedAccumulator) AccumulatorFactory(io.prestosql.operator.aggregation.AccumulatorFactory) Rectangle(io.prestosql.geospatial.Rectangle) AggregationTestUtils.getFinalBlock(io.prestosql.operator.aggregation.AggregationTestUtils.getFinalBlock) Block(io.prestosql.spi.block.Block) AggregationTestUtils.createGroupByIdBlock(io.prestosql.operator.aggregation.AggregationTestUtils.createGroupByIdBlock) Page(io.prestosql.spi.Page) InternalAggregationFunction(io.prestosql.operator.aggregation.InternalAggregationFunction) GroupedAccumulator(io.prestosql.operator.aggregation.GroupedAccumulator) Test(org.testng.annotations.Test)

Aggregations

GroupedAccumulator (io.prestosql.operator.aggregation.GroupedAccumulator)2 Page (io.prestosql.spi.Page)2 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)1 Rectangle (io.prestosql.geospatial.Rectangle)1 Accumulator (io.prestosql.operator.aggregation.Accumulator)1 AccumulatorFactory (io.prestosql.operator.aggregation.AccumulatorFactory)1 AggregationTestUtils.createGroupByIdBlock (io.prestosql.operator.aggregation.AggregationTestUtils.createGroupByIdBlock)1 AggregationTestUtils.getFinalBlock (io.prestosql.operator.aggregation.AggregationTestUtils.getFinalBlock)1 InternalAggregationFunction (io.prestosql.operator.aggregation.InternalAggregationFunction)1 Block (io.prestosql.spi.block.Block)1 Test (org.testng.annotations.Test)1