Search in sources :

Example 1 with WatermarkEmissionPolicy

use of com.hazelcast.jet.core.WatermarkEmissionPolicy in project hazelcast-jet by hazelcast.

the class Planner method createDag.

DAG createDag() {
    Map<Transform, List<Transform>> adjacencyMap = pipeline.adjacencyMap();
    validateNoLeakage(adjacencyMap);
    // Calculate greatest common denominator of frame lengths from all transforms in the pipeline
    long frameSizeGcd = Util.gcd(adjacencyMap.keySet().stream().map(Transform::watermarkFrameSize).filter(frameSize -> frameSize > 0).mapToLong(i -> i).toArray());
    WatermarkEmissionPolicy emitPolicy = frameSizeGcd > 0 ? emitByFrame(tumblingWinPolicy(frameSizeGcd)) : noThrottling();
    // Replace emission policy
    for (Transform transform : adjacencyMap.keySet()) {
        if (transform instanceof StreamSourceTransform) {
            StreamSourceTransform t = (StreamSourceTransform) transform;
            if (t.getWmParams() != null) {
                t.setWmGenerationParams(t.getWmParams().withEmitPolicy(emitPolicy));
            }
        } else if (transform instanceof TimestampTransform) {
            TimestampTransform t = (TimestampTransform) transform;
            t.setWmGenerationParams(t.getWmGenParams().withEmitPolicy(emitPolicy));
        }
    }
    Iterable<Transform> sorted = topologicalSort(adjacencyMap, Object::toString);
    for (Transform transform : sorted) {
        transform.addToDag(this);
    }
    return dag;
}
Also used : Processor(com.hazelcast.jet.core.Processor) HashMap(java.util.HashMap) HashSet(java.util.HashSet) SinkTransform(com.hazelcast.jet.impl.pipeline.transform.SinkTransform) Map(java.util.Map) WatermarkEmissionPolicy.noThrottling(com.hazelcast.jet.core.WatermarkEmissionPolicy.noThrottling) BiConsumer(java.util.function.BiConsumer) TimestampTransform(com.hazelcast.jet.impl.pipeline.transform.TimestampTransform) Edge.from(com.hazelcast.jet.core.Edge.from) DAG(com.hazelcast.jet.core.DAG) Edge(com.hazelcast.jet.core.Edge) TopologicalSorter.topologicalSort(com.hazelcast.jet.impl.TopologicalSorter.topologicalSort) Nonnull(javax.annotation.Nonnull) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) DistributedSupplier(com.hazelcast.jet.function.DistributedSupplier) WatermarkEmissionPolicy.emitByFrame(com.hazelcast.jet.core.WatermarkEmissionPolicy.emitByFrame) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) WatermarkEmissionPolicy(com.hazelcast.jet.core.WatermarkEmissionPolicy) Set(java.util.Set) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform) Consumer(java.util.function.Consumer) Vertex(com.hazelcast.jet.core.Vertex) Util(com.hazelcast.jet.impl.util.Util) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Entry(java.util.Map.Entry) StreamSourceTransform(com.hazelcast.jet.impl.pipeline.transform.StreamSourceTransform) SlidingWindowPolicy.tumblingWinPolicy(com.hazelcast.jet.core.SlidingWindowPolicy.tumblingWinPolicy) WatermarkEmissionPolicy(com.hazelcast.jet.core.WatermarkEmissionPolicy) StreamSourceTransform(com.hazelcast.jet.impl.pipeline.transform.StreamSourceTransform) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) SinkTransform(com.hazelcast.jet.impl.pipeline.transform.SinkTransform) TimestampTransform(com.hazelcast.jet.impl.pipeline.transform.TimestampTransform) Transform(com.hazelcast.jet.impl.pipeline.transform.Transform) StreamSourceTransform(com.hazelcast.jet.impl.pipeline.transform.StreamSourceTransform) TimestampTransform(com.hazelcast.jet.impl.pipeline.transform.TimestampTransform)

Aggregations

DAG (com.hazelcast.jet.core.DAG)1 Edge (com.hazelcast.jet.core.Edge)1 Edge.from (com.hazelcast.jet.core.Edge.from)1 Processor (com.hazelcast.jet.core.Processor)1 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)1 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)1 SlidingWindowPolicy.tumblingWinPolicy (com.hazelcast.jet.core.SlidingWindowPolicy.tumblingWinPolicy)1 Vertex (com.hazelcast.jet.core.Vertex)1 WatermarkEmissionPolicy (com.hazelcast.jet.core.WatermarkEmissionPolicy)1 WatermarkEmissionPolicy.emitByFrame (com.hazelcast.jet.core.WatermarkEmissionPolicy.emitByFrame)1 WatermarkEmissionPolicy.noThrottling (com.hazelcast.jet.core.WatermarkEmissionPolicy.noThrottling)1 DistributedSupplier (com.hazelcast.jet.function.DistributedSupplier)1 TopologicalSorter.topologicalSort (com.hazelcast.jet.impl.TopologicalSorter.topologicalSort)1 SinkTransform (com.hazelcast.jet.impl.pipeline.transform.SinkTransform)1 StreamSourceTransform (com.hazelcast.jet.impl.pipeline.transform.StreamSourceTransform)1 TimestampTransform (com.hazelcast.jet.impl.pipeline.transform.TimestampTransform)1 Transform (com.hazelcast.jet.impl.pipeline.transform.Transform)1 Util (com.hazelcast.jet.impl.util.Util)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1