You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2024/04/25 22:20:08 UTC
(pinot) branch master updated: Use ArrayList instead of LinkedList in SortOperator (#12783)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new fc98ce1d53 Use ArrayList instead of LinkedList in SortOperator (#12783)
fc98ce1d53 is described below
commit fc98ce1d53710d333ca652304cd0f1c1f1fa8e1b
Author: Gonzalo Ortiz Jaureguizar <go...@users.noreply.github.com>
AuthorDate: Fri Apr 26 00:20:02 2024 +0200
Use ArrayList instead of LinkedList in SortOperator (#12783)
---
.../pinot/query/runtime/operator/SortOperator.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/SortOperator.java b/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/SortOperator.java
index ce4ddf130f..b0a1923c80 100644
--- a/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/SortOperator.java
+++ b/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/SortOperator.java
@@ -21,7 +21,7 @@ package org.apache.pinot.query.runtime.operator;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
-import java.util.LinkedList;
+import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import javax.annotation.Nullable;
@@ -129,16 +129,16 @@ public class SortOperator extends MultiStageOperator {
return TransferableBlockUtils.getEndOfStreamTransferableBlock();
}
} else {
- LinkedList<Object[]> rows = new LinkedList<>();
- while (_priorityQueue.size() > _offset) {
- Object[] row = _priorityQueue.poll();
- rows.addFirst(row);
- }
- if (rows.size() == 0) {
+ int resultSize = _priorityQueue.size() - _offset;
+ if (resultSize <= 0) {
return TransferableBlockUtils.getEndOfStreamTransferableBlock();
- } else {
- return new TransferableBlock(rows, _dataSchema, DataBlock.Type.ROW);
}
+ Object[][] rowsArr = new Object[resultSize][];
+ for (int i = resultSize - 1; i >= 0; i--) {
+ Object[] row = _priorityQueue.poll();
+ rowsArr[i] = row;
+ }
+ return new TransferableBlock(Arrays.asList(rowsArr), _dataSchema, DataBlock.Type.ROW);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org