lsyldliu commented on a change in pull request #12303:
URL: https://github.com/apache/flink/pull/12303#discussion_r435333138
##########
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:
@wuchong I agree with you, but I think we also should subtract
buffer.currentTopNum = buffer.currentTopNum - 1 after remove lastElement, So
is it appropriate to add a method in TopNBuffer such as `public void
minusTopNum(int delta) {
currentTopNum -= delta;
}`,
we should call this method behind `dataState.put(lastKey, new
ArrayList<>(lastList))`, what do you think it?
----------------------------------------------------------------
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]