maedhroz commented on code in PR #3649:
URL: https://github.com/apache/cassandra/pull/3649#discussion_r1833155123
##########
src/java/org/apache/cassandra/index/sai/plan/StorageAttachedIndexSearcher.java:
##########
@@ -222,45 +236,57 @@ public UnfilteredRowIterator computeNext()
/**
* Returns the next available key contained by one of the keyRanges
and selected by the queryController.
* If the next key falls out of the current key range, it skips to the
next key range, and so on.
- * If no more keys acceptd by the controller are available, returns
null.
+ * If no more keys acceptd by the controller are available, returns an
empty list.
*/
- private @Nullable PrimaryKey nextSelectedKeyInRange()
+ private List<PrimaryKey> nextSelectedKeyInRange()
{
+ List<PrimaryKey> threadLocalNextKeys = nextKeys.get();
+ threadLocalNextKeys.clear();
PrimaryKey key;
+
do
{
key = nextKeyInRange();
+
+ if (key == null)
+ return Collections.emptyList();
}
- while (key != null && queryController.doesNotSelect(key));
- return key;
+ while (queryController.doesNotSelect(key) || key.equals(lastKey));
+
+ lastKey = key;
+ threadLocalNextKeys.add(key);
+ return threadLocalNextKeys;
}
/**
- * Retrieves the next primary key that belongs to the given partition
and is selected by the query controller.
- * The underlying key iterator is advanced only if the key belongs to
the same partition.
- * <p>
- * Returns null if:
- * <ul>
- * <li>there are no more keys</li>
- * <li>the next key is beyond the upper bound</li>
- * <li>the next key belongs to a different partition</li>
- * </ul>
- * </p>
+ * Retrieves the next batch of primary keys (i.e. up to {@link
#partitionRowBatchSize} of them) that belong to
+ * the given partition and are selected by the query controller,
advancing the underlying iterator only while
+ * the next key belongs to that partition.
+ *
+ * @return a list of up to {@link #partitionRowBatchSize} primary keys
within the given partition and data range
*/
- private @Nullable PrimaryKey nextSelectedKeyInPartition(DecoratedKey
partitionKey)
+ private List<PrimaryKey> nextSelectedKeysInPartition(DecoratedKey
partitionKey)
Review Comment:
Right. As it stands, a query that matches 100 rows in a partition doesn't go
down to 1 local read, but 2. It might be easy to fix this by using
`nextSelectedKeysInPartition()` at the end of `nextSelectedKeyInRange()`...will
push something...
--
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]