jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1346301 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
Date Tue, 05 Jun 2012 08:58:34 GMT
Author: thomasm
Date: Tue Jun  5 08:58:34 2012
New Revision: 1346301

URL: http://svn.apache.org/viewvc?rev=1346301&view=rev
Log:
OAK-28 Query implementation - support "explain" for XPath queries

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1346301&r1=1346300&r2=1346301&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
Tue Jun  5 08:58:34 2012
@@ -57,6 +57,10 @@ public class XPathToSQL2Converter {
      */
     public String convert(String query) throws ParseException {
         // TODO verify this is correct
+        boolean explain = query.startsWith("explain ");
+        if (explain) {
+            query = query.substring("explain ".length());
+        }
         if (!query.startsWith("/")) {
             query = "/jcr:root/" + query;
         }
@@ -196,7 +200,11 @@ public class XPathToSQL2Converter {
         if (!currentToken.isEmpty()) {
             throw getSyntaxError("<end>");
         }
-        StringBuilder buff = new StringBuilder("select ");
+        StringBuilder buff = new StringBuilder();
+        if (explain) {
+            buff.append("explain ");
+        }
+        buff.append("select ");
         buff.append("[jcr:path], [jcr:score], ");
         if (columnList.isEmpty()) {
             buff.append('*');

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt?rev=1346301&r1=1346300&r2=1346301&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
Tue Jun  5 08:58:34 2012
@@ -36,6 +36,9 @@ select [jcr:path], [jcr:score], * from [
 xpath /jcr:root/test/text()
 select [jcr:path], [jcr:score], * from [nt:base] where issamenode('/test/jcr:xmltext')
 
+xpath explain //*[@*='x']
+explain select [jcr:path], [jcr:score], * from [nt:base] where [*] = 'x'
+
 xpath //*[@*='x']
 select [jcr:path], [jcr:score], * from [nt:base] where [*] = 'x'
 



Mime
View raw message