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 mr...@apache.org on 2016/12/22 14:08:33 UTC

svn commit: r1775660 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImpl.java test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java

Author: mreutegg
Date: Thu Dec 22 14:08:33 2016
New Revision: 1775660

URL: http://svn.apache.org/viewvc?rev=1775660&view=rev
Log:
OAK-5366: Optimize pre-filtering with long paths

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImpl.java?rev=1775660&r1=1775659&r2=1775660&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImpl.java Thu Dec 22 14:08:33 2016
@@ -211,8 +211,20 @@ public class ChangeSetFilterImpl impleme
         if (changeSet.doesHitMaxPathDepth()) {
             // then we might or might not include this - but without
             // further complicated checks this can't be determined for sure
-            // so for simplicity reason: return false here
-            return false;
+            // so for simplicity reason just check first level include names
+            // if available
+            if (firstLevelIncludeNames == null) {
+                return false;
+            }
+            for (String parentPath : changeSet.getParentPaths()) {
+                String firstLevelName = firstLevelName(parentPath);
+                if (firstLevelName != null && firstLevelIncludeNames.contains(firstLevelName)) {
+                    return false;
+                }
+            }
+            // none of the first level include names matched any parentPath
+            // we can safely exclude this change set
+            return true;
         }
         final Set<String> parentPaths = new HashSet<String>(changeSet.getParentPaths());
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java?rev=1775660&r1=1775659&r2=1775660&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java Thu Dec 22 14:08:33 2016
@@ -303,23 +303,17 @@ public class ChangeSetFilterImplTest {
         doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g", 5, false);
         doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 5, false);
         
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 1, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 2, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 3, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 4, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 5, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 6, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 7, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 8, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", 9, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h",10, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h",11, false);
-        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h",12, false);
+        for (int maxPathDepth = 1; maxPathDepth < 13; maxPathDepth++) {
+            doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/d/e/f/g/h", maxPathDepth, false);
+        }
 
         doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/x", 15, true);
         doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/x", 15, true);
         doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/x", 15, true);
         doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/b/c/x", 15, true);
+
+        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/x", 9, true);
+        doTestDeepPath("/a/b/c/d/e/f/g/h/i/j/k/l", "/a/x", 9, false);
     }
 
     private void doTestDeepPath(String changeSetPath, String includePath, int maxPathDepth, boolean expectExclude) {