You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2023/04/25 12:45:44 UTC

[jackrabbit-oak] branch OAK-10210 created (now cbe36d4a43)

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

thomasm pushed a change to branch OAK-10210
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


      at cbe36d4a43 OAK-10210 Prefetch breaks Fast Result Size

This branch includes the following new commits:

     new cbe36d4a43 OAK-10210 Prefetch breaks Fast Result Size

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jackrabbit-oak] 01/01: OAK-10210 Prefetch breaks Fast Result Size

Posted by th...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

thomasm pushed a commit to branch OAK-10210
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit cbe36d4a43491ae19c37cfafadd617253b9cb308
Author: Thomas Mueller <th...@apache.org>
AuthorDate: Tue Apr 25 14:45:30 2023 +0200

    OAK-10210 Prefetch breaks Fast Result Size
---
 .../oak/plugins/index/cursor/PrefetchCursor.java   |  6 +++++
 .../plugins/index/cursor/PrefetchCursorTest.java   | 31 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursor.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursor.java
index 60fe8c512e..1a0a283de7 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursor.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursor.java
@@ -26,6 +26,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
+import org.apache.jackrabbit.oak.api.Result.SizePrecision;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.IndexRow;
@@ -61,6 +62,11 @@ public class PrefetchCursor extends AbstractCursor {
         this.prefetchRelative = prefetchRelative;
     }
 
+    @Override
+    public long getSize(SizePrecision precision, long max) {
+        return cursor.getSize(precision, max);
+    }
+
     @Override
     public IndexRow next() {
         if (!prefetched.hasNext()) {
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursorTest.java
index 05a0fe3e88..c424d99aae 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursorTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/cursor/PrefetchCursorTest.java
@@ -25,6 +25,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.jackrabbit.oak.api.Result.SizePrecision;
+import org.apache.jackrabbit.oak.spi.query.Cursor;
+import org.apache.jackrabbit.oak.spi.query.IndexRow;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
 
@@ -96,6 +99,34 @@ public class PrefetchCursorTest {
                 "/content/images/abc.jpg"));
     }
     
+    /**
+     * Test that the PrefetchCursor forwards the getSize() request to the nested
+     * cursor.
+     */
+    @Test
+    public void fastResultSize() {
+        int expectedResult = 123;
+        PrefetchCursor prefetch = new PrefetchCursor(new Cursor() {
+
+            @Override
+            public boolean hasNext() {
+                return false;
+            }
+
+            @Override
+            public long getSize(SizePrecision precision, long max) {
+                return expectedResult;
+            }
+
+            @Override
+            public IndexRow next() {
+                return null;
+            }
+
+        }, null, 0, null, null);
+        assertEquals(expectedResult, prefetch.getSize(null, 0));
+    }
+
     @Test
     public void cursor() {
         List<String> paths = Arrays.asList(