jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1420138 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: query/ query/ast/ query/index/ spi/query/
Date Tue, 11 Dec 2012 12:57:51 GMT
Author: thomasm
Date: Tue Dec 11 12:57:48 2012
New Revision: 1420138

URL: http://svn.apache.org/viewvc?rev=1420138&view=rev
Log:
OAK-355 Move QueryEngine reference from ContentSession to Root / rename "root" parameters
and fields

Modified:
    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/ResultImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.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/ast/SourceImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java

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=1420138&r1=1420137&r2=1420138&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 Dec 11 12:57:48 2012
@@ -92,7 +92,7 @@ public class Query {
     private long offset;
     private long size = -1;
     private boolean prepared;
-    private Root root;
+    private Root rootTree;
     private NamePathMapper namePathMapper;
 
     Query(String statement, SourceImpl source, ConstraintImpl constraint, OrderingImpl[]
orderings,
@@ -299,15 +299,15 @@ public class Query {
         this.measure = measure;
     }
 
-    public ResultImpl executeQuery(NodeState root) {
-        return new ResultImpl(this, root);
+    public ResultImpl executeQuery(NodeState rootState) {
+        return new ResultImpl(this, rootState);
     }
 
-    Iterator<ResultRowImpl> getRows(NodeState root) {
+    Iterator<ResultRowImpl> getRows(NodeState rootState) {
         prepare();
         Iterator<ResultRowImpl> it;
         if (explain) {
-            String plan = source.getPlan(root);
+            String plan = source.getPlan(rootState);
             columns = new ColumnImpl[] { new ColumnImpl("explain", "plan", "plan")};
             ResultRowImpl r = new ResultRowImpl(this,
                     new String[0], 
@@ -316,14 +316,14 @@ public class Query {
             it = Arrays.asList(r).iterator();
         } else {
             if (LOG.isDebugEnabled()) {
-                LOG.debug("plan: " + source.getPlan(root));
+                LOG.debug("plan: " + source.getPlan(rootState));
             }
             if (orderings == null) {
                 // can apply limit and offset directly
-                it = new RowIterator(root, limit, offset);
+                it = new RowIterator(rootState, limit, offset);
             } else {
                 // read and order first; skip and limit afterwards
-                it = new RowIterator(root, Long.MAX_VALUE, 0);
+                it = new RowIterator(rootState, Long.MAX_VALUE, 0);
             }
             long readCount = 0;
             if (orderings != null) {
@@ -450,13 +450,13 @@ public class Query {
      */
     class RowIterator implements Iterator<ResultRowImpl> {
 
-        private final NodeState root;
+        private final NodeState rootState;
         private ResultRowImpl current;
         private boolean started, end;
         private long limit, offset, rowIndex;
 
-        RowIterator(NodeState root, long limit, long offset) {
-            this.root = root;
+        RowIterator(NodeState rootState, long limit, long offset) {
+            this.rootState = rootState;
             this.limit = limit;
             this.offset = offset;
         }
@@ -470,7 +470,7 @@ public class Query {
                 return;
             }
             if (!started) {
-                source.execute(root);
+                source.execute(rootState);
                 started = true;
             }
             while (true) {
@@ -592,8 +592,8 @@ public class Query {
         return queryEngine.getBestIndex(this, filter);
     }
 
-    public void setRoot(Root root) {
-        this.root = root;
+    public void setRootTree(Root rootTree) {
+        this.rootTree = rootTree;
     }
 
     public void setNamePathMapper(NamePathMapper namePathMapper) {
@@ -605,7 +605,7 @@ public class Query {
     }
 
     public Tree getTree(String path) {
-        return root.getTree(path);
+        return rootTree.getTree(path);
     }
     
     /**

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=1420138&r1=1420137&r2=1420138&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 Dec 11 12:57:48 2012
@@ -47,11 +47,11 @@ public class QueryEngineImpl {
 
     private static final Logger LOG = LoggerFactory.getLogger(QueryEngineImpl.class);
 
-    private final NodeState root;
+    private final NodeState rootState;
     private final QueryIndexProvider indexProvider;
 
-    public QueryEngineImpl(NodeState root, QueryIndexProvider indexProvider) {
-        this.root = root;
+    public QueryEngineImpl(NodeState rootState, QueryIndexProvider indexProvider) {
+        this.rootState = rootState;
         this.indexProvider = indexProvider;
     }
 
@@ -108,10 +108,10 @@ public class QueryEngineImpl {
 
     public ResultImpl executeQuery(String statement, String language, 
             long limit, long offset, Map<String, ? extends PropertyValue> bindings,
-            Root root,
+            Root rootTree,
             NamePathMapper namePathMapper) throws ParseException {
         Query q = parseQuery(statement, language);
-        q.setRoot(root);
+        q.setRootTree(rootTree);
         q.setNamePathMapper(namePathMapper);
         q.setLimit(limit);
         q.setOffset(offset);
@@ -122,14 +122,14 @@ public class QueryEngineImpl {
         }
         q.setQueryEngine(this);
         q.prepare();
-        return q.executeQuery(this.root);
+        return q.executeQuery(this.rootState);
     }
 
     public QueryIndex getBestIndex(Query query, Filter filter) {
         QueryIndex best = null;
         double bestCost = Double.MAX_VALUE;
         for (QueryIndex index : getIndexes()) {
-            double cost = index.getCost(filter, root);
+            double cost = index.getCost(filter, rootState);
             if (LOG.isDebugEnabled()) {
                 LOG.debug("cost for " + index.getIndexName() + " is " + cost);
             }
@@ -148,7 +148,7 @@ public class QueryEngineImpl {
     }
 
     private List<? extends QueryIndex> getIndexes() {
-        return indexProvider.getQueryIndexes(root);
+        return indexProvider.getQueryIndexes(rootState);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java?rev=1420138&r1=1420137&r2=1420138&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java
Tue Dec 11 12:57:48 2012
@@ -30,11 +30,11 @@ import org.apache.jackrabbit.oak.spi.sta
 public class ResultImpl implements Result {
 
     protected final Query query;
-    protected final NodeState root;
+    protected final NodeState rootState;
 
-    ResultImpl(Query query, NodeState root) {
+    ResultImpl(Query query, NodeState rootState) {
         this.query = query;
-        this.root = root;
+        this.rootState = rootState;
     }
 
     @Override
@@ -63,7 +63,7 @@ public class ResultImpl implements Resul
 
             @Override
             public Iterator<ResultRowImpl> iterator() {
-                return query.getRows(root);
+                return query.getRows(rootState);
             }
 
         };

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java?rev=1420138&r1=1420137&r2=1420138&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/JoinImpl.java
Tue Dec 11 12:57:48 2012
@@ -30,7 +30,7 @@ public class JoinImpl extends SourceImpl
     private boolean leftNeedNext;
     private boolean foundJoinedRow;
     private boolean end;
-    private NodeState root;
+    private NodeState rootState;
 
     public JoinImpl(SourceImpl left, SourceImpl right, JoinType joinType,
             JoinConditionImpl joinCondition) {
@@ -58,9 +58,9 @@ public class JoinImpl extends SourceImpl
     }
 
     @Override
-    public String getPlan(NodeState root) {
-        return left.getPlan(root) + ' ' + joinType +
-                " " + right.getPlan(root) + " on " + joinCondition;
+    public String getPlan(NodeState rootState) {
+        return left.getPlan(rootState) + ' ' + joinType +
+                " " + right.getPlan(rootState) + " on " + joinCondition;
     }
 
     @Override
@@ -116,8 +116,8 @@ public class JoinImpl extends SourceImpl
     }
 
     @Override
-    public void execute(NodeState root) {
-        this.root = root;
+    public void execute(NodeState rootState) {
+        this.rootState = rootState;
         leftNeedExecute = true;
         end = false;
     }
@@ -128,7 +128,7 @@ public class JoinImpl extends SourceImpl
             return false;
         }
         if (leftNeedExecute) {
-            left.execute(root);
+            left.execute(rootState);
             leftNeedExecute = false;
             leftNeedNext = true;
         }
@@ -142,7 +142,7 @@ public class JoinImpl extends SourceImpl
                 rightNeedExecute = true;
             }
             if (rightNeedExecute) {
-                right.execute(root);
+                right.execute(rootState);
                 foundJoinedRow = false;
                 rightNeedExecute = false;
             }

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=1420138&r1=1420137&r2=1420138&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 Dec 11 12:57:48 2012
@@ -105,15 +105,15 @@ public class SelectorImpl extends Source
     }
 
     @Override
-    public void execute(NodeState root) {
-        cursor = index.query(createFilter(), root);
+    public void execute(NodeState rootState) {
+        cursor = index.query(createFilter(), rootState);
     }
 
     @Override
-    public String getPlan(NodeState root) {
+    public String getPlan(NodeState rootState) {
         StringBuilder buff = new StringBuilder();
         buff.append(toString());
-        buff.append(" /* ").append(index.getPlan(createFilter(), root));
+        buff.append(" /* ").append(index.getPlan(createFilter(), rootState));
         if (selectorCondition != null) {
             buff.append(" where ").append(selectorCondition);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java?rev=1420138&r1=1420137&r2=1420138&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SourceImpl.java
Tue Dec 11 12:57:48 2012
@@ -127,10 +127,10 @@ public abstract class SourceImpl extends
     /**
      * Get the query plan.
      *
-     * @param root the root
+     * @param rootState the root
      * @return the query plan
      */
-    public abstract String getPlan(NodeState root);
+    public abstract String getPlan(NodeState rootState);
 
     /**
      * Prepare executing the query. This method will decide which index to use.
@@ -141,9 +141,9 @@ public abstract class SourceImpl extends
     /**
      * Execute the query. The current node is set to before the first row.
      *
-     * @param root root state of the given revision
+     * @param rootState root state of the given revision
      */
-    public abstract void execute(NodeState root);
+    public abstract void execute(NodeState rootState);
 
     /**
      * Go to the next node for the given source. This will also filter the

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java?rev=1420138&r1=1420137&r2=1420138&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
Tue Dec 11 12:57:48 2012
@@ -31,12 +31,12 @@ import org.apache.jackrabbit.oak.spi.sta
 public class TraversingIndex implements QueryIndex {
 
     @Override
-    public Cursor query(Filter filter, NodeState root) {
-        return Cursors.newTraversingCursor(filter, root);
+    public Cursor query(Filter filter, NodeState rootState) {
+        return Cursors.newTraversingCursor(filter, rootState);
     }
 
     @Override
-    public double getCost(Filter filter, NodeState root) {
+    public double getCost(Filter filter, NodeState rootState) {
         String path = filter.getPath();
         // TODO estimate or read the node count
         double nodeCount = 10000000;
@@ -50,7 +50,7 @@ public class TraversingIndex implements 
     }
 
     @Override
-    public String getPlan(Filter filter, NodeState root) {
+    public String getPlan(Filter filter, NodeState rootState) {
         String p = filter.getPath();
         String r = filter.getPathRestriction().toString();
         if (PathUtils.denotesRoot(p)) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java?rev=1420138&r1=1420137&r2=1420138&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Cursors.java
Tue Dec 11 12:57:48 2012
@@ -58,12 +58,12 @@ public class Cursors {
      * {@link Filter}.
      *
      * @param filter    the filter.
-     * @param root      the root {@link NodeState}.
+     * @param rootState      the root {@link NodeState}.
      * @return the {@link Cursor}.
      */
     public static Cursor newTraversingCursor(Filter filter,
-                                             NodeState root) {
-        return new TraversingCursor(filter, root);
+                                             NodeState rootState) {
+        return new TraversingCursor(filter, rootState);
     }
     
     /**
@@ -127,14 +127,14 @@ public class Cursors {
         
         private boolean closed;
 
-        public TraversingCursor(Filter filter, NodeState root) {
+        public TraversingCursor(Filter filter, NodeState rootState) {
             this.filter = filter;
 
             String path = filter.getPath();
             parentPath = null;
             currentPath = "/";
             NodeState parent = null;
-            NodeState node = root;
+            NodeState node = rootState;
             if (!path.equals("/")) {
                 for (String name : path.substring(1).split("/")) {
                     parentPath = currentPath;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java?rev=1420138&r1=1420137&r2=1420138&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/QueryIndex.java
Tue Dec 11 12:57:48 2012
@@ -47,28 +47,28 @@ public interface QueryIndex {
      * estimated number of nodes to traverse.
      *
      * @param filter the filter
-     * @param root root state of the current repository snapshot
+     * @param rootState root state of the current repository snapshot
      * @return the estimated cost in number of read nodes
      */
-    double getCost(Filter filter, NodeState root);
+    double getCost(Filter filter, NodeState rootState);
 
     /**
      * Start a query.
      *
      * @param filter the filter
-     * @param root root state of the current repository snapshot
+     * @param rootState root state of the current repository snapshot
      * @return a cursor to iterate over the result
      */
-    Cursor query(Filter filter, NodeState root);
+    Cursor query(Filter filter, NodeState rootState);
 
     /**
      * Get the query plan for the given filter.
      *
      * @param filter the filter
-     * @param root root state of the current repository snapshot
+     * @param rootState root state of the current repository snapshot
      * @return the query plan
      */
-    String getPlan(Filter filter, NodeState root);
+    String getPlan(Filter filter, NodeState rootState);
 
     /**
      * Get the unique index name.



Mime
View raw message