Search in sources :

Example 1 with GroupByHashYieldResult

use of com.facebook.presto.operator.GroupByHashYieldAssertion.GroupByHashYieldResult in project presto by prestodb.

the class TestHashAggregationOperator method testMemoryReservationYield.

@Test(dataProvider = "dataType")
public void testMemoryReservationYield(Type type) {
    List<Page> input = createPagesWithDistinctHashKeys(type, 6_000, 600);
    OperatorFactory operatorFactory = new HashAggregationOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(type), ImmutableList.of(0), ImmutableList.of(), Step.SINGLE, ImmutableList.of(COUNT.bind(ImmutableList.of(0), Optional.empty())), Optional.of(1), Optional.empty(), 1, Optional.of(new DataSize(16, MEGABYTE)), joinCompiler, false);
    // get result with yield; pick a relatively small buffer for aggregator's memory usage
    GroupByHashYieldResult result;
    result = finishOperatorWithYieldingGroupByHash(input, type, operatorFactory, this::getHashCapacity, 1_400_000);
    assertGreaterThan(result.getYieldCount(), 5);
    assertGreaterThan(result.getMaxReservedBytes(), 20L << 20);
    int count = 0;
    for (Page page : result.getOutput()) {
        // value + hash + aggregation result
        assertEquals(page.getChannelCount(), 3);
        for (int i = 0; i < page.getPositionCount(); i++) {
            assertEquals(page.getBlock(2).getLong(i), 1);
            count++;
        }
    }
    assertEquals(count, 6_000 * 600);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) GroupByHashYieldResult(com.facebook.presto.operator.GroupByHashYieldAssertion.GroupByHashYieldResult) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory) DataSize(io.airlift.units.DataSize) Page(com.facebook.presto.common.Page) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

Page (com.facebook.presto.common.Page)1 GroupByHashYieldResult (com.facebook.presto.operator.GroupByHashYieldAssertion.GroupByHashYieldResult)1 HashAggregationOperatorFactory (com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)1 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)1 DataSize (io.airlift.units.DataSize)1 Test (org.testng.annotations.Test)1