Search in sources :

Example 26 with PlannerVertex

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

the class WindowGroupTransform method addSlidingWindowSingleStage.

// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// distributed    distributed
// partitioned    partitioned
// \              /
// ---\    /-----
// v  v
// ---------------------------
// | aggregateToSlidingWindowP |
// ---------------------------
private void addSlidingWindowSingleStage(Planner p, SlidingWindowDefinition wDef) {
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), aggregateToSlidingWindowP(keyFns, nCopies(keyFns.size(), (ToLongFunctionEx<JetEvent<?>>) JetEvent::timestamp), TimestampKind.EVENT, slidingWinPolicy(wDef.windowSize(), wDef.slideBy()), wDef.earlyResultsPeriod(), 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)

Example 27 with PlannerVertex

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

the class AggregateTransform method addToDagSingleStage.

// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// distributed    distributed
// all-to-one      all-to-one
// \              /
// ---\    /-----
// v  v
// ----------------
// |   aggregateP   | local parallelism = 1
// ----------------
private void addToDagSingleStage(Planner p) {
    determinedLocalParallelism(1);
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), aggregateP(aggrOp));
    p.addEdges(this, pv.v, edge -> edge.distributed().allToOne(name().hashCode()));
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex)

Example 28 with PlannerVertex

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

the class DistinctTransform method addToDag.

@Override
public void addToDag(Planner p, Context context) {
    String vertexName = name();
    determineLocalParallelism(LOCAL_PARALLELISM_USE_DEFAULT, context, false);
    Vertex v1 = p.dag.newVertex(vertexName + FIRST_STAGE_VERTEX_NAME_SUFFIX, distinctP(keyFn)).localParallelism(determinedLocalParallelism());
    PlannerVertex pv2 = p.addVertex(this, vertexName, determinedLocalParallelism(), distinctP(keyFn));
    p.addEdges(this, v1, (e, ord) -> e.partitioned(keyFn, HASH_CODE));
    p.dag.edge(between(v1, pv2.v).distributed().partitioned(keyFn));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex)

Example 29 with PlannerVertex

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

the class FlatMapTransform method addToDag.

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

Example 30 with PlannerVertex

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

the class HashJoinTransform method addToDag.

// ---------           ----------           ----------
// | primary |         | joined-1 |         | joined-2 |
// ---------           ----------           ----------
// |                   |                     |
// |              distributed          distributed
// |               broadcast            broadcast
// |                   v                     v
// |             -------------         -------------
// |            | collector-1 |       | collector-2 |
// |            | localPara=1 |       | localPara=1 |
// |             -------------         -------------
// |                   |                     |
// |                 local                 local
// local             broadcast             broadcast
// unicast           prioritized           prioritized
// ordinal 0           ordinal 1             ordinal 2
// \                   |                     |
// ----------------\  |   /----------------/
// v  v  v
// --------
// | joiner |
// --------
@Override
@SuppressWarnings("unchecked")
public void addToDag(Planner p, Context context) {
    determineLocalParallelism(LOCAL_PARALLELISM_USE_DEFAULT, context, p.isPreserveOrder());
    PlannerVertex primary = p.xform2vertex.get(this.upstream().get(0));
    List keyFns = toList(this.clauses, JoinClause::leftKeyFn);
    List<Tag> tags = this.tags;
    BiFunctionEx mapToOutputBiFn = this.mapToOutputBiFn;
    TriFunction mapToOutputTriFn = this.mapToOutputTriFn;
    // must be extracted to variable, probably because of serialization bug
    BiFunctionEx<List<Tag>, Object[], ItemsByTag> tupleToItems = tupleToItemsByTag(whereNullsNotAllowed);
    Vertex joiner = p.addVertex(this, name() + "-joiner", determinedLocalParallelism(), () -> new HashJoinP<>(keyFns, tags, mapToOutputBiFn, mapToOutputTriFn, tupleToItems)).v;
    Edge edgeToJoiner = from(primary.v, primary.nextAvailableOrdinal()).to(joiner, 0);
    if (p.isPreserveOrder()) {
        edgeToJoiner.isolated();
    } else {
        applyRebalancing(edgeToJoiner, this);
    }
    p.dag.edge(edgeToJoiner);
    String collectorName = name() + "-collector";
    int collectorOrdinal = 1;
    for (Transform fromTransform : tailList(this.upstream())) {
        PlannerVertex fromPv = p.xform2vertex.get(fromTransform);
        JoinClause<?, ?, ?, ?> clause = this.clauses.get(collectorOrdinal - 1);
        FunctionEx<Object, Object> getKeyFn = (FunctionEx<Object, Object>) clause.rightKeyFn();
        FunctionEx<Object, Object> projectFn = (FunctionEx<Object, Object>) clause.rightProjectFn();
        Vertex collector = p.dag.newVertex(collectorName + collectorOrdinal, () -> new HashJoinCollectP(getKeyFn, projectFn));
        collector.localParallelism(1);
        p.dag.edge(from(fromPv.v, fromPv.nextAvailableOrdinal()).to(collector, 0).distributed().broadcast());
        p.dag.edge(from(collector, 0).to(joiner, collectorOrdinal).broadcast().priority(-1));
        collectorOrdinal++;
    }
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) HashJoinCollectP(com.hazelcast.jet.impl.processor.HashJoinCollectP) HashJoinP(com.hazelcast.jet.impl.processor.HashJoinP) ItemsByTag(com.hazelcast.jet.datamodel.ItemsByTag) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) FunctionEx(com.hazelcast.function.FunctionEx) BiFunctionEx(com.hazelcast.function.BiFunctionEx) TriFunction(com.hazelcast.jet.function.TriFunction) Util.toList(com.hazelcast.jet.impl.util.Util.toList) List(java.util.List) Planner.tailList(com.hazelcast.jet.impl.pipeline.Planner.tailList) Tag(com.hazelcast.jet.datamodel.Tag) ItemsByTag(com.hazelcast.jet.datamodel.ItemsByTag) JoinClause(com.hazelcast.jet.pipeline.JoinClause) Edge(com.hazelcast.jet.core.Edge) BiFunctionEx(com.hazelcast.function.BiFunctionEx)

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