jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1376004 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
Date Wed, 22 Aug 2012 11:45:42 GMT
Author: thomasm
Date: Wed Aug 22 11:45:42 2012
New Revision: 1376004

URL: http://svn.apache.org/viewvc?rev=1376004&view=rev
Log:
OAK-261 Support querying on property types

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java?rev=1376004&r1=1376003&r2=1376004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
Wed Aug 22 11:45:42 2012
@@ -44,29 +44,36 @@ public class PrefixContentIndex implemen
 
     @Override
     public double getCost(Filter filter) {
-        Filter.PropertyRestriction restriction = filter.getPropertyRestriction("*");
-        if (restriction == null) {
-            return Double.MAX_VALUE;
+        if (getPropertyTypeRestriction(filter) != null) {
+            return 100;
         }
-        if (restriction.first != restriction.last) {
-            // only support equality matches (for now)
-            return Double.MAX_VALUE;
-        }
-        if (restriction.propertyType == PropertyType.UNDEFINED) {
-            return Double.MAX_VALUE;
-        }
-        String hint = CoreValueMapper.getHintForType(restriction.propertyType);
-        String prefix = hint + ":";
-        if (!prefix.equals(index.getPrefix())) {
-            // wrong prefix (wrong property type)
-            return Double.MAX_VALUE;
+        return Double.MAX_VALUE;
+    }
+
+    private Filter.PropertyRestriction getPropertyTypeRestriction(Filter filter) {
+        for (Filter.PropertyRestriction restriction : filter.getPropertyRestrictions()) {
+            if (restriction == null) {
+                continue;
+            }
+            if (restriction.first != restriction.last) {
+                // only support equality matches (for now)
+                continue;
+            }
+            if (restriction.propertyType == PropertyType.UNDEFINED) {
+                continue;
+            }
+            String hint = CoreValueMapper.getHintForType(restriction.propertyType);
+            String prefix = hint + ":";
+            if (prefix.equals(index.getPrefix())) {
+                return restriction;
+            }
         }
-        return 100;
+        return null;
     }
 
     @Override
     public String getPlan(Filter filter) {
-        Filter.PropertyRestriction restriction = filter.getPropertyRestriction("*");
+        Filter.PropertyRestriction restriction = getPropertyTypeRestriction(filter);
         if (restriction == null) {
             throw new IllegalArgumentException("No restriction for *");
         }
@@ -78,7 +85,7 @@ public class PrefixContentIndex implemen
 
     @Override
     public Cursor query(Filter filter, String revisionId, NodeState root) {
-        Filter.PropertyRestriction restriction = filter.getPropertyRestriction("*");
+        Filter.PropertyRestriction restriction = getPropertyTypeRestriction(filter);
         if (restriction == null) {
             throw new IllegalArgumentException("No restriction for *");
         }



Mime
View raw message