use of com.hazelcast.jet.pipeline.Sources 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);
}
use of com.hazelcast.jet.pipeline.Sources in project hazelcast-jet-reference-manual by hazelcast.
the class BuildComputation method s5.
static void s5() {
// tag::s5[]
Pipeline p = Pipeline.create();
p.drawFrom(Sources.<String>list("text")).flatMap(line -> traverseArray(line.toLowerCase().split("\\W+"))).filter(word -> !word.isEmpty()).aggregate(counting()).drainTo(Sinks.list("result"));
// end::s5[]
}
use of com.hazelcast.jet.pipeline.Sources in project hazelcast-jet-reference-manual by hazelcast.
the class BuildComputation method s6.
static void s6() {
// tag::s6[]
Pipeline p = Pipeline.create();
p.drawFrom(Sources.<String>list("text")).flatMap(line -> traverseArray(line.toLowerCase().split("\\W+"))).filter(word -> !word.isEmpty()).groupingKey(wholeItem()).aggregate(counting()).drainTo(Sinks.list("result"));
// end::s6[]
}
use of com.hazelcast.jet.pipeline.Sources in project hazelcast-jet-reference-manual by hazelcast.
the class ImdgConnectors method s4.
static void s4() {
// tag::s4[]
Pipeline pipeline = Pipeline.create();
pipeline.drawFrom(Sources.<String, Long>map("inMap")).drainTo(Sinks.<Entry<String, Long>, String, Long>mapWithUpdating("outMap", Entry::getKey, (oldV, item) -> (oldV != null ? oldV : 0L) + item.getValue()));
// end::s4[]
}
use of com.hazelcast.jet.pipeline.Sources in project hazelcast-jet-reference-manual by hazelcast.
the class ImdgConnectors method s3.
static void s3() {
// tag::s3[]
Pipeline pipeline = Pipeline.create();
pipeline.drawFrom(Sources.<String, Long>map("inMap")).drainTo(Sinks.mapWithMerging("outMap", Entry::getKey, Entry::getValue, (oldValue, newValue) -> oldValue + newValue));
// end::s3[]
}
Aggregations