tsreaper commented on a change in pull request #17570:
URL: https://github.com/apache/flink/pull/17570#discussion_r737100142



##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/rank/RetractableTopNFunction.java
##########
@@ -455,9 +464,18 @@ private boolean retractRecordWithoutRowNumber(
                     // sends the record if there is a record recently upgrades 
to Top-N
                     int index = Long.valueOf(rankEnd - nextRank).intValue();
                     List<RowData> inputs = dataState.get(key);
-                    RowData toAdd = inputs.get(index);
-                    collectInsert(out, toAdd);
-                    break;
+                    if (inputs == null) {
+                        // Skip the data if it's state is cleared because of 
state ttl.
+                        if (lenient) {
+                            LOG.warn(STATE_CLEARED_WARN_MSG);

Review comment:
       Shall we update the value of `sortedMap`? If not `treeMap` and 
`dataState` will be inconsistent. Or shall we put `treeMap` and `dataState` in 
an atomic state object to avoid this problem once and for all.




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