Jackie-Jiang commented on code in PR #16789:
URL: https://github.com/apache/pinot/pull/16789#discussion_r2364888423


##########
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:
   I prefer keeping all query option parsing methods in one util class so that 
I don't need to look for other places. If we keep it in a different file, 
people might end up adding another one when they need to access the same option 
key. This is optional, and you can keep it the current way



-- 
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]

Reply via email to