Search in sources :

Example 1 with DistributedStream

use of com.hazelcast.jet.stream.DistributedStream in project hazelcast-jet-reference-manual by hazelcast.

the class JUS method s4.

static void s4() {
    JetInstance jet = Jet.newJetInstance();
    // tag::s4[]
    IMap<String, Long> counts = DistributedStream.<String>fromList(jet.getList("text")).flatMap(line -> Stream.of(line.toLowerCase().split("\\W+"))).filter(word -> !word.isEmpty()).collect(DistributedCollectors.groupingByToIMap("counts", wholeItem(), DistributedCollectors.counting()));
// end::s4[]
}
Also used : Arrays(java.util.Arrays) JetInstance(com.hazelcast.jet.JetInstance) IMapJet(com.hazelcast.jet.IMapJet) Collectors(java.util.stream.Collectors) DistributedFunctions.wholeItem(com.hazelcast.jet.function.DistributedFunctions.wholeItem) Sources(com.hazelcast.jet.pipeline.Sources) IMap(com.hazelcast.core.IMap) DistributedCollectors(com.hazelcast.jet.stream.DistributedCollectors) Stream(java.util.stream.Stream) Map(java.util.Map) IList(com.hazelcast.core.IList) DistributedStream(com.hazelcast.jet.stream.DistributedStream) Jet(com.hazelcast.jet.Jet) DistributedCollectors.toMap(com.hazelcast.jet.stream.DistributedCollectors.toMap) JetInstance(com.hazelcast.jet.JetInstance)

Aggregations

IList (com.hazelcast.core.IList)1 IMap (com.hazelcast.core.IMap)1 IMapJet (com.hazelcast.jet.IMapJet)1 Jet (com.hazelcast.jet.Jet)1 JetInstance (com.hazelcast.jet.JetInstance)1 DistributedFunctions.wholeItem (com.hazelcast.jet.function.DistributedFunctions.wholeItem)1 Sources (com.hazelcast.jet.pipeline.Sources)1 DistributedCollectors (com.hazelcast.jet.stream.DistributedCollectors)1 DistributedCollectors.toMap (com.hazelcast.jet.stream.DistributedCollectors.toMap)1 DistributedStream (com.hazelcast.jet.stream.DistributedStream)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1