Search in sources :

Example 1 with Delivery

use of datamodel.Delivery in project hazelcast-jet-reference-manual by hazelcast.

the class BuildComputation method s9.

// end::s8[]
static void s9() {
    // tag::s9[]
    Pipeline p = Pipeline.create();
    // Create three source streams
    StageWithGrouping<PageVisit, Integer> pageVisits = p.drawFrom(Sources.<PageVisit>list("pageVisit")).groupingKey(PageVisit::userId);
    StageWithGrouping<AddToCart, Integer> addToCarts = p.drawFrom(Sources.<AddToCart>list("addToCart")).groupingKey(AddToCart::userId);
    StageWithGrouping<Payment, Integer> payments = p.drawFrom(Sources.<Payment>list("payment")).groupingKey(Payment::userId);
    StageWithGrouping<Delivery, Integer> deliveries = p.drawFrom(Sources.<Delivery>list("delivery")).groupingKey(Delivery::userId);
    // Obtain a builder object for the co-group transform
    GroupAggregateBuilder<PageVisit, Integer> builder = pageVisits.aggregateBuilder();
    Tag<PageVisit> visitTag = builder.tag0();
    // Add the co-grouped streams to the builder.
    Tag<AddToCart> cartTag = builder.add(addToCarts);
    Tag<Payment> payTag = builder.add(payments);
    Tag<Delivery> deliveryTag = builder.add(deliveries);
    // Build the co-group transform. The aggregate operation collects all
    // the stream items inside an accumulator class called BagsByTag.
    BatchStage<Entry<Integer, BagsByTag>> coGrouped = builder.build(toBagsByTag(visitTag, cartTag, payTag, deliveryTag));
// end::s9[]
}
Also used : PageVisit(datamodel.PageVisit) AddToCart(datamodel.AddToCart) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Payment(datamodel.Payment) Entry(java.util.Map.Entry) Delivery(datamodel.Delivery)

Aggregations

Pipeline (com.hazelcast.jet.pipeline.Pipeline)1 AddToCart (datamodel.AddToCart)1 Delivery (datamodel.Delivery)1 PageVisit (datamodel.PageVisit)1 Payment (datamodel.Payment)1 Entry (java.util.Map.Entry)1