Search in sources :

Example 21 with PlannerVertex

use of com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex in project hazelcast by hazelcast.

the class TimestampTransform method addToDag.

@Override
public void addToDag(Planner p, Context context) {
    determineLocalParallelism(LOCAL_PARALLELISM_USE_DEFAULT, context, true);
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), insertWatermarksP(eventTimePolicy));
    p.addEdges(this, pv.v, Edge::isolated);
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) Edge(com.hazelcast.jet.core.Edge)

Example 22 with PlannerVertex

use of com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex in project hazelcast by hazelcast.

the class WindowAggregateTransform method addSessionWindow.

// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// distributed    distributed
// all-to-one      all-to-one
// \              /
// ---\    /-----
// v  v
// ---------------------------
// | aggregateToSessionWindowP | local parallelism = 1
// ---------------------------
private void addSessionWindow(Planner p, SessionWindowDefinition wDef) {
    determinedLocalParallelism(1);
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), aggregateToSessionWindowP(wDef.sessionTimeout(), wDef.earlyResultsPeriod(), nCopies(aggrOp.arity(), (ToLongFunctionEx<JetEvent<?>>) JetEvent::timestamp), nCopies(aggrOp.arity(), new ConstantFunctionEx<>(name().hashCode())), aggrOp, jetEventOfWindowResultFn()));
    p.addEdges(this, pv.v, edge -> edge.distributed().allToOne(name().hashCode()));
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) JetEvent(com.hazelcast.jet.impl.JetEvent)

Example 23 with PlannerVertex

use of com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex in project hazelcast by hazelcast.

the class WindowAggregateTransform method addSlidingWindowSingleStage.

// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// distributed    distributed
// all-to-one      all-to-one
// \              /
// ---\    /-----
// v  v
// ---------------------------
// | aggregateToSlidingWindowP | local parallelism = 1
// ---------------------------
private void addSlidingWindowSingleStage(Planner p, SlidingWindowDefinition wDef) {
    determinedLocalParallelism(1);
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), aggregateToSlidingWindowP(nCopies(aggrOp.arity(), new ConstantFunctionEx<>(name().hashCode())), nCopies(aggrOp.arity(), (ToLongFunctionEx<JetEvent<?>>) JetEvent::timestamp), TimestampKind.EVENT, slidingWinPolicy(wDef.windowSize(), wDef.slideBy()), wDef.earlyResultsPeriod(), aggrOp, jetEventOfWindowResultFn()));
    p.addEdges(this, pv.v, edge -> edge.distributed().allToOne(name().hashCode()));
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) JetEvent(com.hazelcast.jet.impl.JetEvent)

Example 24 with PlannerVertex

use of com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex in project hazelcast by hazelcast.

the class StreamSourceTransform method addToDag.

@Override
public void addToDag(Planner p, Context context) {
    if (emitsWatermarks || eventTimePolicy == null) {
        // Reached when the source either emits both JetEvents and watermarks
        // or neither. In these cases we don't have to insert watermarks.
        final ProcessorMetaSupplier metaSupplier = metaSupplierFn.apply(eventTimePolicy != null ? eventTimePolicy : noEventTime());
        determineLocalParallelism(metaSupplier.preferredLocalParallelism(), context, false);
        p.addVertex(this, name(), determinedLocalParallelism(), metaSupplier);
    } else {
        // ------------
        // |  sourceP   |
        // ------------
        // |
        // isolated
        // v
        // -------------
        // |  insertWmP  |
        // -------------
        String v1name = name();
        final ProcessorMetaSupplier metaSupplier = metaSupplierFn.apply(eventTimePolicy);
        determineLocalParallelism(metaSupplier.preferredLocalParallelism(), context, false);
        Vertex v1 = p.dag.newVertex(v1name, metaSupplier).localParallelism(determinedLocalParallelism());
        PlannerVertex pv2 = p.addVertex(this, v1name + "-add-timestamps", determinedLocalParallelism(), insertWatermarksP(eventTimePolicy));
        p.dag.edge(between(v1, pv2.v).isolated());
    }
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier)

Example 25 with PlannerVertex

use of com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex in project hazelcast by hazelcast.

the class WindowGroupTransform method addSessionWindow.

// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// distributed    distributed
// partitioned    partitioned
// \              /
// ---\    /-----
// v  v
// ---------------------------
// | aggregateToSessionWindowP |
// ---------------------------
private void addSessionWindow(Planner p, SessionWindowDefinition wDef) {
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), aggregateToSessionWindowP(wDef.sessionTimeout(), wDef.earlyResultsPeriod(), nCopies(keyFns.size(), (ToLongFunctionEx<JetEvent<?>>) JetEvent::timestamp), keyFns, aggrOp, jetEventOfKeyedWindowResultFn()));
    p.addEdges(this, pv.v, (e, ord) -> e.distributed().partitioned(keyFns.get(ord)));
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) JetEvent(com.hazelcast.jet.impl.JetEvent)

Aggregations

PlannerVertex (com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex)48 Vertex (com.hazelcast.jet.core.Vertex)14 Edge (com.hazelcast.jet.core.Edge)9 JetEvent (com.hazelcast.jet.impl.JetEvent)6 JetEvent (com.hazelcast.jet.impl.pipeline.JetEvent)6 SlidingWindowPolicy (com.hazelcast.jet.core.SlidingWindowPolicy)4 FunctionEx (com.hazelcast.function.FunctionEx)3 BiFunctionEx (com.hazelcast.function.BiFunctionEx)2 Tag (com.hazelcast.jet.datamodel.Tag)2 DistributedFunction (com.hazelcast.jet.function.DistributedFunction)2 Planner.tailList (com.hazelcast.jet.impl.pipeline.Planner.tailList)2 HashJoinCollectP (com.hazelcast.jet.impl.processor.HashJoinCollectP)2 HashJoinP (com.hazelcast.jet.impl.processor.HashJoinP)2 ConstantFunctionEx (com.hazelcast.jet.impl.util.ConstantFunctionEx)2 List (java.util.List)2 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)1 ItemsByTag (com.hazelcast.jet.datamodel.ItemsByTag)1 DistributedBiFunction (com.hazelcast.jet.function.DistributedBiFunction)1 DistributedTriFunction (com.hazelcast.jet.function.DistributedTriFunction)1 TriFunction (com.hazelcast.jet.function.TriFunction)1