Search in sources :

Example 1 with AggregateOperations

use of com.hazelcast.jet.aggregate.AggregateOperations in project hazelcast by hazelcast.

the class SlidingWindowP_CoGroupTest method test.

@Test
@SuppressWarnings("unchecked")
public void test() {
    SupplierEx supplier = Processors.aggregateToSlidingWindowP(asList(Functions.<String>entryKey(), entryKey()), asList(t -> 1L, t -> 1L), TimestampKind.FRAME, tumblingWinPolicy(1), 0L, aggregateOperation2(AggregateOperations.<Entry<String, String>>toList(), AggregateOperations.<Entry<String, String>>toList()), (start, end, key, result, isEarly) -> result(end, key, result.f0(), result.f1()));
    Entry<String, String> entry1 = entry("k1", "a");
    Entry<String, String> entry2 = entry("k2", "b");
    Entry<String, String> entry3 = entry("k1", "c");
    Entry<String, String> entry4 = entry("k3", "d");
    Entry<String, String> entry5 = entry("k1", "e");
    TestSupport.verifyProcessor(supplier).inputs(asList(asList(entry1, entry2), asList(entry3, entry4, entry5))).expectOutput(asList(result(1, "k1", singletonList(entry1), asList(entry3, entry5)), result(1, "k2", singletonList(entry2), emptyList()), result(1, "k3", emptyList(), singletonList(entry4))));
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Functions(com.hazelcast.function.Functions) AggregateOperations.aggregateOperation2(com.hazelcast.jet.aggregate.AggregateOperations.aggregateOperation2) Collections.emptyList(java.util.Collections.emptyList) RunWith(org.junit.runner.RunWith) AggregateOperations(com.hazelcast.jet.aggregate.AggregateOperations) Processors(com.hazelcast.jet.core.processor.Processors) Test(org.junit.Test) TimestampKind(com.hazelcast.jet.core.TimestampKind) Category(org.junit.experimental.categories.Category) SupplierEx(com.hazelcast.function.SupplierEx) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) TestSupport(com.hazelcast.jet.core.test.TestSupport) Functions.entryKey(com.hazelcast.function.Functions.entryKey) Util.entry(com.hazelcast.jet.Util.entry) Arrays.asList(java.util.Arrays.asList) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Entry(java.util.Map.Entry) SlidingWindowPolicy.tumblingWinPolicy(com.hazelcast.jet.core.SlidingWindowPolicy.tumblingWinPolicy) Entry(java.util.Map.Entry) SupplierEx(com.hazelcast.function.SupplierEx) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test)

Aggregations

Functions (com.hazelcast.function.Functions)1 Functions.entryKey (com.hazelcast.function.Functions.entryKey)1 SupplierEx (com.hazelcast.function.SupplierEx)1 Util.entry (com.hazelcast.jet.Util.entry)1 AggregateOperations (com.hazelcast.jet.aggregate.AggregateOperations)1 AggregateOperations.aggregateOperation2 (com.hazelcast.jet.aggregate.AggregateOperations.aggregateOperation2)1 SlidingWindowPolicy.tumblingWinPolicy (com.hazelcast.jet.core.SlidingWindowPolicy.tumblingWinPolicy)1 TimestampKind (com.hazelcast.jet.core.TimestampKind)1 Processors (com.hazelcast.jet.core.processor.Processors)1 TestSupport (com.hazelcast.jet.core.test.TestSupport)1 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 RunWith (org.junit.runner.RunWith)1