maedhroz commented on code in PR #2943:
URL: https://github.com/apache/cassandra/pull/2943#discussion_r1410000119
##########
src/java/org/apache/cassandra/index/sai/disk/v1/keystore/KeyLookup.java:
##########
@@ -197,43 +197,34 @@ public long clusteredSeekToKey(ByteComparable key, long
startingPointId, long en
updateCurrentBlockIndex(startingPointId);
resetToCurrentBlock();
- if (compareKeys(currentKey, skipKey) == 0)
- return startingPointId;
+ // We can return straightaway if the currentPointId is within the
requested partition range and the keys match
+ if (currentPointId >= startingPointId && currentPointId <
endingPointId && compareKeys(currentKey, skipKey) == 0)
+ return currentPointId;
- if (notInCurrentBlock(startingPointId, skipKey))
- {
- long split = (endingPointId - startingPointId) >>> blockShift;
- long splitPointId = startingPointId;
- while (split > 0)
- {
- updateCurrentBlockIndex(Math.min((splitPointId >>>
blockShift) + split, blockOffsets.length() - 1));
- resetToCurrentBlock();
+ long splitStartId = startingPointId;
+ long splitEndId = endingPointId;
- if (currentPointId >= endingPointId)
- {
- updateCurrentBlockIndex((endingPointId - 1));
- resetToCurrentBlock();
- }
-
- int cmp = compareKeys(currentKey, skipKey);
-
- if (cmp == 0)
- return currentPointId;
+ while ((splitEndId - splitStartId) >>> blockShift > 0)
+ {
+ long midPointId = splitStartId + (splitEndId - splitStartId) /
2;
- if (cmp < 0)
- splitPointId = currentPointId;
+ int position = keyInBlockComparison(midPointId, skipKey);
Review Comment:
So essentially this `keyInBlockComparison()` method is
`moveToBlockAndCompareTo()`? Going back and forth on whether it would be less
surprising to just pull up the `updateCurrentBlockIndex()` and
`resetToCurrentBlock()` calls to this level to avoid hiding the "move" part in
`keyInBlockComparison()`...
--
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]