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;
}
Aggregations