Search in sources :

Example 6 with PartitionFunction

use of com.facebook.presto.operator.PartitionFunction in project presto by prestodb.

the class TestOptimizedPartitionedOutputOperator method testReplicated.

private void testReplicated(List<Type> types, List<Page> pages, DataSize maxMemory) {
    TestingPartitionedOutputBuffer outputBuffer = createPartitionedOutputBuffer();
    PartitionFunction partitionFunction = new LocalPartitionGenerator(new PrecomputedHashGenerator(0), PARTITION_COUNT);
    OptimizedPartitionedOutputOperator operator = createOptimizedPartitionedOutputOperator(types, ImmutableList.of(0), partitionFunction, outputBuffer, OptionalInt.of(types.size() - 1), maxMemory);
    for (Page page : pages) {
        operator.addInput(page);
    }
    operator.finish();
    Map<Integer, List<Page>> acutualPageLists = outputBuffer.getPages();
    assertEquals(acutualPageLists.size(), PARTITION_COUNT);
    Page expectedPage = mergePages(types, pages);
    acutualPageLists.values().forEach(pageList -> assertPageEquals(types, mergePages(types, pageList), expectedPage));
}
Also used : PartitionFunction(com.facebook.presto.operator.PartitionFunction) LocalPartitionGenerator(com.facebook.presto.operator.exchange.LocalPartitionGenerator) Page(com.facebook.presto.common.Page) SerializedPage(com.facebook.presto.spi.page.SerializedPage) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) PrecomputedHashGenerator(com.facebook.presto.operator.PrecomputedHashGenerator)

Aggregations

PartitionFunction (com.facebook.presto.operator.PartitionFunction)6 Page (com.facebook.presto.common.Page)4 Type (com.facebook.presto.common.type.Type)4 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 Session (com.facebook.presto.Session)2 BlockAssertions.createMapType (com.facebook.presto.block.BlockAssertions.createMapType)2 ArrayType (com.facebook.presto.common.type.ArrayType)2 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)2 DecimalType.createDecimalType (com.facebook.presto.common.type.DecimalType.createDecimalType)2 PrecomputedHashGenerator (com.facebook.presto.operator.PrecomputedHashGenerator)2 LocalPartitionGenerator (com.facebook.presto.operator.exchange.LocalPartitionGenerator)2 ArrayList (java.util.ArrayList)2 Optional (java.util.Optional)2 OptionalInt (java.util.OptionalInt)2 Test (org.testng.annotations.Test)2 MoreFutures.addSuccessCallback (com.facebook.airlift.concurrent.MoreFutures.addSuccessCallback)1 Threads.daemonThreadsNamed (com.facebook.airlift.concurrent.Threads.daemonThreadsNamed)1 JsonCodec (com.facebook.airlift.json.JsonCodec)1 Assertions.assertBetweenInclusive (com.facebook.airlift.testing.Assertions.assertBetweenInclusive)1