JingsongLi commented on code in PR #6738:
URL: https://github.com/apache/paimon/pull/6738#discussion_r2588404374
##########
paimon-common/src/main/java/org/apache/paimon/lookup/sort/BlockIterator.java:
##########
@@ -70,32 +62,58 @@ public void remove() {
throw new UnsupportedOperationException();
}
+ /**
+ * Seeks to the first entry with a key that is either equal to or greater
than the specified
+ * key. After this call, the next invocation of {@link
BlockIterator#next()} will return that
+ * entry (if it exists).
+ *
+ * <p>Note that the comparing value must be monotonically increasing
across current block e.g.
+ * key and some special values such as the {@code lastRecordPosition} of
an {@code
+ * IndexBlockEntry}.
+ *
+ * @param targetKey target key
+ * @return true if found an equal record
+ */
public boolean seekTo(MemorySlice targetKey) {
int left = 0;
int right = recordCount - 1;
+ int mid = left + (right - left) / 2;
while (left <= right) {
- int mid = left + (right - left) / 2;
+ mid = left + (right - left) / 2;
seekTo(mid);
BlockEntry midEntry = readEntry();
int compare = comparator.compare(midEntry.getKey(), targetKey);
if (compare == 0) {
- polled = midEntry;
- return true;
+ break;
} else if (compare > 0) {
- polled = midEntry;
right = mid - 1;
} else {
left = mid + 1;
Review Comment:
Why not just modify here: polled = null;
--
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]