jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1532358 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/ oak-core/src/main/java/or...
Date Tue, 15 Oct 2013 14:30:15 GMT
Author: alexparvulescu
Date: Tue Oct 15 14:30:15 2013
New Revision: 1532358

URL: http://svn.apache.org/r1532358
Log:
OAK-1052 Introduce execution context for executing queries
 - improved javadocs on the contextand other tiny refactorings


Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ExecutionContext.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
    jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ExecutionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ExecutionContext.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ExecutionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ExecutionContext.java
Tue Oct 15 14:30:15 2013
@@ -44,6 +44,10 @@ public class ExecutionContext {
     }
 
     /**
+     * 
+     * Used to evaluate the query (ie. read the existing node types, index
+     * definitions), doesn't need to be a secured version of a node state
+     * 
      * @return Root node state of the content tree against which the query runs.
      */
     @Nonnull
@@ -52,6 +56,10 @@ public class ExecutionContext {
     }
 
     /**
+     * 
+     * Used to create the actual query results from the indexed paths, needs to
+     * be a secured version of a tree to take into account ACLs
+     * 
      * @return Root tree of the content tree against which the query runs.
      */
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
Tue Oct 15 14:30:15 2013
@@ -23,7 +23,6 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.query.ast.ColumnImpl;
 import org.apache.jackrabbit.oak.query.ast.OrderingImpl;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 /**
  * A "select" or "union" query.
@@ -34,9 +33,7 @@ import org.apache.jackrabbit.oak.spi.sta
  */
 public interface Query {
 
-    void setRootTree(Tree rootTree);
-
-    void setRootState(NodeState rootState);
+    void setExecutionContext(ExecutionContext context);
 
     void setNamePathMapper(NamePathMapper namePathMapper);
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
Tue Oct 15 14:30:15 2013
@@ -135,8 +135,7 @@ public abstract class QueryEngineImpl im
 
         ExecutionContext context = getExecutionContext();
         Query q = parseQuery(statement, language, context);
-        q.setRootTree(context.getRootTree());
-        q.setRootState(context.getRootState());
+        q.setExecutionContext(context);
         q.setNamePathMapper(namePathMapper);
         q.setLimit(limit);
         q.setOffset(offset);
@@ -171,7 +170,7 @@ public abstract class QueryEngineImpl im
         this.traversalFallback = traversal;
     }
 
-    public static QueryIndex getBestIndex(QueryImpl query, NodeState rootState, Filter filter,
+    public static QueryIndex getBestIndex(NodeState rootState, Filter filter,
             QueryIndexProvider indexProvider) {
         QueryIndex best = null;
         if (LOG.isDebugEnabled()) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
Tue Oct 15 14:30:15 2013
@@ -103,8 +103,7 @@ public class QueryImpl implements Query 
     private long offset;
     private long size = -1;
     private boolean prepared;
-    private Tree rootTree;
-    private NodeState rootState;
+    private ExecutionContext context;
     private NamePathMapper namePathMapper;
 
     QueryImpl(String statement, SourceImpl source, ConstraintImpl constraint, ColumnImpl[]
columns) {
@@ -375,7 +374,7 @@ public class QueryImpl implements Query 
             LOG.debug("query execute {} ", statement);
             LOG.debug("query plan {}", getPlan());
         }
-        RowIterator rowIt = new RowIterator(rootState);
+        RowIterator rowIt = new RowIterator(context.getRootState());
         Comparator<ResultRowImpl> orderBy = ResultRowImpl.getComparator(orderings);
         Iterator<ResultRowImpl> it = 
                 FilterIterators.newCombinedFilter(rowIt, distinct, limit, offset, orderBy);
@@ -414,7 +413,7 @@ public class QueryImpl implements Query 
     
     @Override
     public String getPlan() {
-        return source.getPlan(rootState);
+        return source.getPlan(context.getRootState());
     }
 
     @Override
@@ -577,23 +576,15 @@ public class QueryImpl implements Query 
     }
 
     public QueryIndex getBestIndex(Filter filter) {
-        return QueryEngineImpl.getBestIndex(this, rootState, filter, indexProvider);
+        return QueryEngineImpl.getBestIndex(context.getRootState(), filter,
+                indexProvider);
     }
 
     @Override
-    public void setRootTree(Tree rootTree) {
-        this.rootTree = rootTree;
+    public void setExecutionContext(ExecutionContext context) {
+        this.context = context;
     }
-    
-    public Tree getRootTree() {
-        return rootTree;
-    }
-    
-    @Override
-    public void setRootState(NodeState rootState) {
-        this.rootState = rootState;
-    }
-    
+
     @Override
     public void setOrderings(OrderingImpl[] orderings) {
         this.orderings = orderings;
@@ -610,7 +601,7 @@ public class QueryImpl implements Query 
 
     @Override
     public Tree getTree(String path) {
-        return TreeUtil.getTree(rootTree, PathUtils.isAbsolute(path) ? path.substring(1)
: path);
+        return TreeUtil.getTree(context.getRootTree(), PathUtils.isAbsolute(path) ? path.substring(1)
: path);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java
Tue Oct 15 14:30:15 2013
@@ -20,7 +20,6 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 
-import com.google.common.collect.Iterators;
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -29,10 +28,11 @@ import org.apache.jackrabbit.oak.query.a
 import org.apache.jackrabbit.oak.query.ast.OrderingImpl;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Iterators;
+
 /**
  * Represents a union query.
  */
@@ -57,18 +57,12 @@ public class UnionQueryImpl implements Q
     }
 
     @Override
-    public void setRootTree(Tree rootTree) {
-        left.setRootTree(rootTree);
-        right.setRootTree(rootTree);
+    public void setExecutionContext(ExecutionContext context) {
+        left.setExecutionContext(context);
+        right.setExecutionContext(context);
     }
 
     @Override
-    public void setRootState(NodeState rootState) {
-        left.setRootState(rootState);
-        right.setRootState(rootState);
-    }
-    
-    @Override
     public void setOrderings(OrderingImpl[] orderings) {
         if (orderings == null) {
             left.setOrderings(null);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Tue Oct 15 14:30:15 2013
@@ -227,7 +227,7 @@ public class SelectorImpl extends Source
      * @return the filter
      */
     private Filter createFilter(boolean preparing) {
-        FilterImpl f = new FilterImpl(this, query.getStatement(), query.getRootTree());
+        FilterImpl f = new FilterImpl(this, query.getStatement());
         f.setPreparing(preparing);
         if (joinCondition != null) {
             joinCondition.restrict(f);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
Tue Oct 15 14:30:15 2013
@@ -31,7 +31,6 @@ import javax.annotation.Nullable;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.api.PropertyValue;
-import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
@@ -87,23 +86,16 @@ public class FilterImpl implements Filte
      * Set during the prepare phase of a query.
      */
     private boolean preparing;
-    
-    private Tree rootTree;
 
     // TODO support "order by"
     
     public FilterImpl() {
-        this(null, null, null);
+        this(null, null);
     }
 
     public FilterImpl(SelectorImpl selector, String queryStatement) {
-        this(selector, queryStatement, null);
-    }
-
-    public FilterImpl(SelectorImpl selector, String queryStatement, Tree rootTree) {
         this.selector = selector;
         this.queryStatement = queryStatement;
-        this.rootTree = rootTree;
         this.matchesAllTypes = selector != null ? selector.matchesAllTypes()
                 : false;
     }
@@ -118,7 +110,6 @@ public class FilterImpl implements Filte
         this.pathRestriction = impl.pathRestriction;
         this.propertyRestrictions.putAll(impl.propertyRestrictions);
         this.queryStatement = impl.queryStatement;
-        this.rootTree = impl.rootTree;
         this.selector = impl.selector;
         this.matchesAllTypes = selector != null ? selector.matchesAllTypes()
                 : false;
@@ -158,11 +149,6 @@ public class FilterImpl implements Filte
     public void setDistinct(boolean distinct) {
         this.distinct = distinct;
     }
-    
-    @Override
-    public Tree getRootTree() {
-        return rootTree;
-    }
 
     public void setAlwaysFalse() {
         propertyRestrictions.clear();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
Tue Oct 15 14:30:15 2013
@@ -27,7 +27,6 @@ import javax.annotation.Nullable;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.api.PropertyValue;
-import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.query.fulltext.FullTextExpression;
 
 /**
@@ -64,13 +63,6 @@ public interface Filter {
      * @return the condition (null if none)
      */
     FullTextExpression getFullTextConstraint();
-    
-    /**
-     * Get the root tree to read data.
-     * 
-     * @return the tree
-     */
-    Tree getRootTree();
 
     /**
      * Get the property restriction for the given property, if any.

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
Tue Oct 15 14:30:15 2013
@@ -200,7 +200,7 @@ public class IndexUpdateTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(NT_BASE);
         SelectorImpl selector = new SelectorImpl(type, NT_BASE);
-        Filter filter = new FilterImpl(selector, "SELECT * FROM [nt:base]", null);
+        Filter filter = new FilterImpl(selector, "SELECT * FROM [nt:base]");
         return Sets.newHashSet(lookup.query(filter, name,
                 PropertyValues.newString(value)));
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
Tue Oct 15 14:30:15 2013
@@ -103,7 +103,7 @@ public class NodeTypeIndexTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(nodeTypeName);
         SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
-        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", null);
+        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]");
     }
 
     private static void checkCursor(Cursor cursor, String... matches) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
Tue Oct 15 14:30:15 2013
@@ -240,7 +240,7 @@ public class PropertyIndexTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(nodeTypeName);
         SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
-        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", null);
+        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]");
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1532358&r1=1532357&r2=1532358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
Tue Oct 15 14:30:15 2013
@@ -145,8 +145,7 @@ public class LuceneIndexTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(nodeTypeName);
         SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
-        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]",
-                null);
+        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]");
     }
 
     @Test



Mime
View raw message