snuyanzin commented on code in PR #26434:
URL: https://github.com/apache/flink/pull/26434#discussion_r2425344904


##########
flink-runtime/src/main/java/org/apache/flink/streaming/api/graph/StreamGraphGenerator.java:
##########
@@ -438,16 +439,26 @@ private boolean shouldExecuteInBatchMode() {
     }
 
     private boolean existsUnboundedSource() {
+        final HashSet<Integer> checkedTransformations = new HashSet<>();
         return transformations.stream()
                 .anyMatch(
                         transformation ->
-                                isUnboundedSource(transformation)
+                                isUnboundedSource(transformation, 
checkedTransformations)
                                         || 
transformation.getTransitivePredecessors().stream()
-                                                
.anyMatch(this::isUnboundedSource));
+                                                .anyMatch(
+                                                        t ->
+                                                                
isUnboundedSource(
+                                                                        t,
+                                                                        
checkedTransformations)));
     }
 
-    private boolean isUnboundedSource(final Transformation<?> transformation) {
+    private boolean isUnboundedSource(
+            final Transformation<?> transformation, HashSet<Integer> 
checkedTransformations) {
         checkNotNull(transformation);
+        if (checkedTransformations.contains(transformation.getId())) {
+            return false;
+        }
+        checkedTransformations.add(transformation.getId());

Review Comment:
   1. why do we need it?
   the checks for `instanceof` and `getBoundedness` are cheap, so would be 
great to see some measurements first to be sure that we really improve 
something here
   
   2. what is the reason to have `HashSet` in args instead of `Set`?
   3. you calculate hash 2 times: first while contains, second while add



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to