lsyldliu commented on a change in pull request #12303:
URL: https://github.com/apache/flink/pull/12303#discussion_r435652445
##########
File path:
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/rank/AppendOnlyTopNFunction.java
##########
@@ -210,14 +210,19 @@ private void processElementWithoutRowNumber(RowData
input, Collector<RowData> ou
RowData lastKey = lastEntry.getKey();
List<RowData> lastList = (List<RowData>)
lastEntry.getValue();
// remove last one
- RowData lastElement = lastList.remove(lastList.size() -
1);
- if (lastList.isEmpty()) {
+ int size = lastList.size();
+ RowData lastElement = null;
+ if (size > 0) {
+ lastElement = lastList.get(size - 1);
Review comment:
Good idea, I don't want to break the atomicity of `TopNBuffer`, so I
don't want to add new method which can operate currentTopNum directly in this
class, prefer to use `TopNBuffer#removeLast`
----------------------------------------------------------------
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]