JingsongLi commented on code in PR #6842:
URL: https://github.com/apache/paimon/pull/6842#discussion_r2641659734
##########
paimon-common/src/main/java/org/apache/paimon/sst/SstFileReader.java:
##########
@@ -95,20 +100,62 @@ public byte[] lookup(byte[] key) throws IOException {
MemorySlice keySlice = MemorySlice.wrap(key);
// seek the index to the block containing the key
- indexBlockIterator.seekTo(keySlice);
+ BlockIterator detachedIndex = this.indexBlockIterator.detach();
+ detachedIndex.seekTo(keySlice);
// if indexIterator does not have a next, it means the key does not
exist in this iterator
- if (indexBlockIterator.hasNext()) {
+ if (detachedIndex.hasNext()) {
// seek the current iterator to the key
- BlockIterator current = getNextBlock();
+ BlockIterator current = getNextBlock(detachedIndex);
if (current.seekTo(keySlice)) {
return current.next().getValue().copyBytes();
}
}
return null;
}
- private BlockIterator getNextBlock() {
+ /**
+ * Seek to the position of the record whose key is exactly equal to or
greater than the
+ * specified key.
+ */
+ public void seekTo(byte[] key) throws IOException {
Review Comment:
Can you create a `SstFileIterator` for this? It can be:
```
class SstFileIterator {
void seekTo(byte[] key);
BlockIterator readBatch();
}
```
--
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]