maedhroz commented on code in PR #2943:
URL: https://github.com/apache/cassandra/pull/2943#discussion_r1409916712
##########
src/java/org/apache/cassandra/index/sai/disk/v1/keystore/KeyLookup.java:
##########
@@ -265,42 +258,39 @@ public void reset() throws IOException
readCurrentKey();
}
-
@Override
public void close()
{
keysInput.close();
}
- private void updateCurrentBlockIndex(long pointId)
+ private int keyInBlockComparison(long pointId, BytesRef key)
{
- currentBlockIndex = pointId >>> blockShift;
- }
+ updateCurrentBlockIndex(pointId);
+ resetToCurrentBlock();
+ if (compareKeys(key, currentKey) < 0)
+ return -1;
- private boolean notInCurrentBlock(long pointId, BytesRef key)
- {
- if (inLastBlock(pointId))
- return false;
+ if (currentBlockIndex == blockOffsets.length() -1)
+ return 0;
- // Load the starting value of the next block into nextBlockKey.
- long blockIndex = (pointId >>> blockShift) + 1;
long currentFp = keysInput.getFilePointer();
- keysInput.seek(blockOffsets.get(blockIndex) + keysFilePointer);
- readKey(blockIndex << blockShift, nextBlockKey);
+ keysInput.seek(blockOffsets.get(currentBlockIndex + 1) +
keysFilePointer);
+ readKey((currentBlockIndex + 1) << blockShift, nextBlockKey);
keysInput.seek(currentFp);
-
- return compareKeys(key, nextBlockKey) >= 0;
+ return compareKeys(key, nextBlockKey) < 0 ? 0 : 1;
}
- private boolean inLastBlock(long pointId)
+ private void updateCurrentBlockIndex(long pointId)
{
- return pointId >>> blockShift == blockOffsets.length() - 1;
+ currentBlockIndex = pointId >>> blockShift;
}
// Reset currentPointId and currentKey to be at the start of the block
// pointed to by currentBlockIndex.
private void resetToCurrentBlock()
{
+
Review Comment:
nit: revert newline
--
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]