Search in sources :

Example 16 with PlannerVertex

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

the class MapTransform 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(), mapP(mapFn()));
    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 17 with PlannerVertex

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

the class GroupTransform method addToDagTwoStage.

// ---------        ---------
// | source0 |  ... | sourceN |
// ---------        ---------
// |                |
// local            local
// partitioned      partitioned
// v                v
// --------------------
// |  accumulateByKeyP  |
// --------------------
// |
// distributed
// partitioned
// v
// ---------------
// | combineByKeyP |
// ---------------
private void addToDagTwoStage(Planner p) {
    List<FunctionEx<?, ? extends K>> groupKeyFns = this.groupKeyFns;
    Vertex v1 = p.dag.newVertex(name() + FIRST_STAGE_VERTEX_NAME_SUFFIX, accumulateByKeyP(groupKeyFns, aggrOp)).localParallelism(determinedLocalParallelism());
    PlannerVertex pv2 = p.addVertex(this, name(), determinedLocalParallelism(), combineByKeyP(aggrOp, mapToOutputFn));
    p.addEdges(this, v1, (e, ord) -> e.partitioned(groupKeyFns.get(ord), HASH_CODE));
    p.dag.edge(between(v1, pv2.v).distributed().partitioned(entryKey()));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) FunctionEx(com.hazelcast.function.FunctionEx) BiFunctionEx(com.hazelcast.function.BiFunctionEx)

Example 18 with PlannerVertex

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

the class MergeTransform 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(), mapP(identity()));
    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 19 with PlannerVertex

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

the class PeekTransform method addToDag.

@Override
public void addToDag(Planner p, Context context) {
    determineLocalParallelism(LOCAL_PARALLELISM_USE_DEFAULT, context, p.isPreserveOrder());
    PlannerVertex peekedPv = p.xform2vertex.get(this.upstream().get(0));
    // Peeking transform doesn't add a vertex, so point to the upstream
    // transform's vertex:
    p.xform2vertex.put(this, peekedPv);
    peekedPv.v.updateMetaSupplier(sup -> peekOutputP(toStringFn, shouldLogFn, sup));
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex)

Example 20 with PlannerVertex

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

the class SinkTransform method addToDag.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addToDag(Planner p, Context context) {
    determineLocalParallelism(sink.metaSupplier().preferredLocalParallelism(), context, false);
    PlannerVertex pv = p.addVertex(this, name(), determinedLocalParallelism(), adaptingMetaSupplier(sink.metaSupplier(), ordinalsToAdapt));
    p.addEdges(this, pv.v, (e, ord) -> {
        // all the items will be routed to the member with the partition key
        if (sink.getType() == TOTAL_PARALLELISM_ONE) {
            e.allToOne(sink.name()).distributed();
        } else {
            if (sink.getType().isPartitioned()) {
                FunctionEx keyFn = sink.partitionKeyFunction();
                if (arrayIndexOf(ord, ordinalsToAdapt) >= 0) {
                    keyFn = ADAPT_TO_JET_EVENT.adaptKeyFn(keyFn);
                }
                e.partitioned(keyFn, Partitioner.defaultPartitioner());
            }
            if (sink.getType().isDistributed()) {
                e.distributed();
            }
        }
    });
}
Also used : PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) FunctionEx(com.hazelcast.function.FunctionEx)

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