You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2012/06/05 11:23:39 UTC

svn commit: r1346307 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java

Author: thomasm
Date: Tue Jun  5 09:23:39 2012
New Revision: 1346307

URL: http://svn.apache.org/viewvc?rev=1346307&view=rev
Log:
OAK-28 Query implementation - support "explain", simplify filtering

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryResultImpl.java

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=1346307&r1=1346306&r2=1346307&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 Jun  5 09:23:39 2012
@@ -66,6 +66,17 @@ public class QueryResultImpl implements 
         return result.getSelectorNames();
     }
 
+    boolean includeRow(String path) {
+        if (path == null) {
+            // a row without path (explain,...)
+            return true;
+        } else if (PathUtils.isAncestor(pathFilter, path)) {
+            // a row within this workspace
+            return true;
+        }
+        return false;
+    }
+
     @Override
     public RowIterator getRows() throws RepositoryException {
         Iterator<RowImpl> it = new Iterator<RowImpl>() {
@@ -83,7 +94,7 @@ public class QueryResultImpl implements 
                     ResultRow r = it.next();
                     for (String s : getSelectorNames()) {
                         String path = r.getPath(s);
-                        if (PathUtils.isAncestor(pathFilter, path)) {
+                        if (includeRow(path)) {
                             current = new RowImpl(QueryResultImpl.this, r);
                             return;
                         }
@@ -145,7 +156,7 @@ public class QueryResultImpl implements 
                 while(it.hasNext()) {
                     ResultRow r = it.next();
                     String path = r.getPath();
-                    if (PathUtils.isAncestor(pathFilter, path)) {
+                    if (includeRow(path)) {
                         current = getNode(getLocalPath(path));
                         break;
                     }