Jackie-Jiang commented on a change in pull request #8228:
URL: https://github.com/apache/pinot/pull/8228#discussion_r812421122
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/operator/query/SelectionOrderByOperator.java
##########
@@ -117,6 +118,31 @@ public String toExplainString() {
return stringBuilder.append(')').toString();
}
+ private boolean isAllOrderByColumnsSorted() {
+ // Order by col1, col2 limit k will take all the n matching rows
+ // and add it to a priority queue of size k.
+ // This is nlogk operation which can be quite expensive for a large n.
+ // This function, prunes out any order by clause that matches columns
sorting order.
+ // In the above example, if the docs are already sorted by both col1, col2
then there is no need for any
+ // sorting at all (only limit is needed).
+ //
+ // This function just tracks the columns that are already sorted. If all
them are sorted already, we can
+ // use that info to short circuit the looping.
+ int numOrderByExpressions = _orderByExpressions.size();
+ for (int i = 0; i < numOrderByExpressions; i++) {
+ OrderByExpressionContext expressionContext = _orderByExpressions.get(0);
+ if
(!expressionContext.getExpression().getType().equals(ExpressionContext.Type.IDENTIFIER)
Review comment:
(minor)
```suggestion
if (!expressionContext.getExpression().getType() ==
ExpressionContext.Type.IDENTIFIER
```
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/operator/query/SelectionOrderByOperator.java
##########
@@ -82,6 +82,7 @@
private final int _numRowsToKeep;
private final PriorityQueue<Object[]> _rows;
+ private int _numOrderByColsPreSorted = 0;
Review comment:
Remove this unused variable
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/operator/query/SelectionOrderByOperator.java
##########
@@ -117,6 +118,31 @@ public String toExplainString() {
return stringBuilder.append(')').toString();
}
+ private boolean isAllOrderByColumnsSorted() {
+ // Order by col1, col2 limit k will take all the n matching rows
Review comment:
Let's revise the comments to match the functionality and put it as
javadoc for this method
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]