Search in sources :

Example 26 with Pipeline

use of com.hazelcast.jet.pipeline.Pipeline in project hazelcast-jet-reference-manual by hazelcast.

the class BuildComputation method s15.

static void s15() {
    // tag::s15[]
    Pipeline p = Pipeline.create();
    p.<Tweet>drawFrom(Sources.mapJournal("tweets", mapPutEvents(), mapEventNewValue(), START_FROM_CURRENT)).addTimestamps(Tweet::timestamp, TimeUnit.SECONDS.toMillis(5)).flatMap(tweet -> traverseArray(tweet.text().toLowerCase().split("\\W+"))).filter(word -> !word.isEmpty()).window(sliding(MINUTES.toMillis(1), SECONDS.toMillis(1))).groupingKey(wholeItem()).aggregate(counting()).drainTo(Sinks.list("result"));
// end::s15[]
}
Also used : AggregateOperations.counting(com.hazelcast.jet.aggregate.AggregateOperations.counting) Delivery(datamodel.Delivery) MINUTES(java.util.concurrent.TimeUnit.MINUTES) Tweet(datamodel.Tweet) JoinClause.joinMapEntries(com.hazelcast.jet.pipeline.JoinClause.joinMapEntries) DistributedFunctions.wholeItem(com.hazelcast.jet.function.DistributedFunctions.wholeItem) BatchStage(com.hazelcast.jet.pipeline.BatchStage) Util.mapEventNewValue(com.hazelcast.jet.Util.mapEventNewValue) PageVisit(datamodel.PageVisit) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) START_FROM_CURRENT(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_CURRENT) DAG(com.hazelcast.jet.core.DAG) StreamHashJoinBuilder(com.hazelcast.jet.pipeline.StreamHashJoinBuilder) Tuple2(com.hazelcast.jet.datamodel.Tuple2) AddToCart(datamodel.AddToCart) Tuple3(com.hazelcast.jet.datamodel.Tuple3) StreamStage(com.hazelcast.jet.pipeline.StreamStage) StageWithGrouping(com.hazelcast.jet.pipeline.StageWithGrouping) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Market(datamodel.Market) AggregateOperation2(com.hazelcast.jet.aggregate.AggregateOperation2) Tag(com.hazelcast.jet.datamodel.Tag) Sinks(com.hazelcast.jet.pipeline.Sinks) Payment(datamodel.Payment) Sources(com.hazelcast.jet.pipeline.Sources) Product(datamodel.Product) TimeUnit(java.util.concurrent.TimeUnit) BagsByTag(com.hazelcast.jet.datamodel.BagsByTag) WindowDefinition.sliding(com.hazelcast.jet.pipeline.WindowDefinition.sliding) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Traversers.traverseArray(com.hazelcast.jet.Traversers.traverseArray) ItemsByTag(com.hazelcast.jet.datamodel.ItemsByTag) Entry(java.util.Map.Entry) Trade(datamodel.Trade) TweetWord(datamodel.TweetWord) Util.mapPutEvents(com.hazelcast.jet.Util.mapPutEvents) AggregateOperations.toBagsByTag(com.hazelcast.jet.aggregate.AggregateOperations.toBagsByTag) GroupAggregateBuilder(com.hazelcast.jet.pipeline.GroupAggregateBuilder) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Broker(datamodel.Broker) Tweet(datamodel.Tweet) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 27 with Pipeline

use of com.hazelcast.jet.pipeline.Pipeline in project hazelcast-jet-reference-manual by hazelcast.

the class BuildComputation method s3.

static void s3() {
    // tag::s3[]
    Pipeline p = Pipeline.create();
    BatchStage<String> src = p.drawFrom(Sources.list("src"));
    src.map(String::toUpperCase).drainTo(Sinks.list("uppercase"));
    src.map(String::toLowerCase).drainTo(Sinks.list("lowercase"));
// end::s3[]
}
Also used : Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 28 with Pipeline

use of com.hazelcast.jet.pipeline.Pipeline 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[]
}
Also used : AggregateOperations.counting(com.hazelcast.jet.aggregate.AggregateOperations.counting) Delivery(datamodel.Delivery) MINUTES(java.util.concurrent.TimeUnit.MINUTES) Tweet(datamodel.Tweet) JoinClause.joinMapEntries(com.hazelcast.jet.pipeline.JoinClause.joinMapEntries) DistributedFunctions.wholeItem(com.hazelcast.jet.function.DistributedFunctions.wholeItem) BatchStage(com.hazelcast.jet.pipeline.BatchStage) Util.mapEventNewValue(com.hazelcast.jet.Util.mapEventNewValue) PageVisit(datamodel.PageVisit) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) START_FROM_CURRENT(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_CURRENT) DAG(com.hazelcast.jet.core.DAG) StreamHashJoinBuilder(com.hazelcast.jet.pipeline.StreamHashJoinBuilder) Tuple2(com.hazelcast.jet.datamodel.Tuple2) AddToCart(datamodel.AddToCart) Tuple3(com.hazelcast.jet.datamodel.Tuple3) StreamStage(com.hazelcast.jet.pipeline.StreamStage) StageWithGrouping(com.hazelcast.jet.pipeline.StageWithGrouping) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Market(datamodel.Market) AggregateOperation2(com.hazelcast.jet.aggregate.AggregateOperation2) Tag(com.hazelcast.jet.datamodel.Tag) Sinks(com.hazelcast.jet.pipeline.Sinks) Payment(datamodel.Payment) Sources(com.hazelcast.jet.pipeline.Sources) Product(datamodel.Product) TimeUnit(java.util.concurrent.TimeUnit) BagsByTag(com.hazelcast.jet.datamodel.BagsByTag) WindowDefinition.sliding(com.hazelcast.jet.pipeline.WindowDefinition.sliding) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Traversers.traverseArray(com.hazelcast.jet.Traversers.traverseArray) ItemsByTag(com.hazelcast.jet.datamodel.ItemsByTag) Entry(java.util.Map.Entry) Trade(datamodel.Trade) TweetWord(datamodel.TweetWord) Util.mapPutEvents(com.hazelcast.jet.Util.mapPutEvents) AggregateOperations.toBagsByTag(com.hazelcast.jet.aggregate.AggregateOperations.toBagsByTag) GroupAggregateBuilder(com.hazelcast.jet.pipeline.GroupAggregateBuilder) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Broker(datamodel.Broker) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 29 with Pipeline

use of com.hazelcast.jet.pipeline.Pipeline in project hazelcast-jet-reference-manual by hazelcast.

the class Considerations method s8.

static void s8() {
    // tag::s8[]
    Pipeline p = Pipeline.create();
    BatchStage<Long> src = p.drawFrom(Sources.list("input"));
    ContextFactory<DateTimeFormatter> contextFactory = // <1>
    ContextFactory.withCreateFn(x -> DateTimeFormatter.ofPattern("HH:mm:ss.SSS").withZone(ZoneId.systemDefault()));
    // <2>
    src.mapUsingContext(// <2>
    contextFactory, // <3>
    (formatter, tstamp) -> formatter.format(Instant.ofEpochMilli(tstamp)));
// end::s8[]
}
Also used : DateTimeFormatter(java.time.format.DateTimeFormatter) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 30 with Pipeline

use of com.hazelcast.jet.pipeline.Pipeline 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[]
}
Also used : EventJournalCacheEvent(com.hazelcast.cache.journal.EventJournalCacheEvent) JetConfig(com.hazelcast.jet.config.JetConfig) StreamStage(com.hazelcast.jet.pipeline.StreamStage) Person(datamodel.Person) JetInstance(com.hazelcast.jet.JetInstance) DistributedFunctions(com.hazelcast.jet.function.DistributedFunctions) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Sinks(com.hazelcast.jet.pipeline.Sinks) IListJet(com.hazelcast.jet.IListJet) EntryBackupProcessor(com.hazelcast.map.EntryBackupProcessor) ArrayList(java.util.ArrayList) BatchStage(com.hazelcast.jet.pipeline.BatchStage) Sources(com.hazelcast.jet.pipeline.Sources) EntryProcessor(com.hazelcast.map.EntryProcessor) Entry(java.util.Map.Entry) START_FROM_CURRENT(com.hazelcast.jet.pipeline.JournalInitialPosition.START_FROM_CURRENT) ClientConfig(com.hazelcast.client.config.ClientConfig) IList(com.hazelcast.core.IList) Jet(com.hazelcast.jet.Jet) DistributedFunction(com.hazelcast.jet.function.DistributedFunction) EventJournalMapEvent(com.hazelcast.map.journal.EventJournalMapEvent) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Aggregations

Pipeline (com.hazelcast.jet.pipeline.Pipeline)379 Test (org.junit.Test)300 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)142 QuickTest (com.hazelcast.test.annotation.QuickTest)142 Job (com.hazelcast.jet.Job)125 Sinks (com.hazelcast.jet.pipeline.Sinks)107 Category (org.junit.experimental.categories.Category)100 HazelcastInstance (com.hazelcast.core.HazelcastInstance)94 JobConfig (com.hazelcast.jet.config.JobConfig)86 Assert.assertEquals (org.junit.Assert.assertEquals)73 List (java.util.List)72 NightlyTest (com.hazelcast.test.annotation.NightlyTest)65 Before (org.junit.Before)64 Entry (java.util.Map.Entry)61 TestSources (com.hazelcast.jet.pipeline.test.TestSources)58 Assert.assertTrue (org.junit.Assert.assertTrue)50 Sources (com.hazelcast.jet.pipeline.Sources)49 IOException (java.io.IOException)48 BeforeClass (org.junit.BeforeClass)48 SimpleTestInClusterSupport (com.hazelcast.jet.SimpleTestInClusterSupport)42