jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1496970 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
Date Wed, 26 Jun 2013 15:28:34 GMT
Author: thomasm
Date: Wed Jun 26 15:28:34 2013
New Revision: 1496970

URL: http://svn.apache.org/r1496970
Log:
OAK-882 Query: support conditions of type "property in(value1, value2)"

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java?rev=1496970&r1=1496969&r2=1496970&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
Wed Jun 26 15:28:34 2013
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import com.google.common.base.Charsets;
+import com.google.common.collect.Iterables;
 
 /**
  * Provides a QueryIndex that does lookups against a property index
@@ -131,6 +132,12 @@ class PropertyIndex implements QueryInde
                     && pr.first != null && pr.first.equals(pr.last)) {
                     // "[property] = $value"
                     return lookup.getCost(filter, propertyName, pr.first);
+                } else if (pr.list != null) {
+                    double cost = 0;
+                    for (PropertyValue p : pr.list) {
+                        cost += lookup.getCost(filter, propertyName, p);
+                    }
+                    return cost;
                 } else {
                     // processed as "[property] is not null"
                     return lookup.getCost(filter, propertyName, null);
@@ -159,6 +166,16 @@ class PropertyIndex implements QueryInde
                     // "[property] = $value"
                     paths = lookup.query(filter, propertyName, pr.first);
                     break;
+                } else if (pr.list != null) {
+                    for (PropertyValue pv : pr.list) {
+                        Iterable<String> p = lookup.query(filter, propertyName, pv);
+                        if (paths == null) {
+                            paths = p;
+                        } else {
+                            paths = Iterables.concat(paths, p);
+                        }
+                    }
+                    break;
                 } else {
                     // processed as "[property] is not null"
                     paths = lookup.query(filter, propertyName, null);
@@ -192,6 +209,16 @@ class PropertyIndex implements QueryInde
                 } else {
                     buff.append(' ').append(propertyName);
                 }
+            } else if (pr.list != null) {
+                buff.append(' ').append(propertyName).append(" IN(");
+                int i = 0;
+                for (PropertyValue pv : pr.list) {
+                    if (i++ > 0) {
+                        buff.append(", ");
+                    }
+                    buff.append(pv);
+                }
+                buff.append(')');
             } else {
                 notIndexed.append(' ').append(propertyName);
                 if (!pr.toString().isEmpty()) {



Mime
View raw message