ibessonov commented on code in PR #1992:
URL: https://github.com/apache/ignite-3/pull/1992#discussion_r1180344448
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/SortedIndexLocker.java:
##########
@@ -155,15 +154,15 @@ public CompletableFuture<Lock> locksForInsert(UUID txId,
BinaryRow tableRow, Row
BinaryTuplePrefix prefix = BinaryTuplePrefix.fromBinaryTuple(key);
- // find next key
- Cursor<IndexRow> cursor = storage.scan(prefix, null,
SortedIndexStorage.GREATER);
+ // Find next key.
+ PeekCursor<IndexRow> cursor = storage.scan(prefix, null,
SortedIndexStorage.GREATER);
- BinaryTuple nextKey;
- if (cursor.hasNext()) {
- nextKey = cursor.next().indexColumns();
- } else { // otherwise INF
- nextKey = POSITIVE_INF;
- }
+ //noinspection ResultOfMethodCallIgnored
+ cursor.hasNext();
+
+ // "peek" works the same as "next" when "hasNext" is called. The only
difference is that it returns null instead of throwing
+ // an exception, if nothing is found.
+ BinaryTuple nextKey = indexKey(cursor.peek());
Review Comment:
Old code was a scenario copy-pasted twice, I removed the copy-paste.
What else is equivalent? Replacement of "hasNext()" with "peek() != null" is
not an equivalent change, it's a fix
--
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]