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 ch...@apache.org on 2014/10/31 04:28:34 UTC

svn commit: r1635658 - /jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java

Author: chetanm
Date: Fri Oct 31 03:28:34 2014
New Revision: 1635658

URL: http://svn.apache.org/r1635658
Log:
OAK-1980 - Use index on non-root node

Pulling in only QueryIndex related changes from revision 1615904

Modified:
    jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java

Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java?rev=1635658&r1=1635657&r2=1635658&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java Fri Oct 31 03:28:34 2014
@@ -27,6 +27,8 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.plugins.index.aggregate.NodeAggregator;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction;
+
 /**
  * Represents an index. The index should use the data in the filter if possible
  * to speed up reading.
@@ -162,7 +164,7 @@ public interface QueryIndex {
          * used.
          * 
          * @param plan the index plan to use
-         * @param rootState root state of the current repository snapshot
+         * @param root root state of the current repository snapshot
          * @return a cursor to iterate over the result
          */
         Cursor query(IndexPlan plan, NodeState rootState);
@@ -242,6 +244,29 @@ public interface QueryIndex {
          * @return the sort order
          */
         List<OrderEntry> getSortOrder();
+
+        /**
+         * The node state with the index definition.
+         *
+         * @return the node state with the index definition.
+         */
+        NodeState getDefinition();
+
+        /**
+         * The path prefix for this index plan.
+         * @return
+         */
+        String getPathPrefix();
+
+        /**
+         * The property restriction for this index plan or <code>null</code> if
+         * this index plan isn't base on a property restriction. E.g. a plan
+         * based on an order by clause in the query.
+         *
+         * @return the restriction this plan is based on or <code>null</code>.
+         */
+        @CheckForNull
+        PropertyRestriction getPropertyRestriction();
         
         /**
          * A builder for index plans.
@@ -256,6 +281,9 @@ public interface QueryIndex {
             protected boolean isFulltextIndex;
             protected boolean includesNodeData;
             protected List<OrderEntry> sortOrder;
+            protected NodeState definition;
+            protected PropertyRestriction propRestriction;
+            protected String pathPrefix = "/";
 
             public Builder setCostPerExecution(double costPerExecution) {
                 this.costPerExecution = costPerExecution;
@@ -296,7 +324,22 @@ public interface QueryIndex {
                 this.sortOrder = sortOrder;
                 return this;
             }
-            
+
+            public Builder setDefinition(NodeState definition) {
+                this.definition = definition;
+                return this;
+            }
+
+            public Builder setPropertyRestriction(PropertyRestriction restriction) {
+                this.propRestriction = restriction;
+                return this;
+            }
+
+            public Builder setPathPrefix(String pathPrefix) {
+                this.pathPrefix = pathPrefix;
+                return this;
+            }
+
             public IndexPlan build() {
                 
                 return new IndexPlan() {
@@ -318,7 +361,14 @@ public interface QueryIndex {
                     private final List<OrderEntry> sortOrder = 
                             Builder.this.sortOrder == null ?
                             null : new ArrayList<OrderEntry>(
-                                    Builder.this.sortOrder);                  
+                                    Builder.this.sortOrder);
+                    private final NodeState definition =
+                            Builder.this.definition;
+                    private final PropertyRestriction propRestriction =
+                            Builder.this.propRestriction;
+                    private final String pathPrefix =
+                            Builder.this.pathPrefix;
+
                     @Override
                     public String toString() {
                         return String.format(
@@ -329,7 +379,10 @@ public interface QueryIndex {
                             + " isDelayed : %s,"
                             + " isFulltextIndex : %s,"
                             + " includesNodeData : %s,"
-                            + " sortOrder : %s }",
+                            + " sortOrder : %s,"
+                            + " definition : %s,"
+                            + " propertyRestriction : %s,"
+                            + " pathPrefix : %s }",
                             costPerExecution,
                             costPerEntry,
                             estimatedEntryCount,
@@ -337,7 +390,10 @@ public interface QueryIndex {
                             isDelayed,
                             isFulltextIndex,
                             includesNodeData,
-                            sortOrder
+                            sortOrder,
+                            definition,
+                            propRestriction,
+                            pathPrefix
                             );
                     }
 
@@ -385,10 +441,24 @@ public interface QueryIndex {
                     public List<OrderEntry> getSortOrder() {
                         return sortOrder;
                     }
-                    
+
+                    @Override
+                    public NodeState getDefinition() {
+                        return definition;
+                    }
+
+                    @Override
+                    public PropertyRestriction getPropertyRestriction() {
+                        return propRestriction;
+                    }
+
+                    @Override
+                    public String getPathPrefix() {
+                        return pathPrefix;
+                    }
                 };
             }
-                
+
         }
 
     }