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


##########
src/java/org/apache/cassandra/index/sai/memory/MemtableOrdering.java:
##########
@@ -20,23 +20,36 @@
 
 import java.util.List;
 
-import org.apache.cassandra.index.sai.iterators.KeyRangeIterator;
+import org.apache.cassandra.db.PartitionPosition;
+import org.apache.cassandra.dht.AbstractBounds;
+import org.apache.cassandra.index.sai.QueryContext;
+import org.apache.cassandra.index.sai.disk.v1.vector.PrimaryKeyWithScore;
 import org.apache.cassandra.index.sai.plan.Expression;
 import org.apache.cassandra.index.sai.utils.PrimaryKey;
+import org.apache.cassandra.utils.CloseableIterator;
 
 /**
  * Analogue of {@link 
org.apache.cassandra.index.sai.disk.v1.segment.SegmentOrdering}, but for 
memtables.
  */
 public interface MemtableOrdering
 {
     /**
-     * Filter the given list of {@code PrimaryKey} results to the top `limit` 
results corresponding to the given expression,
-     * Returns an iterator over the results that is put back in token order.
-     * <p>
-     * Assumes that the given list spans the same rows as the implementing 
index's segment.
+     * Order the index based on the given expression.
+     *
+     * @param queryContext - the query context
+     * @param expression   - the expression to order by
+     * @param keyRange     - the key range to search
+     * @return an iterator over the results in score order.
      */
-    default KeyRangeIterator limitToTopResults(List<PrimaryKey> primaryKeys, 
Expression expression, int limit)
-    {
-        throw new UnsupportedOperationException();
-    }
+    CloseableIterator<PrimaryKeyWithScore> orderBy(QueryContext queryContext,
+                                                   Expression expression,
+                                                   
AbstractBounds<PartitionPosition> keyRange);
+
+    /**
+     * Order the given list of {@link PrimaryKey} results corresponding to the 
given expression.
+     * Returns an iterator over the results in score order.
+     *
+     * Assumes that the given  spans the same rows as the implementing index's 
segment.
+     */
+    CloseableIterator<PrimaryKeyWithScore> orderResultsBy(QueryContext 
context, List<PrimaryKey> primaryKeys, Expression expression);

Review Comment:
   For this and `SegmentOrdering`, I've been mulling over naming a bit. You 
could imagine a signature like the one below, but take it as brainstorming 
rather than a strong suggestion. (I'm always trying to pack some meaning into 
argument names, so something like `primaryKeys` -> `results` is appealing to 
me.)
   
   ```
   CloseableIterator<PrimaryKeyWithScore> orderResultsBy(QueryContext context, 
List<PrimaryKey> results, Expression scorer);
   ```



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