Search in sources :

Example 1 with IList

use of com.hazelcast.core.IList in project hazelcast-jet by hazelcast.

the class WindowGroupTransform_IntegrationTest method testSliding_groupingFirst_withNonStreamingSource.

@Test
public void testSliding_groupingFirst_withNonStreamingSource() {
    IList<Entry<Long, String>> list = instance.getList("source");
    list.add(entry(0L, "foo"));
    list.add(entry(1L, "bar"));
    list.add(entry(2L, "baz"));
    list.add(entry(3L, "booze"));
    Pipeline p = Pipeline.create();
    p.drawFrom(Sources.<Entry<Long, String>>list("source")).addTimestamps(Entry::getKey, 0).groupingKey(entry -> entry.getValue().charAt(0)).window(WindowDefinition.tumbling(2)).aggregate(toSet()).drainTo(Sinks.list("sink"));
    instance.newJob(p).join();
    assertTrueEventually(() -> {
        assertEquals(set(new TimestampedEntry<>(2, 'f', set(entry(0L, "foo"))), new TimestampedEntry<>(2, 'b', set(entry(1L, "bar"))), new TimestampedEntry<>(4, 'b', set(entry(2L, "baz"), entry(3L, "booze")))), new HashSet<>(instance.getHazelcastInstance().getList("sink")));
    }, 5);
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) GroupProperty(com.hazelcast.spi.properties.GroupProperty) RunWith(org.junit.runner.RunWith) EventJournalConfig(com.hazelcast.config.EventJournalConfig) TestUtil.set(com.hazelcast.jet.core.TestUtil.set) HashSet(java.util.HashSet) ThreeBags(com.hazelcast.jet.datamodel.ThreeBags) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) SlidingWindowDef(com.hazelcast.jet.pipeline.SlidingWindowDef) Util.entry(com.hazelcast.jet.Util.entry) Arrays.asList(java.util.Arrays.asList) WindowGroupAggregateBuilder(com.hazelcast.jet.pipeline.WindowGroupAggregateBuilder) StageWithGroupingAndWindow(com.hazelcast.jet.pipeline.StageWithGroupingAndWindow) IList(com.hazelcast.core.IList) Before(org.junit.Before) AggregateOperations.toThreeBags(com.hazelcast.jet.aggregate.AggregateOperations.toThreeBags) JetConfig(com.hazelcast.jet.config.JetConfig) WindowDefinition(com.hazelcast.jet.pipeline.WindowDefinition) Pipeline(com.hazelcast.jet.pipeline.Pipeline) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) AggregateOperations.toTwoBags(com.hazelcast.jet.aggregate.AggregateOperations.toTwoBags) AggregateOperations.toSet(com.hazelcast.jet.aggregate.AggregateOperations.toSet) Tag(com.hazelcast.jet.datamodel.Tag) Sinks(com.hazelcast.jet.pipeline.Sinks) Test(org.junit.Test) START_FROM_OLDEST(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_OLDEST) ParallelTest(com.hazelcast.test.annotation.ParallelTest) Category(org.junit.experimental.categories.Category) Sources(com.hazelcast.jet.pipeline.Sources) IMap(com.hazelcast.core.IMap) JournalInitialPosition(com.hazelcast.jet.pipeline.JournalInitialPosition) StreamStageWithGrouping(com.hazelcast.jet.pipeline.StreamStageWithGrouping) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Entry(java.util.Map.Entry) TwoBags(com.hazelcast.jet.datamodel.TwoBags) Assert.assertEquals(org.junit.Assert.assertEquals) TimestampedEntry(com.hazelcast.jet.datamodel.TimestampedEntry) WindowResult(com.hazelcast.jet.datamodel.WindowResult) TestSupport.listToString(com.hazelcast.jet.core.test.TestSupport.listToString) Entry(java.util.Map.Entry) TimestampedEntry(com.hazelcast.jet.datamodel.TimestampedEntry) TimestampedEntry(com.hazelcast.jet.datamodel.TimestampedEntry) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with IList

use of com.hazelcast.core.IList in project hazelcast-jet by hazelcast.

the class SkipTest method sourceMap.

@Test
public void sourceMap() {
    int skip = 10;
    IList list = streamMap().skip(skip).collect(DistributedCollectors.toIList(randomString()));
    assertEquals(COUNT - skip, list.size());
}
Also used : IList(com.hazelcast.core.IList) Test(org.junit.Test)

Example 3 with IList

use of com.hazelcast.core.IList in project hazelcast-jet by hazelcast.

the class SkipTest method intermediateOperation_sourceMap.

@Test
public void intermediateOperation_sourceMap() {
    int skip = 10;
    IList list = streamMap().map(Entry::getValue).skip(skip).collect(DistributedCollectors.toIList(randomString()));
    assertEquals(COUNT - skip, list.size());
}
Also used : Entry(java.util.Map.Entry) IList(com.hazelcast.core.IList) Test(org.junit.Test)

Example 4 with IList

use of com.hazelcast.core.IList in project hazelcast-jet by hazelcast.

the class LimitTest method intermediateOperation_sourceMap.

@Test
public void intermediateOperation_sourceMap() {
    int limit = 10;
    IList list = streamMap().map(Entry::getValue).limit(limit).collect(DistributedCollectors.toIList(randomString()));
    assertEquals(limit, list.size());
}
Also used : Entry(java.util.Map.Entry) IList(com.hazelcast.core.IList) Test(org.junit.Test)

Example 5 with IList

use of com.hazelcast.core.IList in project hazelcast-jet by hazelcast.

the class LimitTest method sourceMap.

@Test
public void sourceMap() {
    int limit = 10;
    IList list = streamMap().limit(limit).collect(DistributedCollectors.toIList(randomString()));
    assertEquals(limit, list.size());
}
Also used : IList(com.hazelcast.core.IList) Test(org.junit.Test)

Aggregations

IList (com.hazelcast.core.IList)12 Test (org.junit.Test)10 Entry (java.util.Map.Entry)6 JetInstance (com.hazelcast.jet.JetInstance)2 JetConfig (com.hazelcast.jet.config.JetConfig)2 Pipeline (com.hazelcast.jet.pipeline.Pipeline)2 Sinks (com.hazelcast.jet.pipeline.Sinks)2 Sources (com.hazelcast.jet.pipeline.Sources)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 EventJournalCacheEvent (com.hazelcast.cache.journal.EventJournalCacheEvent)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 EventJournalConfig (com.hazelcast.config.EventJournalConfig)1 IMap (com.hazelcast.core.IMap)1 IListJet (com.hazelcast.jet.IListJet)1 Jet (com.hazelcast.jet.Jet)1 Util.entry (com.hazelcast.jet.Util.entry)1 AggregateOperation (com.hazelcast.jet.aggregate.AggregateOperation)1 AggregateOperations.toSet (com.hazelcast.jet.aggregate.AggregateOperations.toSet)1 AggregateOperations.toThreeBags (com.hazelcast.jet.aggregate.AggregateOperations.toThreeBags)1 AggregateOperations.toTwoBags (com.hazelcast.jet.aggregate.AggregateOperations.toTwoBags)1