maedhroz commented on code in PR #4353:
URL: https://github.com/apache/cassandra/pull/4353#discussion_r2692541374


##########
src/java/org/apache/cassandra/index/sai/plan/Operation.java:
##########
@@ -319,16 +320,23 @@ private static int getPriority(Operator op)
      */
     static KeyRangeIterator buildIterator(QueryController controller)
     {
-        List<RowFilter.Expression> orderings = 
controller.indexFilter().getExpressions()
-                                                         .stream().filter(e -> 
e.operator() == Operator.ANN).collect(Collectors.toList());
-        assert orderings.size() <= 1;
-        if (controller.indexFilter().getExpressions().size() == 1 && 
orderings.size() == 1)
+        return 
Node.buildTree(controller.indexFilter()).analyzeTree(controller).rangeIterator(controller);
+    }
+
+    /**
+     * Converts expressions into filter tree for query.
+     *
+     * @return a KeyRangeIterator over the index query results
+     */
+    static CloseableIterator<PrimaryKeyWithScore> 
buildIteratorForOrder(QueryController controller, 
QueryViewBuilder.QueryExpressionView view)
+    {
+        if (controller.indexFilter().getExpressions().size() == 1)
             // If we only have one expression, we just use the ANN index to 
order and limit.
-            return controller.getTopKRows(orderings.get(0));
+            return controller.getTopKRows(view);
+
+        // Otherwise, we need to search first, then order.
         KeyRangeIterator iterator = 
Node.buildTree(controller.indexFilter()).analyzeTree(controller).rangeIterator(controller);

Review Comment:
   nit: Could we just call `buildIterator()` now instead of duplicating 
`Node.buildTree(controller.indexFilter()).analyzeTree(controller).rangeIterator(controller)`?



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