rionmonster commented on code in PR #29570:
URL: https://github.com/apache/flink/pull/29570#discussion_r4379933602


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/stream/StreamingSemiAntiJoinOperator.java:
##########
@@ -109,29 +122,37 @@ public void open() throws Exception {
     @Override
     public void processElement1(StreamRecord<RowData> element) throws 
Exception {
         RowData input = element.getValue();
+        boolean isAccumulateMsg = RowDataUtil.isAccumulateMsg(input);
+        RowKind inputRowKind = input.getRowKind();
+        input.setRowKind(RowKind.INSERT); // erase RowKind for later state 
updating
+
+        final RowData record =
+                isAccumulateMsg
+                        ? input
+                        : retractedRecord(input, inputRowKind, 
leftRecordStateView, true);
         Iterator<OuterRecord> associatedRecords =
                 AbstractStreamingJoinOperator.iterator(
-                        input, true, rightRecordStateView, joinCondition);
-        if (!associatedRecords.hasNext()) {
-            if (isAntiJoin) {
-                collector.collect(input);
-            }
-        } else { // there are matched rows on the other side
-            if (!isAntiJoin) {
-                collector.collect(input);
+                        record, true, rightRecordStateView, joinCondition);
+        final boolean recordIsSent = isAntiJoin != associatedRecords.hasNext();
+        // count before the state of the other side is read again, which may 
reuse the iterable
+        final int numOfAssociations = isAccumulateMsg ? 
Iterators.size(associatedRecords) : 0;
+        if (isAccumulateMsg && !recordIsSent) {
+            final RowData replacedRecord = replacedRecord(input, 
leftRecordStateView, true, false);
+            if (replacedRecord != null && isSent(replacedRecord)) {

Review Comment:
   Done!



-- 
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