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 2014/07/08 08:39:10 UTC

svn commit: r1608671 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java test/resources/org/apache/jackrabbit/oak/query/sql2.txt

Author: thomasm
Date: Tue Jul  8 06:39:10 2014
New Revision: 1608671

URL: http://svn.apache.org/r1608671
Log:
OAK-1933 Query: UnsupportedOperationException for some combinations of "or" and "and" conditions

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java?rev=1608671&r1=1608670&r2=1608671&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AndImpl.java Tue Jul  8 06:39:10 2014
@@ -110,7 +110,13 @@ public class AndImpl extends ConstraintI
         for (Entry<DynamicOperandImpl, Set<StaticOperandImpl>> e2 : m2.entrySet()) {
             Set<StaticOperandImpl> s = result.get(e2.getKey());
             if (s != null) {
-                s.retainAll(e2.getValue());
+                // OAK-1933
+                // a property can have multiple values at the same time,
+                // so that "where a=1 and a=2" needs to be kept and can not
+                // be reduced to "where false" - in fact, we could 
+                // extend it to "where a in (1, 2)" so that an index can be used,
+                // but we might as well keep it at "where a = 1" as that would
+                // also use an index
             } else {
                 result.put(e2.getKey(), e2.getValue());
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java?rev=1608671&r1=1608670&r2=1608671&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java Tue Jul  8 06:39:10 2014
@@ -194,8 +194,8 @@ public interface QueryIndex {
         double getCostPerEntry();
 
         /**
-         * The estimated number of entries. This value does not have to be
-         * accurate.
+         * The estimated number of entries in the cursor that is returned by the query method,
+         * when using this plan. This value does not have to be accurate.
          * 
          * @return the estimated number of entries
          */

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=1608671&r1=1608670&r2=1608671&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 Tue Jul  8 06:39:10 2014
@@ -29,6 +29,9 @@
 
 commit / + "test": { "a": { "name": "Hello" }, "b": { "name" : "World" }}
 
+select * from [nt:base] 
+  where [a] = 1 and [b] = 2 and [b] = 3 or [c] = 4
+
 select [jcr:path]
   from [nt:base]
   where [a/name] = 'Hello' or [b/name] = 'World'