gortiz commented on code in PR #16789:
URL: https://github.com/apache/pinot/pull/16789#discussion_r2369224264


##########
pinot-core/src/main/java/org/apache/pinot/core/plan/SelectionPlanNode.java:
##########
@@ -120,6 +122,34 @@ public Operator<SelectionResultsBlock> run() {
     return new SelectionOrderByOperator(_indexSegment, _queryContext, 
expressions, projectOperator);
   }
 
+  private BaseProjectOperator<?> getSortedByProject(List<ExpressionContext> 
expressions, int maxDocsPerCall,
+      List<OrderByExpressionContext> orderByExpressions) {
+    BaseProjectOperator<?> projectOperator =
+        new ProjectPlanNode(_segmentContext, _queryContext, expressions, 
maxDocsPerCall).run();
+
+    boolean asc = orderByExpressions.get(0).isAsc();
+    if (!asc
+        && reverseOptimizationEnabled(_queryContext)
+        && 
!projectOperator.isCompatibleWith(SegmentBlockOperator.DidOrder.DESC)) {
+      try {
+        return projectOperator.withOrder(SegmentBlockOperator.DidOrder.DESC);
+      } catch (IllegalArgumentException | UnsupportedOperationException e) {
+        // This happens when the operator cannot provide the required order 
between blocks
+        // Fallback to SelectionOrderByOperator
+        return projectOperator;
+      }
+    }
+    return projectOperator;
+  }
+
+  private boolean reverseOptimizationEnabled(QueryContext queryContext) {

Review Comment:
   Changed in 
[0ef6a9c](https://github.com/apache/pinot/pull/16789/commits/0ef6a9cf972c5b1753b496da27905d32d278e792)



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to