jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1308742 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/query/ oak-core/src/test/java/org/apache/jack...
Date Tue, 03 Apr 2012 08:24:17 GMT
Author: thomasm
Date: Tue Apr  3 08:24:16 2012
New Revision: 1308742

URL: http://svn.apache.org/viewvc?rev=1308742&view=rev
Log:
OAK-34 Define query API (prototype)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Result.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
      - copied, changed from r1308726, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngine.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java
      - copied, changed from r1308726, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Result.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java
      - copied, changed from r1308726, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRow.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngine.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Result.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRow.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/RepositoryService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java
Tue Apr  3 08:24:16 2012
@@ -87,8 +87,13 @@ public interface Connection extends Clos
 
     NodeStateEditor getNodeStateEditor(NodeState state);
 
-    // TODO : add versioning operations
+    /**
+     * Get the query engine.
+     *
+     * @return the query engine
+     */
+    QueryEngine getQueryEngine();
 
-    // TODO : add query execution operations
+    // TODO : add versioning operations
 
 }
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java?rev=1308742&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/QueryEngine.java
Tue Apr  3 08:24:16 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.api;
+
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+import org.apache.jackrabbit.oak.query.CoreValue;
+
+/**
+ * The query engine allows to parse and execute queries.
+ * <p>
+ * At least the query languages {@code QueryEngine.XPATH} and {@code
+ * QueryEngine.SQL2} are supported. Other query languages might be supported
+ * depending on the configured query parsers.
+ */
+public interface QueryEngine {
+
+    /**
+     * The XPath query language.
+     */
+    String XPATH = "xpath";
+
+    /**
+     * The SQL-2 query language.
+     */
+    String SQL2 = "sql2";
+
+    /**
+     * Parse the query (check if it's valid) and get the list of bind variable names.
+     *
+     * @param statement
+     * @param language
+     * @return the list of bind variable names
+     * @throws ParseException
+     */
+    List<String> getBindVariableNames(String statement, String language) throws ParseException;
+
+    /**
+     * Execute a query and get the result.
+     *
+     * @param statement the query statement
+     * @param language the language
+     * @param bindings the bind variable value bindings
+     * @return the result
+     * @throws ParseException if the statement could not be parsed
+     */
+    Result executeQuery(String statement, String language, Map<String, CoreValue> bindings)
throws ParseException;
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/RepositoryService.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/RepositoryService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/RepositoryService.java
Tue Apr  3 08:24:16 2012
@@ -37,7 +37,7 @@ public interface RepositoryService {
      *
      * @param credentials
      * @param workspaceName
-     * @return
+     * @return the connection
      * @throws LoginException
      * @throws NoSuchWorkspaceException
      */

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Result.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Result.java?rev=1308742&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Result.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Result.java
Tue Apr  3 08:24:16 2012
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.api;
+
+import java.util.Iterator;
+
+/**
+ * A result from executing a query.
+ */
+public interface Result {
+
+    String[] getColumnNames();
+
+    String[] getSelectorNames();
+
+    Iterator<? extends ResultRow> getRows();
+
+}

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java?rev=1308742&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ResultRow.java
Tue Apr  3 08:24:16 2012
@@ -0,0 +1,18 @@
+package org.apache.jackrabbit.oak.api;
+
+import org.apache.jackrabbit.oak.query.CoreValue;
+
+/**
+ * A query result row.
+ */
+public interface ResultRow {
+
+    String getPath();
+
+    String getPath(String selectorName);
+
+    CoreValue getValue(String columnName);
+
+    CoreValue[] getValues();
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
Tue Apr  3 08:24:16 2012
@@ -23,7 +23,9 @@ import org.apache.jackrabbit.mk.model.No
 import org.apache.jackrabbit.oak.api.AuthInfo;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Connection;
+import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
+import org.apache.jackrabbit.oak.query.QueryEngineImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,15 +46,17 @@ public class ConnectionImpl implements C
     private final SimpleCredentials credentials;
     private final String workspaceName;
     private final NodeStore store;
+    private final QueryEngine queryEngine;
 
     private NodeState root;
 
     public ConnectionImpl(SimpleCredentials credentials, String workspaceName,
-            NodeStore store, NodeState root) {
+            NodeStore store, NodeState root, QueryEngine queryEngine) {
         this.credentials = credentials;
         this.workspaceName = workspaceName;
         this.store = store;
         this.root = root;
+        this.queryEngine = queryEngine;
     }
 
     static Connection createWorkspaceConnection(SimpleCredentials credentials,
@@ -63,8 +67,9 @@ public class ConnectionImpl implements C
         if (wspRoot == null) {
             throw new NoSuchWorkspaceException(workspace);
         }
+        QueryEngine queryEngine = new QueryEngineImpl(microKernel);
 
-        return new ConnectionImpl(credentials, workspace, store, wspRoot);
+        return new ConnectionImpl(credentials, workspace, store, wspRoot, queryEngine);
     }
 
     @Override
@@ -122,6 +127,12 @@ public class ConnectionImpl implements C
 
     @Override
     public Connection getRepositoryConnection() {
-        return new ConnectionImpl(credentials, null, store, store.getRoot());
+        return new ConnectionImpl(credentials, null, store, store.getRoot(), queryEngine);
     }
+
+    @Override
+    public QueryEngine getQueryEngine() {
+        return queryEngine;
+    }
+
 }
\ No newline at end of file

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=1308742&r1=1308741&r2=1308742&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 Apr  3 08:24:16 2012
@@ -260,29 +260,29 @@ public class Query {
         this.explain = explain;
     }
 
-    public Result executeQuery(String revisionId) {
+    public ResultImpl executeQuery(String revisionId) {
         prepare();
-        Iterator<ResultRow> it;
+        Iterator<ResultRowImpl> it;
         if (explain) {
             String plan = source.getPlan();
             columns = new ColumnImpl[] { new ColumnImpl("explain", "plan", "plan")};
-            ResultRow r = new ResultRow(this, new String[0], new CoreValue[] { valueFactory.createValue(plan)
}, null);
+            ResultRowImpl r = new ResultRowImpl(this, new String[0], new CoreValue[] { valueFactory.createValue(plan)
}, null);
             it = Arrays.asList(r).iterator();
         } else {
             it = new RowIterator(revisionId);
             if (orderings != null) {
                 // TODO "order by" is not necessary if the used index returns
                 // rows in the same order
-                ArrayList<ResultRow> list = new ArrayList<ResultRow>();
+                ArrayList<ResultRowImpl> list = new ArrayList<ResultRowImpl>();
                 while (it.hasNext()) {
-                    ResultRow r = it.next();
+                    ResultRowImpl r = it.next();
                     list.add(r);
                 }
                 Collections.sort(list);
                 it = list.iterator();
             }
         }
-        return new Result(this, it);
+        return new ResultImpl(this, it);
     }
 
     public int compareRows(CoreValue[] orderValues, CoreValue[] orderValues2) {
@@ -319,10 +319,10 @@ public class Query {
         source.prepare(mk);
     }
 
-    class RowIterator implements Iterator<ResultRow> {
+    class RowIterator implements Iterator<ResultRowImpl> {
 
         private final String revisionId;
-        private ResultRow current;
+        private ResultRowImpl current;
         private boolean started, end;
 
         RowIterator(String revisionId) {
@@ -363,14 +363,14 @@ public class Query {
         }
 
         @Override
-        public ResultRow next() {
+        public ResultRowImpl next() {
             if (end) {
                 return null;
             }
             if (current == null) {
                 fetchNext();
             }
-            ResultRow r = current;
+            ResultRowImpl r = current;
             current = null;
             return r;
         }
@@ -382,7 +382,7 @@ public class Query {
 
     }
 
-    ResultRow currentRow() {
+    ResultRowImpl currentRow() {
         int selectorCount = selectors.size();
         String[] paths = new String[selectorCount];
         for (int i = 0; i < selectorCount; i++) {
@@ -405,7 +405,7 @@ public class Query {
                 orderValues[i] = orderings[i].getOperand().currentValue();
             }
         }
-        return new ResultRow(this, paths, values, orderValues);
+        return new ResultRowImpl(this, paths, values, orderValues);
     }
 
     public int getSelectorIndex(String selectorName) {

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
(from r1308726, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngine.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngine.java&r1=1308726&r2=1308742&rev=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngine.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineImpl.java
Tue Apr  3 08:24:16 2012
@@ -21,17 +21,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.QueryEngine;
 
-public class QueryEngine {
-
-    public static final String XPATH = "xpath";
-    public static final String SQL2 = "sql2";
+public class QueryEngineImpl implements QueryEngine {
 
     private final MicroKernel mk;
     private final CoreValueFactory vf = new CoreValueFactory();
     private final SQL2Parser parserSQL2;
 
-    public QueryEngine(MicroKernel mk) {
+    public QueryEngineImpl(MicroKernel mk) {
         this.mk = mk;
         parserSQL2 = new SQL2Parser(vf);
     }
@@ -44,7 +42,8 @@ public class QueryEngine {
      * @return the list of bind variable names
      * @throws ParseException
      */
-    public List<String> parse(String statement, String language) throws ParseException
{
+    @Override
+    public List<String> getBindVariableNames(String statement, String language) throws
ParseException {
         Query q = parseQuery(statement, language);
         return q.getBindVariableNames();
 
@@ -64,7 +63,8 @@ public class QueryEngine {
         return q;
     }
 
-    public Result executeQuery(String statement, String language, Map<String, CoreValue>
bindings) throws ParseException {
+    @Override
+    public ResultImpl executeQuery(String statement, String language, Map<String, CoreValue>
bindings) throws ParseException {
         Query q = parseQuery(statement, language);
         q.setMicroKernel(mk);
         if (bindings != null) {

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java
(from r1308726, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Result.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Result.java&r1=1308726&r2=1308742&rev=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Result.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultImpl.java
Tue Apr  3 08:24:16 2012
@@ -18,22 +18,25 @@ package org.apache.jackrabbit.oak.query;
 
 import java.util.Iterator;
 import java.util.List;
+import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.query.ast.ColumnImpl;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
 
 /**
  * A query result.
  */
-public class Result {
+public class ResultImpl implements Result {
 
     private final Query query;
-    private final Iterator<ResultRow> it;
+    private final Iterator<ResultRowImpl> it;
 
-    Result(Query query, Iterator<ResultRow> it) {
+    ResultImpl(Query query, Iterator<ResultRowImpl> it) {
         this.query = query;
         this.it = it;
     }
 
+    @Override
     public String[] getColumnNames() {
         ColumnImpl[] cols = query.getColumns();
         String[] names = new String[cols.length];
@@ -43,6 +46,7 @@ public class Result {
         return names;
     }
 
+    @Override
     public String[] getSelectorNames() {
         List<SelectorImpl> selectors = query.getSelectors();
         String[] names = new String[selectors.size()];
@@ -52,7 +56,8 @@ public class Result {
         return names;
     }
 
-    public Iterator<ResultRow> getRows() {
+    @Override
+    public Iterator<? extends ResultRow> getRows() {
         return it;
     }
 

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java
(from r1308726, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRow.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRow.java&r1=1308726&r2=1308742&rev=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRow.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ResultRowImpl.java
Tue Apr  3 08:24:16 2012
@@ -16,26 +16,28 @@
  */
 package org.apache.jackrabbit.oak.query;
 
+import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.query.ast.ColumnImpl;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
 
 /**
  * A query result row that keeps all data in memory.
  */
-public class ResultRow implements Comparable<ResultRow> {
+public class ResultRowImpl implements ResultRow, Comparable<ResultRowImpl> {
 
     private final Query query;
     private final String[] paths;
     private final CoreValue[] values;
     private final CoreValue[] orderValues;
 
-    ResultRow(Query query, String[] paths, CoreValue[] values, CoreValue[] orderValues) {
+    ResultRowImpl(Query query, String[] paths, CoreValue[] values, CoreValue[] orderValues)
{
         this.query = query;
         this.paths = paths;
         this.values = values;
         this.orderValues = orderValues;
     }
 
+    @Override
     public String getPath() {
         if (paths.length > 1) {
             throw new IllegalArgumentException("More than one selector");
@@ -43,6 +45,7 @@ public class ResultRow implements Compar
         return paths[0];
     }
 
+    @Override
     public String getPath(String selectorName) {
         int index = query.getSelectorIndex(selectorName);
         if (paths == null || index >= paths.length) {
@@ -51,10 +54,12 @@ public class ResultRow implements Compar
         return paths[index];
     }
 
+    @Override
     public CoreValue getValue(String columnName) {
         return values[query.getColumnIndex(columnName)];
     }
 
+    @Override
     public CoreValue[] getValues() {
         CoreValue[] v2 = new CoreValue[values.length];
         System.arraycopy(values, 0, v2, 0, v2.length);
@@ -62,7 +67,7 @@ public class ResultRow implements Compar
     }
 
     @Override
-    public int compareTo(ResultRow o) {
+    public int compareTo(ResultRowImpl o) {
         return query.compareRows(orderValues, o.orderValues);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryTest.java
Tue Apr  3 08:24:16 2012
@@ -26,6 +26,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.ResultRow;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,13 +39,13 @@ public class QueryTest {
 
     MicroKernel mk;
     String head;
-    QueryEngine qe;
+    QueryEngineImpl qe;
 
     @Before
     public void setUp() {
         mk = MicroKernelFactory.getInstance("simple:/target/temp;clear");
         head = mk.getHeadRevision();
-        qe = new QueryEngine(mk);
+        qe = new QueryEngineImpl(mk);
     }
 
     @After
@@ -67,7 +69,7 @@ public class QueryTest {
         HashMap<String, CoreValue> sv = new HashMap<String, CoreValue>();
         CoreValueFactory vf = new CoreValueFactory();
         sv.put("id", vf.createValue("1"));
-        Iterator<ResultRow> result;
+        Iterator<? extends ResultRow> result;
         result = qe.executeQuery("select * from [nt:base] where id = $id", QueryEngine.SQL2,
sv).getRows();
         assertTrue(result.hasNext());
         assertEquals("/test/hello", result.next().getPath());
@@ -78,9 +80,9 @@ public class QueryTest {
         assertEquals("/test/world", result.next().getPath());
 
 
-        qe.executeQuery("explain select * from [nt:base] where id = 1 order by id", QueryEngine.SQL2,
null);
-
-
+        result = qe.executeQuery("explain select * from [nt:base] where id = 1 order by id",
QueryEngine.SQL2, null).getRows();
+        assertTrue(result.hasNext());
+        assertEquals("nt:base AS nt:base /* traverse \"//*\" */", result.next().getValue("plan").getString());
 
     }
 
@@ -115,7 +117,7 @@ public class QueryTest {
                     }
                 } else if (line.startsWith("select") || line.startsWith("explain")) {
                     w.println(line);
-                    Iterator<ResultRow> result = qe.executeQuery(line, QueryEngine.SQL2,
null).getRows();
+                    Iterator<? extends ResultRow> result = qe.executeQuery(line, QueryEngine.SQL2,
null).getRows();
                     boolean readEnd = true;
                     while (result.hasNext()) {
                         ResultRow row = result.next();

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
Tue Apr  3 08:24:16 2012
@@ -18,14 +18,13 @@
  */
 package org.apache.jackrabbit.oak.jcr.query;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.QueryEngine;
+import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
 import org.apache.jackrabbit.oak.jcr.SessionImpl;
 import org.apache.jackrabbit.oak.jcr.WorkspaceImpl;
 import org.apache.jackrabbit.oak.jcr.query.qom.QueryObjectModelFactoryImpl;
 import org.apache.jackrabbit.oak.query.CoreValue;
-import org.apache.jackrabbit.oak.query.QueryEngine;
-import org.apache.jackrabbit.oak.query.Result;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -46,11 +45,10 @@ import java.util.Map.Entry;
 public class QueryManagerImpl implements QueryManager {
 
     private final QueryObjectModelFactoryImpl qomFactory = new QueryObjectModelFactoryImpl();
-    private final QueryEngine qe;
+    private final QueryEngine queryEngine;
 
     public QueryManagerImpl(WorkspaceImpl workspace, SessionContext<SessionImpl> sessionContext)
{
-        MicroKernel mk = sessionContext.getMicrokernel();
-        qe = new QueryEngine(mk);
+        queryEngine = sessionContext.getConnection().getQueryEngine();
     }
 
     @Override
@@ -84,7 +82,7 @@ public class QueryManagerImpl implements
 
     public List<String> parse(String statement, String language) throws InvalidQueryException
{
         try {
-            return qe.parse(statement, convertLanguage(language));
+            return queryEngine.getBindVariableNames(statement, convertLanguage(language));
         } catch (ParseException e) {
             throw new InvalidQueryException(e);
         }
@@ -94,7 +92,7 @@ public class QueryManagerImpl implements
             HashMap<String, Value> bindVariableMap, long limit, long offset) throws
RepositoryException {
         try {
             HashMap<String, CoreValue> bindMap = convertMap(bindVariableMap);
-            Result r = qe.executeQuery(statement, convertLanguage(language), bindMap);
+            Result r = queryEngine.executeQuery(statement, convertLanguage(language), bindMap);
             return new QueryResultImpl(r);
         } catch (ParseException e) {
             throw new InvalidQueryException(e);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java
Tue Apr  3 08:24:16 2012
@@ -24,8 +24,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
-import org.apache.jackrabbit.oak.query.Result;
-import org.apache.jackrabbit.oak.query.ResultRow;
+import org.apache.jackrabbit.oak.api.Result;
+import org.apache.jackrabbit.oak.api.ResultRow;
 
 /**
  * The implementation of the corresponding JCR interface.
@@ -52,7 +52,7 @@ public class QueryResultImpl implements 
     public RowIterator getRows() throws RepositoryException {
         Iterator<RowImpl> it = new Iterator<RowImpl>() {
 
-            private Iterator<ResultRow> it = result.getRows();
+            private Iterator<? extends ResultRow> it = result.getRows();
 
             @Override
             public boolean hasNext() {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java?rev=1308742&r1=1308741&r2=1308742&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/RowImpl.java
Tue Apr  3 08:24:16 2012
@@ -23,8 +23,8 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.query.Row;
+import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.query.CoreValue;
-import org.apache.jackrabbit.oak.query.ResultRow;
 
 /**
  * The implementation of the corresponding JCR interface.



Mime
View raw message