Vladsz83 commented on code in PR #9987:
URL: https://github.com/apache/ignite/pull/9987#discussion_r873137409
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortNode.java:
##########
@@ -39,21 +43,53 @@
/** Rows buffer. */
private final PriorityQueue<Row> rows;
+ /** SQL select limit. Negative if disabled. */
+ private final int limit;
+
+ /** Reverse-ordered rows in case of limited sort. */
+ private List<Row> reversed;
+
/**
* @param ctx Execution context.
* @param comp Rows comparator.
+ * @param offset Offset.
+ * @param fetch Limit.
*/
- public SortNode(ExecutionContext<Row> ctx, RelDataType rowType,
Comparator<Row> comp) {
+ public SortNode(
+ ExecutionContext<Row> ctx, RelDataType rowType,
+ Comparator<Row> comp,
+ @Nullable Supplier<Integer> offset,
+ @Nullable Supplier<Integer> fetch
+ ) {
super(ctx, rowType);
- rows = comp == null ? new PriorityQueue<>() : new
PriorityQueue<>(comp);
+ assert fetch == null || fetch.get() >= 0;
+ assert offset == null || offset.get() >= 0;
+
+ limit = fetch == null ? -1 : fetch.get() + (offset == null ? 0 :
offset.get());
+
+ if (limit < 0)
+ rows = new PriorityQueue<>(comp);
+ else
+ rows = new GridBoundedPriorityQueue<>(limit, comp == null ?
(Comparator<Row>)Comparator.reverseOrder()
+ : comp.reversed());
Review Comment:
Fixed
--
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]