tkalkirill commented on code in PR #1407:
URL: https://github.com/apache/ignite-3/pull/1407#discussion_r1044293398


##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestSortedIndexStorage.java:
##########
@@ -208,4 +184,91 @@ private void checkClosed() {
             throw new StorageClosedException("Storage is already closed");
         }
     }
+
+    private class ScanCursor implements Cursor<IndexRow> {
+        private final NavigableMap<ByteBuffer, NavigableMap<RowId, Object>> 
indexMap;
+
+        @Nullable
+        private Boolean hasNext;
+
+        @Nullable
+        private Entry<ByteBuffer, NavigableMap<RowId, Object>> indexMapEntry;
+
+        @Nullable
+        private RowId rowId;
+
+        private ScanCursor(NavigableMap<ByteBuffer, NavigableMap<RowId, 
Object>> indexMap) {
+            this.indexMap = indexMap;
+        }
+
+        @Override
+        public void close() {
+            // No-op.
+        }
+
+        @Override
+        public boolean hasNext() {
+            checkClosed();
+
+            advanceIfNeeded();
+
+            return hasNext;
+        }
+
+        @Override
+        public IndexRow next() {
+            checkClosed();
+
+            advanceIfNeeded();
+
+            boolean hasNext = this.hasNext;
+
+            this.hasNext = null;
+
+            if (!hasNext) {
+                throw new NoSuchElementException();
+            }
+
+            return new IndexRowImpl(new 
BinaryTuple(descriptor.binaryTupleSchema(), indexMapEntry.getKey()), rowId);
+        }
+
+        private void advanceIfNeeded() {
+            if (hasNext == null) {
+                if (indexMapEntry == null) {
+                    indexMapEntry = indexMap.firstEntry();
+                }
+
+                if (rowId == null) {
+                    if (indexMapEntry != null) {
+                        rowId = 
getRowId(indexMapEntry.getValue().firstEntry());
+                    }
+                } else {
+                    Entry<RowId, Object> rowIdEntry = 
indexMapEntry.getValue().higherEntry(rowId);

Review Comment:
   Fix it



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