This is an automated email from the ASF dual-hosted git repository.

ibessonov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new ccef3df6d18 IGNITE-28524 Delete unused `ClosureCursor` (#7978)
ccef3df6d18 is described below

commit ccef3df6d1845267103da034085320392f05f5d2
Author: Ivan Bessonov <[email protected]>
AuthorDate: Mon Apr 13 17:43:57 2026 +0300

    IGNITE-28524 Delete unused `ClosureCursor` (#7978)
---
 .../tree/AbstractBplusTreePageMemoryTest.java      |  40 ++++---
 .../ignite/internal/pagememory/tree/BplusTree.java | 131 ---------------------
 2 files changed, 25 insertions(+), 146 deletions(-)

diff --git 
a/modules/page-memory/src/integrationTest/java/org/apache/ignite/internal/pagememory/tree/AbstractBplusTreePageMemoryTest.java
 
b/modules/page-memory/src/integrationTest/java/org/apache/ignite/internal/pagememory/tree/AbstractBplusTreePageMemoryTest.java
index b014c5154af..edd7791fc14 100644
--- 
a/modules/page-memory/src/integrationTest/java/org/apache/ignite/internal/pagememory/tree/AbstractBplusTreePageMemoryTest.java
+++ 
b/modules/page-memory/src/integrationTest/java/org/apache/ignite/internal/pagememory/tree/AbstractBplusTreePageMemoryTest.java
@@ -662,10 +662,20 @@ public abstract class AbstractBplusTreePageMemoryTest 
extends BaseIgniteAbstract
         assertNoLocks();
     }
 
+    private static void iterate(
+            TestTree tree, long lower, long upper, TreeRowMapClosure<Long, 
Long, Long> c
+    ) throws IgniteInternalCheckedException {
+        try (Cursor<Long> cursor = tree.find(lower, upper, c, null)) {
+            while (cursor.hasNext()) {
+                cursor.next();
+            }
+        }
+    }
+
     private void checkIterate(TestTree tree, long lower, long upper, Long exp, 
boolean expFound) throws IgniteInternalCheckedException {
         TestTreeRowClosure c = new TestTreeRowClosure(exp);
 
-        tree.iterate(lower, upper, c);
+        iterate(tree, lower, upper, c);
 
         assertEquals(expFound, c.found);
     }
@@ -679,7 +689,7 @@ public abstract class AbstractBplusTreePageMemoryTest 
extends BaseIgniteAbstract
     ) throws IgniteInternalCheckedException {
         c.found = false;
 
-        tree.iterate(lower, upper, c);
+        iterate(tree, lower, upper, c);
 
         assertEquals(expFound, c.found);
     }
@@ -2707,7 +2717,7 @@ public abstract class AbstractBplusTreePageMemoryTest 
extends BaseIgniteAbstract
 
                 TestTreeFindFirstClosure cl = new TestTreeFindFirstClosure();
 
-                tree.iterate((long) low, (long) high, cl);
+                iterate(tree, low, high, cl);
 
                 last = cl.val;
 
@@ -3014,9 +3024,9 @@ public abstract class AbstractBplusTreePageMemoryTest 
extends BaseIgniteAbstract
     }
 
     /**
-     * {@link TreeRowClosure} implementation for the test.
+     * {@link TreeRowMapClosure} implementation for the test.
      */
-    static class TestTreeRowClosure implements TreeRowClosure<Long, Long> {
+    static class TestTreeRowClosure implements TreeRowMapClosure<Long, Long, 
Long> {
         private final Long expVal;
 
         private boolean found;
@@ -3033,33 +3043,33 @@ public abstract class AbstractBplusTreePageMemoryTest 
extends BaseIgniteAbstract
         /** {@inheritDoc} */
         @Override
         public boolean apply(BplusTree<Long, Long> tree, BplusIo<Long> io, 
long pageAddr, int idx) throws IgniteInternalCheckedException {
-            assertFalse(found);
-
-            found = expVal == null || io.getLookupRow(tree, pageAddr, 
idx).equals(expVal);
+            if (expVal == null || io.getLookupRow(tree, pageAddr, 
idx).equals(expVal)) {
+                found = true;
+            }
 
-            return !found;
+            return true;
         }
     }
 
     /**
-     * {@link TreeRowClosure} implementation for the test.
+     * {@link TreeRowMapClosure} implementation for the test.
      */
-    static class TestTreeFindFirstClosure implements TreeRowClosure<Long, 
Long> {
+    static class TestTreeFindFirstClosure implements TreeRowMapClosure<Long, 
Long, Long> {
         private Long val;
 
         /** {@inheritDoc} */
         @Override
         public boolean apply(BplusTree<Long, Long> tree, BplusIo<Long> io, 
long pageAddr, int idx) throws IgniteInternalCheckedException {
-            assertNull(val);
-
-            val = io.getLookupRow(tree, pageAddr, idx);
+            if (val == null) {
+                val = io.getLookupRow(tree, pageAddr, idx);
+            }
 
             return false;
         }
     }
 
     /**
-     * {@link TreeRowClosure} implementation for the test.
+     * {@link TreeRowMapClosure} implementation for the test.
      */
     static class TestTreeFindFilteredClosure implements 
TreeRowMapClosure<Long, Long, Long> {
         private final Set<Long> vals;
diff --git 
a/modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/BplusTree.java
 
b/modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/BplusTree.java
index f6eb1bf101b..a432561c609 100644
--- 
a/modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/BplusTree.java
+++ 
b/modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/BplusTree.java
@@ -1299,37 +1299,6 @@ public abstract class BplusTree<L, T extends L> extends 
DataStructure implements
         }
     }
 
-    /**
-     * Iterates over the tree.
-     *
-     * @param lower Lower bound inclusive.
-     * @param upper Upper bound inclusive.
-     * @param c Closure applied for all found items, iteration is stopped if 
closure returns {@code false}.
-     * @throws IgniteInternalCheckedException If failed.
-     */
-    public void iterate(L lower, L upper, TreeRowClosure<L, T> c) throws 
IgniteInternalCheckedException {
-        checkDestroyed();
-
-        ClosureCursor cursor = new ClosureCursor(lower, upper, c);
-
-        try {
-            cursor.iterate();
-        } catch (CorruptedDataStructureException e) {
-            throw e;
-        } catch (IgniteInternalCheckedException e) {
-            throw new IgniteInternalCheckedException("Runtime failure on 
bounds [lower=" + lower + ", upper=" + upper + "]", e);
-        } catch (RuntimeException | AssertionError e) {
-            throw corruptedTreeException(
-                    "Runtime failure on bounds [lower=" + lower + ", upper=" + 
upper + "]",
-                    e,
-                    grpId,
-                    pages(cursor.getCursor != null, () -> new 
long[]{cursor.getCursor.pageId})
-            );
-        } finally {
-            checkDestroyed();
-        }
-    }
-
     /**
      * Visits tree rows.
      *
@@ -6044,106 +6013,6 @@ public abstract class BplusTree<L, T extends L> extends 
DataStructure implements
         }
     }
 
-    /**
-     * Closure cursor.
-     */
-    private final class ClosureCursor extends AbstractForwardCursor {
-        /** Row predicate. */
-        private final TreeRowClosure<L, T> predicate;
-
-        /** Last row. */
-        @Nullable
-        private L lastRow;
-
-        /**
-         * Constructor.
-         *
-         * @param lowerBound Lower bound inclusive.
-         * @param upperBound Upper bound inclusive.
-         * @param predicate Row predicate.
-         */
-        ClosureCursor(L lowerBound, L upperBound, TreeRowClosure<L, T> 
predicate) {
-            super(lowerBound, upperBound, true, true);
-
-            this.predicate = predicate;
-        }
-
-        @Override
-        void init0() {
-            // No-op.
-        }
-
-        @Override
-        boolean fillFromBuffer0(long pageAddr, BplusIo<L> io, int startIdx, 
int cnt) throws IgniteInternalCheckedException {
-            if (startIdx == -1) {
-                startIdx = findLowerBound(pageAddr, io, cnt);
-            }
-
-            if (cnt == startIdx) {
-                return false;
-            }
-
-            for (int i = startIdx; i < cnt; i++) {
-                int cmp = compare(0, io, pageAddr, i, upperBound);
-
-                if (cmp > 0) {
-                    nextPageId = 0; // The End.
-
-                    return false;
-                }
-
-                boolean stop = !predicate.apply(BplusTree.this, io, pageAddr, 
i);
-
-                if (stop) {
-                    nextPageId = 0; // The End.
-
-                    return true;
-                }
-            }
-
-            if (nextPageId != 0) {
-                lastRow = io.getLookupRow(BplusTree.this, pageAddr, cnt - 1); 
// Need save last row.
-            }
-
-            return true;
-        }
-
-        @Override
-        boolean reinitialize0() {
-            return true;
-        }
-
-        @Override
-        void onNotFound(boolean readDone) {
-            nextPageId = 0;
-        }
-
-        /**
-         * Iterates over the tree.
-         *
-         * @throws IgniteInternalCheckedException If failed.
-         */
-        private void iterate() throws IgniteInternalCheckedException {
-            find();
-
-            if (nextPageId == 0) {
-                return;
-            }
-
-            for (; ; ) {
-                L lastRow0 = lastRow;
-
-                lastRow = null;
-
-                nextPage(lastRow0);
-
-                if (nextPageId == 0) {
-                    return;
-                }
-            }
-        }
-    }
-
     /**
      * Forward cursor.
      */

Reply via email to