denis-chudov commented on code in PR #1467:
URL: https://github.com/apache/ignite-3/pull/1467#discussion_r1055548654


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -697,15 +699,38 @@ private CompletableFuture<List<BinaryRow>> 
scanSortedIndex(
 
         return lockManager.acquire(txId, new LockKey(indexId), 
LockMode.IS).thenCompose(idxLock -> { // Index IS lock
             return lockManager.acquire(txId, new LockKey(tableId), 
LockMode.IS).thenCompose(tblLock -> { // Table IS lock
+                var comparator = new 
BinaryTupleComparator(indexStorage.indexDescriptor());
+
+                Function<IndexRow, Boolean> isUpperBoundAchieved = indexRow -> 
{
+                    if (indexRow == null) {
+                        return true;
+                    }
+
+                    if (upperBound == null) {
+                        return false;
+                    }
+
+                    ByteBuffer buffer = upperBound.byteBuffer();
+
+                    if ((flags & SortedIndexStorage.LESS_OR_EQUAL) != 0) {
+                        byte boundFlags = buffer.get(0);
+
+                        buffer.put(0, (byte) (boundFlags | 
BinaryTupleCommon.EQUALITY_FLAG));
+                    }
+
+                    if 
(comparator.compare(indexRow.indexColumns().byteBuffer(), buffer) < 0) {
+                        return false;
+                    }
+
+                    return true;
+                };
+
                 Cursor<IndexRow> cursor = (Cursor<IndexRow>) 
cursors.computeIfAbsent(cursorId,
                         id -> {
-                            // TODO 
https://issues.apache.org/jira/browse/IGNITE-18057
-                            // Fix scan cursor return item closet to 
lowerbound and <= lowerbound
-                            // to correctly lock range between lowerbound 
value and the item next to lowerbound.
                             return indexStorage.scan(
                                     lowerBound,
-                                    // We need upperBound next value for 
correct range lock.
-                                    upperBound,
+                                    // We have to handle upperBound on a level 
of replication listener, to correct to take a range lock.

Review Comment:
   ```suggestion
                                       // We have to handle upperBound on a 
level of replication listener, for correctness of taking of a range lock.
   ```



-- 
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]

Reply via email to