jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1404926 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/ast/ test/java/org/apache/jackrabbit/oak/plugins/index/lucene/ test/java/org/apache/jackrabbit/oak/query/ test/resources/org/apache/jackrabbit/oak/q...
Date Fri, 02 Nov 2012 11:23:07 GMT
Author: thomasm
Date: Fri Nov  2 11:23:07 2012
New Revision: 1404926

URL: http://svn.apache.org/viewvc?rev=1404926&view=rev
Log:
OAK-419 Query: Conditions are not pushed to "outer join" selectors
OAK-420 Query: Lucene index problem with isdescendantnode

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java?rev=1404926&r1=1404925&r2=1404926&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NotImpl.java
Fri Nov  2 11:23:07 2012
@@ -52,6 +52,21 @@ public class NotImpl extends ConstraintI
 
     @Override
     public void restrict(FilterImpl f) {
+        if (f.getSelector().outerJoin) {
+            // we need to be careful with the condition 
+            // "NOT (property IS NOT NULL)"
+            // (which is the same as 
+            // "property IS NULL") because
+            // this might cause an index to ignore
+            // the join condition "property = x"
+            // for example in:
+            // "select * from a left outer join b on a.x = b.y
+            // where not b.y is not null"
+            // must not result in the index to check for
+            // "b.y is null", because that would alter the
+            // result
+            return;
+        }
         // ignore
         // TODO convert NOT conditions
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1404926&r1=1404925&r2=1404926&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Fri Nov  2 11:23:07 2012
@@ -126,13 +126,20 @@ public class SelectorImpl extends Source
         if (joinCondition != null) {
             joinCondition.restrict(f);
         }
-        if (!outerJoin) {
-            // for outer joins, query constraints can't be applied to the
-            // filter, because that would alter the result
-            if (queryConstraint != null) {
-                queryConstraint.restrict(f);
-            }
+        
+        // all conditions can be pushed to the selectors -
+        // except in some cases to "outer joined" selectors,
+        // but the exceptions are handled in the condition
+        // itself.
+        // An example where it *is* a problem:
+        //  "select * from a left outer join b on a.x = b.y
+        // where b.y is null" - in this case the selector b
+        // must not use an index condition on "y is null"
+        // (".. is null" must be written as "not .. is not null").
+        if (queryConstraint != null) {
+            queryConstraint.restrict(f);
         }
+
         return f;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?rev=1404926&r1=1404925&r2=1404926&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
Fri Nov  2 11:23:07 2012
@@ -22,6 +22,8 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.plugins.index.IndexHookManager;
 import org.apache.jackrabbit.oak.plugins.nodetype.InitialContent;
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * Tests the query engine using the default index implementation: the
@@ -44,5 +46,18 @@ public class LuceneIndexQueryTest extend
             .with(new IndexHookManager(new LuceneIndexHookProvider()))
             .createContentRepository();
     }
+    
+    @Test
+    @Ignore("OAK-420")
+    public void sql2() throws Exception {
+        test("sql2.txt");
+    }
+
+    @Test
+    @Ignore("OAK-420")
+    public void sql2Measure() throws Exception {
+        test("sql2_measure.txt");
+    }
+
 
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1404926&r1=1404925&r2=1404926&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Fri Nov  2 11:23:07 2012
@@ -118,7 +118,6 @@ public abstract class AbstractQueryTest 
     }
 
     @Test
-    @Ignore("OAK-336")
     public void sql2Measure() throws Exception {
         test("sql2_measure.txt");
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt?rev=1404926&r1=1404925&r2=1404926&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
Fri Nov  2 11:23:07 2012
@@ -117,24 +117,7 @@ select * from [nt:base] as b where local
 /test/jcr:resource
 /test/resource
 
-select * from [nt:base] as x where isdescendantnode(x, '/') and not isdescendantnode(x, '/jcr:system')
-/jcr:system
-/oak:index
-/oak:index/authorizableId
-/oak:index/members
-/oak:index/primaryType
-/oak:index/principalName
-/oak:index/test-index
-/oak:index/uuid
-/rep:security
-/rep:security/rep:authorizables
-/rep:security/rep:authorizables/rep:users
-/rep:security/rep:authorizables/rep:users/a
-/rep:security/rep:authorizables/rep:users/a/ad
-/rep:security/rep:authorizables/rep:users/a/ad/admin
-/rep:security/rep:authorizables/rep:users/a/an
-/rep:security/rep:authorizables/rep:users/a/an/anonymous
-/test
+select * from [nt:base] as x where isdescendantnode(x, '/test')
 /test/jcr:resource
 /test/resource
 /test/resource/x
@@ -207,91 +190,41 @@ select * from [nt:base] as p inner join 
 commit / - "parents"
 commit / - "children"
 
-commit / + "test": { "hello": { "x": "1" }, "world": { "x": "2" } }
-commit / + "test2": { "id":"1", "x": "2" }
-
-select * from [nt:base] where not isdescendantnode('/jcr:system')
-/
-/jcr:system
-/oak:index
-/oak:index/authorizableId
-/oak:index/members
-/oak:index/primaryType
-/oak:index/principalName
-/oak:index/test-index
-/oak:index/uuid
-/rep:security
-/rep:security/rep:authorizables
-/rep:security/rep:authorizables/rep:users
-/rep:security/rep:authorizables/rep:users/a
-/rep:security/rep:authorizables/rep:users/a/ad
-/rep:security/rep:authorizables/rep:users/a/ad/admin
-/rep:security/rep:authorizables/rep:users/a/an
-/rep:security/rep:authorizables/rep:users/a/an/anonymous
-/test
-/test/hello
-/test/world
-/test2
+commit / + "testRoot": {}
+commit /testRoot + "test": { "hello": { "x": "1" }, "world": { "x": "2" } }
+commit /testRoot + "test2": { "id":"1", "x": "2" }
+
+select * from [nt:base] where isdescendantnode('/testRoot')
+/testRoot/test
+/testRoot/test/hello
+/testRoot/test/world
+/testRoot/test2
 
 select * from [nt:base] where id = '1'
-/test2
+/testRoot/test2
 
 select * from [nt:base] where id = '1' and x = '2'
-/test2
+/testRoot/test2
 
 select * from [nt:base] where id = '1' or x = '2'
-/test/world
-/test2
-
-select * from [nt:base] where not (id = '1' or x = '2') and not isdescendantnode('/jcr:system')
-/
-/jcr:system
-/oak:index
-/oak:index/authorizableId
-/oak:index/members
-/oak:index/primaryType
-/oak:index/principalName
-/oak:index/test-index
-/oak:index/uuid
-/rep:security
-/rep:security/rep:authorizables
-/rep:security/rep:authorizables/rep:users
-/rep:security/rep:authorizables/rep:users/a
-/rep:security/rep:authorizables/rep:users/a/ad
-/rep:security/rep:authorizables/rep:users/a/ad/admin
-/rep:security/rep:authorizables/rep:users/a/an
-/rep:security/rep:authorizables/rep:users/a/an/anonymous
-/test
-/test/hello
-
-select * from [nt:base] where x is null and not isdescendantnode('/jcr:system')
-/
-/jcr:system
-/oak:index
-/oak:index/authorizableId
-/oak:index/members
-/oak:index/primaryType
-/oak:index/principalName
-/oak:index/test-index
-/oak:index/uuid
-/rep:security
-/rep:security/rep:authorizables
-/rep:security/rep:authorizables/rep:users
-/rep:security/rep:authorizables/rep:users/a
-/rep:security/rep:authorizables/rep:users/a/ad
-/rep:security/rep:authorizables/rep:users/a/ad/admin
-/rep:security/rep:authorizables/rep:users/a/an
-/rep:security/rep:authorizables/rep:users/a/an/anonymous
-/test
-
-commit / - "test"
-commit / - "test2"
+/testRoot/test/world
+/testRoot/test2
 
-commit / + "test": { "name": "hello" }
-commit / + "test2": { "name": "World!" }
-commit / + "test3": { "name": "Hallo" }
-commit / + "test4": { "name": "10%" }
-commit / + "test5": { "name": "10 percent" }
+select * from [nt:base] where not (id = '1' or x = '2') and isdescendantnode('/testRoot')
+/testRoot/test
+/testRoot/test/hello
+
+select * from [nt:base] where x is null and isdescendantnode('/testRoot')
+/testRoot/test
+
+commit /testRoot - "test"
+commit /testRoot - "test2"
+
+commit /testRoot + "test": { "name": "hello" }
+commit /testRoot + "test2": { "name": "World!" }
+commit /testRoot + "test3": { "name": "Hallo" }
+commit /testRoot + "test4": { "name": "10%" }
+commit /testRoot + "test5": { "name": "10 percent" }
 
 select name from [nt:base] where name is not null order by upper(name)
 10 percent
@@ -301,35 +234,35 @@ hello
 World!
 
 select * from [nt:base] where length(name) = 5
-/test
-/test3
+/testRoot/test
+/testRoot/test3
 
 select * from [nt:base] where upper(name) = 'HELLO'
-/test
+/testRoot/test
 
 select * from [nt:base] where lower(name) = 'world!'
-/test2
+/testRoot/test2
 
 select * from [nt:base] where name like 'W%'
-/test2
+/testRoot/test2
 
 select * from [nt:base] where name like '%o_%'
-/test2
+/testRoot/test2
 
 select * from [nt:base] where name like '__llo'
-/test
-/test3
+/testRoot/test
+/testRoot/test3
 
 select * from [nt:base] where upper(name) like 'H_LLO'
-/test
-/test3
+/testRoot/test
+/testRoot/test3
 
 select * from [nt:base] where upper(name) like 'H\_LLO'
 
 select * from [nt:base] where upper(name) like '10%'
-/test4
-/test5
+/testRoot/test4
+/testRoot/test5
 
 select * from [nt:base] where upper(name) like '10\%'
-/test4
+/testRoot/test4
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt?rev=1404926&r1=1404925&r2=1404926&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_measure.txt
Fri Nov  2 11:23:07 2012
@@ -23,56 +23,67 @@
 # * new tests are typically be added on top, after the syntax docs
 # * use ascii character only
 
-commit / + "parents": { "p0": {"id": "0"}, "p1": {"id": "1"}, "p2": {"id": "2"}}
-commit / + "children": { "c1": {"p": "1"}, "c2": {"p": "1"}, "c3": {"p": "2"}, "c4": {"p":
"3"}}
-
-measure select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where
p.id is not null and not isdescendantnode(p, '/jcr:system')
-c, 669
-p, 223
-query, 4
-
-measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null
-c, 669
-p, 223
-query, 4
-
-measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is null
-c, 669
-p, 223
-query, 1
+commit / + "testRoot": { }
+commit /testRoot + "parents": { "p0": {"id": "0"}, "p1": {"id": "1"}, "p2": {"id": "2"}}
+commit /testRoot + "children": { "c1": {"p": "1"}, "c2": {"p": "1"}, "c3": {"p": "2"}, "c4":
{"p": "3"}}
+
+select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where p.id is
not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+/testRoot/children/c1, /testRoot/parents/p1
+/testRoot/children/c2, /testRoot/parents/p1
+/testRoot/children/c3, /testRoot/parents/p2
+
+measure select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where
p.id is not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
+query, 3
 
-measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is not null
-c, 669
-p, 223
+select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id is not
null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+/testRoot/parents/p1, /testRoot/children/c1
+/testRoot/parents/p1, /testRoot/children/c2
+/testRoot/parents/p2, /testRoot/children/c3
+
+measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
 query, 3
 
-measure select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
-c, 669
-p, 223
+measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
+query, 0
+
+measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c,
'/testRoot')
+c, 30
+p, 10
 query, 3
 
-measure select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where
p.id is not null and not isdescendantnode(p, '/jcr:system')
-c, 669
-p, 223
-query, 4
+measure select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p where isdescendantnode(p,
'/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
+query, 3
 
-measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null
-c, 669
-p, 223
-query, 4
+measure select * from [nt:base] as c right outer join [nt:base] as p on p.id = c.p where
p.id is not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
+query, 3
 
-measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is null
-c, 669
-p, 223
-query, 1
+measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
+query, 3
 
-measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is not null
-c, 669
-p, 223
+measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is null and isdescendantnode(p, '/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
+query, 0
+
+measure select * from [nt:base] as p left outer join [nt:base] as c on p.id = c.p where p.id
is not null and c.p is not null and isdescendantnode(p, '/testRoot') and isdescendantnode(c,
'/testRoot')
+c, 30
+p, 10
 query, 3
 
-measure select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
-c, 669
-p, 223
+measure select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p where isdescendantnode(p,
'/testRoot') and isdescendantnode(c, '/testRoot')
+c, 30
+p, 10
 query, 3
 



Mime
View raw message