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 2012/08/22 13:45:42 UTC
svn commit: r1376004 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PrefixContentIndex.java
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 *");
}