ChaomingZhangCN commented on code in PR #27188:
URL: https://github.com/apache/flink/pull/27188#discussion_r2497246875


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/sort/SortLimitOperator.java:
##########
@@ -92,12 +92,11 @@ public void processElement(StreamRecord<RowData> element) 
throws Exception {
     @Override
     public void endInput() throws Exception {
         if (isGlobal) {
-            // Global sort, we need sort the results and pick records in 
limitStart to limitEnd.
-            List<RowData> list = new ArrayList<>(heap);
-            list.sort((o1, o2) -> comparator.compare(o1, o2));
-
-            int maxIndex = (int) Math.min(limitEnd, list.size());
-            for (int i = (int) limitStart; i < maxIndex; i++) {
+            List<RowData> list = new ArrayList<>((int) (heap.size() - 
limitStart));

Review Comment:
   I did some performance tests and found that the improvement was not 
significant.



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