jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1375060 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/lucene/ main/java/org/apache/jackrabbit/oak/query/ main/java/org/apache/jackrabbit/oak/query/ast/ main/java/org/apache/jackrabbit/oak/query/index/...
Date Mon, 20 Aug 2012 15:29:57 GMT
Author: thomasm
Date: Mon Aug 20 15:29:56 2012
New Revision: 1375060

URL: http://svn.apache.org/viewvc?rev=1375060&view=rev
Log:
OAK-262 Query: support pseudo properties like jcr:score() and rep:excerpt()

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/IndexRow.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.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/XPathToSQL2Converter.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/index/PropertyContentIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Cursor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Filter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
    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/plugins/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
Mon Aug 20 15:29:56 2012
@@ -27,9 +27,11 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.jackrabbit.oak.query.index.IndexRowImpl;
 import org.apache.jackrabbit.oak.spi.Cursor;
 import org.apache.jackrabbit.oak.spi.Filter;
 import org.apache.jackrabbit.oak.spi.Filter.PropertyRestriction;
+import org.apache.jackrabbit.oak.spi.IndexRow;
 import org.apache.jackrabbit.oak.spi.QueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -125,7 +127,8 @@ public class LuceneIndex implements Quer
             qs.add(new PrefixQuery(newPathTerm(path + "/")));
             break;
         case DIRECT_CHILDREN:
-            qs.add(new PrefixQuery(newPathTerm(path + "/"))); // FIXME
+            // FIXME
+            qs.add(new PrefixQuery(newPathTerm(path + "/")));
             break;
         case EXACT:
             qs.add(new TermQuery(newPathTerm(path)));
@@ -136,7 +139,8 @@ public class LuceneIndex implements Quer
                 String parent = path.substring(0, slash);
                 qs.add(new TermQuery(newPathTerm(parent)));
             } else {
-                return null; // there's no parent of the root node
+                // there's no parent of the root node
+                return null;
             }
             break;
         }
@@ -172,6 +176,9 @@ public class LuceneIndex implements Quer
         }
     }
 
+    /**
+     * A cursor over the resulting paths.
+     */
     private static class PathCursor implements Cursor {
 
         private final Iterator<String> iterator;
@@ -194,8 +201,9 @@ public class LuceneIndex implements Quer
         }
 
         @Override
-        public String currentPath() {
-            return path;
+        public IndexRow currentRow() {
+            // TODO support jcr:score and possibly rep:exceprt
+            return new IndexRowImpl(path);
         }
 
     }

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=1375060&r1=1375059&r2=1375060&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
Mon Aug 20 15:29:56 2012
@@ -535,7 +535,7 @@ public class Query {
         }
         buff.append(" from ").append(source);
         if (constraint != null) {
-            buff.append(constraint);
+            buff.append(" where ").append(constraint);
         }
         if (orderings != null) {
             buff.append(" order by ");

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=1375060&r1=1375059&r2=1375060&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
Mon Aug 20 15:29:56 2012
@@ -331,21 +331,6 @@ public class XPathToSQL2Converter {
             Literal l = Literal.newString(currentToken);
             read();
             return l;
-        } else if (currentTokenType == IDENTIFIER) {
-            String name = readIdentifier();
-            // relative properties
-            if (readIf("/")) {
-                do {
-                    if (readIf("@")) {
-                        name = name + "/" + readIdentifier();
-                        return new Property(name);
-                    } else {
-                        name = name + "/" + readIdentifier();
-                    }
-                } while (readIf("/"));
-            }
-            read("(");
-            return parseFunction(name);
         } else if (readIf("-")) {
             if (currentTokenType != VALUE_NUMBER) {
                 throw getSyntaxError();
@@ -359,10 +344,60 @@ public class XPathToSQL2Converter {
             }
             return parseExpression();
         } else {
-            throw getSyntaxError();
+            return parsePropertyOrFunction();
         }
     }
 
+    private Expression parsePropertyOrFunction() throws ParseException {
+        StringBuilder buff = new StringBuilder();
+        boolean isPath = false;
+        while (true) {
+            if (currentTokenType == IDENTIFIER) {
+                String name = readIdentifier();
+                buff.append(name);
+            } else if (readIf("*")) {
+                // any node
+                buff.append('*');
+                isPath = true;
+            } else if (readIf(".")) {
+                buff.append('.');
+                if (readIf(".")) {
+                    buff.append('.');
+                }
+                isPath = true;
+            } else if (readIf("@")) {
+                if (readIf("*")) {
+                    // xpath supports @*, even thought jackrabbit may not
+                    buff.append('*');
+                } else {
+                    buff.append(readIdentifier());
+                }
+                return new Property(buff.toString());
+            } else {
+                break;
+            }
+            if (readIf("/")) {
+                isPath = true;
+                buff.append('/');
+            } else {
+                break;
+            }
+        }
+        if (!isPath && readIf("(")) {
+            return parseFunction(buff.toString());
+        } else if (buff.length() > 0) {
+            // path without all attributes, as in:
+            // jcr:contains(jcr:content, 'x')
+            if (buff.toString().equals(".")) {
+                buff = new StringBuilder("*");
+            } else {
+                buff.append("/*");
+            }
+            return new Property(buff.toString());
+        }
+        throw getSyntaxError();
+    }
+
     private Expression parseFunction(String functionName) throws ParseException {
         if ("jcr:like".equals(functionName)) {
             Condition c = new Condition(parseExpression(), "like", null);
@@ -372,12 +407,7 @@ public class XPathToSQL2Converter {
             return c;
         } else if ("jcr:contains".equals(functionName)) {
             Function f = new Function("contains");
-            if (readIf(".")) {
-                // special case: jcr:contains(., expr)
-                f.params.add(new Literal("*"));
-            } else {
-                f.params.add(parseExpression());
-            }
+            f.params.add(parseExpression());
             read(",");
             f.params.add(parseExpression());
             read(")");
@@ -399,7 +429,10 @@ public class XPathToSQL2Converter {
             return f;
         } else if ("fn:name".equals(functionName)) {
             Function f = new Function("name");
-            read(")");
+            if (!readIf(")")) {
+                f.params.add(parseExpression());
+                read(")");
+            }
             return f;
         } else if ("fn:upper-case".equals(functionName)) {
             Function f = new Function("upper");

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=1375060&r1=1375059&r2=1375060&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
Mon Aug 20 15:29:56 2012
@@ -65,12 +65,14 @@ public class JoinImpl extends SourceImpl
 
     @Override
     public String getPlan() {
-        return left.getPlan() + ' ' + joinType.name() + " join " + right.getPlan();
+        return left.getPlan() + ' ' + joinType +
+                " " + right.getPlan() + " on " + joinCondition;
     }
 
     @Override
     public String toString() {
-        return left + " " + joinType.name() + " join " + right;
+        return left + " " + joinType +
+                " " + right + " on " + joinCondition;
     }
 
     @Override

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=1375060&r1=1375059&r2=1375060&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
Mon Aug 20 15:29:56 2012
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.query.Query;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 import org.apache.jackrabbit.oak.spi.Cursor;
+import org.apache.jackrabbit.oak.spi.IndexRow;
 import org.apache.jackrabbit.oak.spi.QueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -117,7 +118,7 @@ public class SelectorImpl extends Source
             if (nodeTypeName.equals(TYPE_BASE)) {
                 return true;
             }
-            Tree tree = getTree(cursor.currentPath());
+            Tree tree = getTree(cursor.currentRow().getPath());
             PropertyState p = tree.getProperty(JCR_PRIMARY_TYPE);
             if (p == null) {
                 return true;
@@ -140,7 +141,7 @@ public class SelectorImpl extends Source
 
     @Override
     public String currentPath() {
-        return cursor == null ? null : cursor.currentPath();
+        return cursor == null ? null : cursor.currentRow().getPath();
     }
 
     public PropertyState currentProperty(String propertyName) {
@@ -157,7 +158,16 @@ public class SelectorImpl extends Source
             CoreValue v = query.getValueFactory().createValue(local);
             return new SinglePropertyState(PATH, v);
         }
-        String path = currentPath();
+        if (cursor == null) {
+            return null;
+        }
+        IndexRow r = cursor.currentRow();
+        if (r == null) {
+            return null;
+        }
+        // TODO support pseudo-properties such as jcr:score using
+        // r.getValue(columnName)
+        String path = r.getPath();
         if (path == null) {
             return null;
         }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java?rev=1375060&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/IndexRowImpl.java
Mon Aug 20 15:29:56 2012
@@ -0,0 +1,45 @@
+/*
+ * 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.query.index;
+
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.spi.IndexRow;
+
+/**
+ * A simple index row implementation.
+ */
+public class IndexRowImpl implements IndexRow {
+
+    private final String path;
+
+    public IndexRowImpl(String path) {
+        this.path = path;
+    }
+
+    @Override
+    public String getPath() {
+        return path;
+    }
+
+    @Override
+    public CoreValue getValue(String columnName) {
+        return null;
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/PropertyContentIndex.java
Mon Aug 20 15:29:56 2012
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.mk.index.Pr
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.spi.Cursor;
 import org.apache.jackrabbit.oak.spi.Filter;
+import org.apache.jackrabbit.oak.spi.IndexRow;
 import org.apache.jackrabbit.oak.spi.QueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -92,8 +93,8 @@ public class PropertyContentIndex implem
         }
 
         @Override
-        public String currentPath() {
-            return currentPath;
+        public IndexRow currentRow() {
+            return new IndexRowImpl(currentPath);
         }
 
         @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
Mon Aug 20 15:29:56 2012
@@ -14,12 +14,9 @@
 package org.apache.jackrabbit.oak.query.index;
 
 import static org.apache.jackrabbit.oak.spi.Filter.PathRestriction.ALL_CHILDREN;
-
 import java.util.Deque;
 import java.util.Iterator;
-
 import javax.jcr.PropertyType;
-
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
@@ -28,9 +25,9 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.Cursor;
 import org.apache.jackrabbit.oak.spi.Filter;
 import org.apache.jackrabbit.oak.spi.Filter.PropertyRestriction;
+import org.apache.jackrabbit.oak.spi.IndexRow;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Queues;
 
@@ -66,7 +63,7 @@ public class TraversingCursor implements
 
                 if (node == null) {
                     // nothing can match this filter, leave nodes empty
-                    return; 
+                    return;
                 }
             }
         }
@@ -93,8 +90,8 @@ public class TraversingCursor implements
     }
 
     @Override
-    public String currentPath() {
-        return currentPath;
+    public IndexRow currentRow() {
+        return new IndexRowImpl(currentPath);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Cursor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Cursor.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Cursor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Cursor.java
Mon Aug 20 15:29:56 2012
@@ -31,10 +31,13 @@ public interface Cursor {
     boolean next();
 
     /**
-     * The path of the current node.
+     * The current row within this index. The row usually only contains the
+     * path, but it may additionally contain so-called 'pseudo-properties' such
+     * as "jcr:score" and "rep:excerpt", in case the index supports those
+     * properties and if the properties were requested when running the query.
      *
-     * @return the path
+     * @return the row
      */
-    String currentPath();
+    IndexRow currentRow();
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Filter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Filter.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Filter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/Filter.java
Mon Aug 20 15:29:56 2012
@@ -29,7 +29,7 @@ public interface Filter {
 
     /**
      * Get the list of property restrictions, if any.
-     * 
+     *
      * @return the conditions (an empty collection if not used)
      */
     Collection<PropertyRestriction> getPropertyRestrictions();

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/IndexRow.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/IndexRow.java?rev=1375060&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/IndexRow.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/IndexRow.java
Mon Aug 20 15:29:56 2012
@@ -0,0 +1,45 @@
+/*
+ * 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.spi;
+
+import org.apache.jackrabbit.oak.api.CoreValue;
+
+/**
+ * A row returned by the index.
+ */
+public interface IndexRow {
+
+    /**
+     * The path of the node, if available.
+     *
+     * @return the path
+     */
+    String getPath();
+
+    /**
+     * The value of the given property, if available. This might be a property
+     * of the given node, or a pseudo-property (a property that is only
+     * available in the index but not in the node itself, such as "jcr:score").
+     *
+     * @param columnName the column name
+     * @return the value, or null if not available
+     */
+    CoreValue getValue(String columnName);
+
+}

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
Mon Aug 20 15:29:56 2012
@@ -61,7 +61,7 @@ public class LuceneEditorTest {
                 MemoryValueFactory.INSTANCE.createValue("bar"));
         Cursor cursor = index.query(filter, null, store.getRoot());
         assertTrue(cursor.next());
-        assertEquals("/", cursor.currentPath());
+        assertEquals("/", cursor.currentRow().getPath());
         assertFalse(cursor.next());
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingCursorTest.java
Mon Aug 20 15:29:56 2012
@@ -49,7 +49,7 @@ public class TraversingCursorTest {
         List<String> paths = new ArrayList<String>();
         Cursor c = t.query(f, head, new KernelNodeState(mk, "/", head));
         while (c.next()) {
-            paths.add(c.currentPath());
+            paths.add(c.currentRow().getPath());
         }
         Collections.sort(paths);
         assertEquals(Arrays.asList(

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt?rev=1375060&r1=1375059&r2=1375060&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryTest.txt
Mon Aug 20 15:29:56 2012
@@ -190,7 +190,7 @@ select * from [nt:base] as p inner join 
 /parents/p2, /children/c3
 
 explain select * from [nt:base] as p inner join [nt:base] as c on p.id = c.p
-nt:base as p /* traverse "//*" */ INNER join nt:base as c /* traverse "//*" */
+nt:base as p /* traverse "//*" */ inner join nt:base as c /* traverse "//*" */ on p.id =
c.p
 
 commit / - "parents"
 commit / - "children"

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=1375060&r1=1375059&r2=1375060&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
Mon Aug 20 15:29:56 2012
@@ -20,12 +20,26 @@
 
 # jackrabbit test queries
 
-xpath /jcr:root/testroot/*[jcr:contains(@jcr:content, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains([jcr:content], 'lazy') and
ischildnode('/testroot')
+xpath //element(*,rep:Authorizable)[(((jcr:contains(profile/givenName,'**') or jcr:contains(profile/familyName,'**'))
or jcr:contains(profile/email,'**')) or (jcr:like(rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))]
order by rep:principalName ascending
+select [jcr:path], [jcr:score], * from [rep:Authorizable] where ((contains([profile/givenName/*],
'**') or contains([profile/familyName/*], '**')) or contains([profile/email/*], '**')) or
(([rep:principalName/*] like '%%') or (name([*]) like '%%')) order by [rep:principalName/*]
+
+xpath //element(*,rep:Authorizable)[(((jcr:contains(profile/@givenName,'**') or jcr:contains(profile/@familyName,'**'))
or jcr:contains(profile/@email,'**')) or (jcr:like(@rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))]
order by @rep:principalName ascending
+select [jcr:path], [jcr:score], * from [rep:Authorizable] where ((contains([profile/givenName],
'**') or contains([profile/familyName], '**')) or contains([profile/email], '**')) or (([rep:principalName]
like '%%') or (name([*]) like '%%')) order by [rep:principalName]
+
+xpath /jcr:root/testroot//*[jcr:contains(@jcr:data, 'lazy')]
+select [jcr:path], [jcr:score], * from [nt:base] where contains([jcr:data], 'lazy') and isdescendantnode('/testroot')
 
-# TODO is the @ before jcr:content not needed, if not why?
 xpath /jcr:root/testroot/*[jcr:contains(jcr:content, 'lazy')]
-invalid: Query: /jcr:root/testroot/*[jcr:contains(jcr:content,(*)'lazy')]; expected: (
+select [jcr:path], [jcr:score], * from [nt:base] where contains([jcr:content/*], 'lazy')
and ischildnode('/testroot')
+
+xpath /jcr:root/testroot/*[jcr:contains(*, 'lazy')]
+select [jcr:path], [jcr:score], * from [nt:base] where contains([*/*], 'lazy') and ischildnode('/testroot')
+
+xpath /jcr:root/testroot/*[jcr:contains(*/@jcr:data, 'lazy')]
+select [jcr:path], [jcr:score], * from [nt:base] where contains([*/jcr:data], 'lazy') and
ischildnode('/testroot')
+
+xpath /jcr:root/testroot/*[jcr:contains(*/@*, 'lazy')]
+select [jcr:path], [jcr:score], * from [nt:base] where contains([*/*], 'lazy') and ischildnode('/testroot')
 
 xpath /jcr:root/testroot/*[@prop1 = 1 and jcr:like(fn:name(), 'F%')]
 select [jcr:path], [jcr:score], * from [nt:base] where (([prop1] = 1) and (name() like 'F%'))
and ischildnode('/testroot')
@@ -143,10 +157,10 @@ xpath /jcr:root/content//*[@name='Hello'
 select [jcr:path], [jcr:score], * from [nt:base] where ([name] = 'Hello') and isdescendantnode('/content')
 
 xpath //*[jcr:contains(., 'test')] order by @jcr:score
-select [jcr:path], [jcr:score], * from [nt:base] where contains(*, 'test') order by [jcr:score]
+select [jcr:path], [jcr:score], * from [nt:base] where contains([*], 'test') order by [jcr:score]
 
 xpath /jcr:root//*[jcr:contains(., 'test')] order by @jcr:score
-select [jcr:path], [jcr:score], * from [nt:base] where contains(*, 'test') and isdescendantnode('/')
order by [jcr:score]
+select [jcr:path], [jcr:score], * from [nt:base] where contains([*], 'test') and isdescendantnode('/')
order by [jcr:score]
 
 xpath /jcr:root//element(*, test)
 select [jcr:path], [jcr:score], * from [test] where isdescendantnode('/')
@@ -229,7 +243,7 @@ xpath //element(*, my:type)[jcr:like(@ti
 select [jcr:path], [jcr:score], * from [my:type] where [title] like '%Java%'
 
 xpath //element(*, my:type)[jcr:contains(., 'JSR 170')]
-select [jcr:path], [jcr:score], * from [my:type] where contains(*, 'JSR 170')
+select [jcr:path], [jcr:score], * from [my:type] where contains([*], 'JSR 170')
 
 xpath //element(*, my:type)[@my:title]
 select [jcr:path], [jcr:score], * from [my:type] where [my:title] is not null
@@ -268,7 +282,7 @@ xpath //element(*, my:type) order by @my
 select [jcr:path], [jcr:score], * from [my:type] order by [my:date] desc, [my:title]
 
 xpath //element(*, my:type)[jcr:contains(., 'jcr')] order by jcr:score() descending
-select [jcr:path], [jcr:score], * from [my:type] where contains(*, 'jcr') order by score()
desc
+select [jcr:path], [jcr:score], * from [my:type] where contains([*], 'jcr') order by score()
desc
 
 xpath //element(*, my:type)[jcr:contains(@my:title, 'jcr')] order by jcr:score() descending
 select [jcr:path], [jcr:score], * from [my:type] where contains([my:title], 'jcr') order
by score() desc
@@ -289,13 +303,13 @@ xpath //element(*, my:type)[@my:value = 
 invalid: Query: //element(*, my:type)[@my:value = +'x'(*)]
 
 xpath //element(*, my:type)[@my:value = ['x']
-invalid: Query: //element(*, my:type)[@my:value = [(*)'x']; expected: @, true, false, -,
+
+invalid: Query: //element(*, my:type)[@my:value = [(*)'x']; expected: @, true, false, -,
+, *, ., @, (
 
 xpath //element(*, my:type)[jcr:strike(@title,'%Java%')]
 invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; expected: jcr:like
| jcr:contains | jcr:score | jcr:deref | fn:lower-case | fn:upper-case
 
 xpath //element(*, my:type)[
-invalid: Query: //element(*, my:type)(*)[; expected: not, (, @, true, false, -, +
+invalid: Query: //element(*, my:type)(*)[; expected: not, (, @, true, false, -, +, *, .,
@, (
 
-xpath //element(*, my:type)[@my:value >= .]
-invalid: Query: //element(*, my:type)[@my:value >= .(*)]; expected: @, true, false, -,
+
+xpath //element(*, my:type)[@my:value >= %]
+invalid: Query: //element(*, my:type)[@my:value >= %(*)]; expected: @, true, false, -,
+, *, ., @, (



Mime
View raw message