AMashenkov commented on code in PR #1629:
URL: https://github.com/apache/ignite-3/pull/1629#discussion_r1114959486
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/SortNode.java:
##########
@@ -127,12 +165,32 @@ private void flush() throws Exception {
inLoop = true;
try {
- while (requested > 0 && !rows.isEmpty()) {
+ // Prepare final order (reversed).
+ if (limit > 0 && !rows.isEmpty()) {
+ if (reversed == null) {
+ reversed = new ArrayList<>(rows.size());
+ }
+
+ while (!rows.isEmpty()) {
+ reversed.add(rows.poll());
Review Comment:
When all data moved from `rows` to `reversed`, then we can free memory and
e.g. nullify `rows`.
--
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]