pnowojski commented on a change in pull request #8731: [FLINK-11878][runtime] 
Implement the runtime handling of BoundedOneInput and BoundedMultiInput
URL: https://github.com/apache/flink/pull/8731#discussion_r295238102
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/OperatorChain.java
 ##########
 @@ -225,6 +233,46 @@ public void prepareSnapshotPreBarrier(long checkpointId) 
throws Exception {
                }
        }
 
+       /**
+        * Ends an input (specified by {@code inputId}) of the {@link 
StreamTask}. The {@code inputId}
+        * is numbered starting from 1, and `1` indicates the first input.
+        *
+        * @param inputId The ID of the input.
+        * @throws Exception if some exception happens in the endInput function 
of an operator.
+        */
+       public void endInput(int inputId) throws Exception {
+               if (isAllInputsFinished) {
+                       return;
+               }
+
+               if (headOperator instanceof TwoInputStreamOperator) {
+                       if ((finishedInputs & inputId) > 0) {
+                               return;
+                       }
+
+                       if (headOperator instanceof BoundedMultiInput) {
+                               ((BoundedMultiInput) 
headOperator).endInput(inputId);
+                       }
+                       finishedInputs |= 1 << (inputId - 1);
+                       isAllInputsFinished = (finishedInputs & 3) == 3;
+               } else {
+                       // here, the head operator is a stream source or an 
one-input stream operator,
+                       // so all inputs are finished
+                       finishedInputs = -1;
 
 Review comment:
   For `TwoInputStreamOperator` case you do not set `finishedInputs = -1`, so 
this is an inconsistency.
   
   I think in both cases, you could add logic 
   ```
   boolean InputSelection#areAllInputsSelected() {
     inputMask == -1;
   }
   ```
   and use it instead of having this separate `isAllInputsFinished` field.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to