Search in sources :

Example 31 with Pipeline

use of com.hazelcast.jet.pipeline.Pipeline 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[]
}
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)

Example 32 with Pipeline

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

the class ImdgConnectors method s15.

static void s15() {
    // tag::s15[]
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getGroupConfig().setName("myGroup").setPassword("pAssw0rd");
    clientConfig.getNetworkConfig().addAddress("node1.mydomain.com", "node2.mydomain.com");
    Pipeline p = Pipeline.create();
    p.drawFrom(Sources.remoteList("inputlist", clientConfig)).drainTo(Sinks.remoteList("outputList", clientConfig));
// end::s15[]
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 33 with Pipeline

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

the class ImplementAggregation method s2.

static void s2() {
    // tag::s2[]
    Pipeline p = Pipeline.create();
    BatchStage<PageVisit> pageVisit = p.drawFrom(Sources.list("pageVisit"));
    BatchStage<AddToCart> addToCart = p.drawFrom(Sources.list("addToCart"));
    BatchStage<Payment> payment = p.drawFrom(Sources.list("payment"));
    AggregateOperation3<PageVisit, AddToCart, Payment, LongAccumulator[], long[]> aggrOp = AggregateOperation.withCreate(() -> new LongAccumulator[] { new LongAccumulator(), new LongAccumulator(), new LongAccumulator() }).<PageVisit>andAccumulate0((accs, pv) -> accs[0].add(pv.loadTime())).<AddToCart>andAccumulate1((accs, atc) -> accs[1].add(atc.quantity())).<Payment>andAccumulate2((accs, pm) -> accs[2].add(pm.amount())).andCombine((accs1, accs2) -> {
        accs1[0].add(accs2[0]);
        accs1[1].add(accs2[1]);
        accs1[2].add(accs2[2]);
    }).andFinish(accs -> new long[] { accs[0].get(), accs[1].get(), accs[2].get() });
    BatchStage<Entry<Integer, long[]>> coGrouped = pageVisit.groupingKey(PageVisit::userId).aggregate3(addToCart.groupingKey(AddToCart::userId), payment.groupingKey(Payment::userId), aggrOp);
// end::s2[]
}
Also used : LongLongAccumulator(com.hazelcast.jet.accumulator.LongLongAccumulator) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) BatchStage(com.hazelcast.jet.pipeline.BatchStage) Sources(com.hazelcast.jet.pipeline.Sources) LongLongAccumulator(com.hazelcast.jet.accumulator.LongLongAccumulator) PageVisit(datamodel.PageVisit) AggregateOperation(com.hazelcast.jet.aggregate.AggregateOperation) Pipeline(com.hazelcast.jet.pipeline.Pipeline) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Entry(java.util.Map.Entry) AggregateOperation3(com.hazelcast.jet.aggregate.AggregateOperation3) Payment(datamodel.Payment) AggregateOperation1(com.hazelcast.jet.aggregate.AggregateOperation1) AddToCart(datamodel.AddToCart) PageVisit(datamodel.PageVisit) Payment(datamodel.Payment) Entry(java.util.Map.Entry) AddToCart(datamodel.AddToCart) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 34 with Pipeline

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

the class ExpertZoneDag method s0.

// end::s1[]
static void s0() {
    Pipeline pipeline = Pipeline.create();
    // tag::s0[]
    DAG dag = pipeline.toDag();
// end::s0[]
}
Also used : DAG(com.hazelcast.jet.core.DAG) Pipeline(com.hazelcast.jet.pipeline.Pipeline)

Example 35 with Pipeline

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

the class FileAndSocket method s2.

static void s2() {
    // tag::s2[]
    Pipeline p = Pipeline.create();
    p.drawFrom(Sources.fileWatcher("/home/jet/input")).drainTo(Sinks.logger());
// end::s2[]
}
Also used : 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