zhijiangW commented on a change in pull request #9478: [FLINK-13766][task]
Refactor the implementation of StreamInputProcessor based on
StreamTaskInput#emitNext
URL: https://github.com/apache/flink/pull/9478#discussion_r323281703
##########
File path:
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/StreamTwoInputProcessor.java
##########
@@ -171,30 +193,23 @@ public boolean processInput() throws Exception {
}
lastReadInputIndex = readingInputIndex;
- StreamElement recordOrMark;
+ InputStatus status;
if (readingInputIndex == 0) {
- recordOrMark = input1.pollNextNullable();
- if (recordOrMark != null) {
- processElement1(recordOrMark,
input1.getLastChannel());
- }
- checkFinished(input1, lastReadInputIndex);
+ status = input1.emitNext(output1);
} else {
- recordOrMark = input2.pollNextNullable();
- if (recordOrMark != null) {
- processElement2(recordOrMark,
input2.getLastChannel());
- }
- checkFinished(input2, lastReadInputIndex);
+ status = input2.emitNext(output2);
}
+ checkFinished(status, lastReadInputIndex);
- if (recordOrMark == null) {
+ if (status != InputStatus.MORE_AVAILABLE) {
inputSelectionHandler.setUnavailableInput(readingInputIndex);
}
- return recordOrMark != null;
+ return status == InputStatus.MORE_AVAILABLE;
}
- private void checkFinished(StreamTaskInput input, int inputIndex)
throws Exception {
- if (input.isFinished()) {
+ private void checkFinished(InputStatus status, int inputIndex) throws
Exception {
+ if (status == InputStatus.END_OF_INPUT) {
Review comment:
The motivation of moving `inputSelectionHandler.setUnavailableInput` before
reading is only for consistent logics for better understanding, not related to
whether to return actual current status.
In the past, `inputSelectionHandler.setUnavailableInput` was done after
reading, and `inputSelectionHandler.setAvailableInput` was done before reading.
From my understanding, no matter with `setUnavailableInput` or
`setAvailableInput` for `inputSelectionHandler` , it is only used for selecting
the next expected input index before reading, so we should integrate them
together either before or after reading. It is hard to understand or trace the
logic if spreading it anywhere.
----------------------------------------------------------------
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