jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1511808 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/ main/java/org/apache/jackrabbit/oak/query/ast/ main/java/org/apache/jackrabbit/oak/query/index/ main/java/org/apache/jackrabbit/oak/spi/query/ test...
Date Thu, 08 Aug 2013 14:35:49 GMT
Author: thomasm
Date: Thu Aug  8 14:35:49 2013
New Revision: 1511808

URL: http://svn.apache.org/r1511808
Log:
OAK-828 Lucene support for index aggregates (add the root tree to the filter)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.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/FilterImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
Thu Aug  8 14:35:49 2013
@@ -576,6 +576,10 @@ public class QueryImpl implements Query 
         this.rootTree = rootTree;
     }
     
+    public Tree getRootTree() {
+        return rootTree;
+    }
+    
     @Override
     public void setRootState(NodeState rootState) {
         this.rootState = rootState;

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=1511808&r1=1511807&r2=1511808&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
Thu Aug  8 14:35:49 2013
@@ -195,7 +195,7 @@ public class SelectorImpl extends Source
      * @return the filter
      */
     private Filter createFilter(boolean preparing) {
-        FilterImpl f = new FilterImpl(this, query.getStatement());
+        FilterImpl f = new FilterImpl(this, query.getStatement(), query.getRootTree());
         f.setPreparing(preparing);
         if (joinCondition != null) {
             joinCondition.restrict(f);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/FilterImpl.java
Thu Aug  8 14:35:49 2013
@@ -31,6 +31,7 @@ import javax.annotation.Nullable;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.api.PropertyValue;
+import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.query.ast.Operator;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
@@ -80,12 +81,19 @@ public class FilterImpl implements Filte
      * Set during the prepare phase of a query.
      */
     private boolean preparing;
+    
+    private Tree rootTree;
 
     // TODO support "order by"
+    
+    public FilterImpl() {
+        this(null, null, null);
+    }
 
-    public FilterImpl(SelectorImpl selector, String queryStatement) {
+    public FilterImpl(SelectorImpl selector, String queryStatement, Tree rootTree) {
         this.selector = selector;
         this.queryStatement = queryStatement;
+        this.rootTree = rootTree;
     }
     
     public void setPreparing(boolean preparing) {
@@ -122,6 +130,11 @@ public class FilterImpl implements Filte
     public void setDistinct(boolean distinct) {
         this.distinct = distinct;
     }
+    
+    @Override
+    public Tree getRootTree() {
+        return rootTree;
+    }
 
     public void setAlwaysFalse() {
         propertyRestrictions.clear();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/Filter.java
Thu Aug  8 14:35:49 2013
@@ -27,6 +27,7 @@ import javax.annotation.Nullable;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.oak.api.PropertyValue;
+import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.query.fulltext.FullTextExpression;
 
 /**
@@ -63,6 +64,13 @@ public interface Filter {
      * @return the condition (null if none)
      */
     FullTextExpression getFullTextConstraint();
+    
+    /**
+     * Get the root tree to read data.
+     * 
+     * @return the tree
+     */
+    Tree getRootTree();
 
     /**
      * Get the property restriction for the given property, if any.

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
Thu Aug  8 14:35:49 2013
@@ -201,7 +201,7 @@ public class IndexUpdateTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(NT_BASE);
         SelectorImpl selector = new SelectorImpl(type, NT_BASE);
-        Filter filter = new FilterImpl(selector, "SELECT * FROM [nt:base]");
+        Filter filter = new FilterImpl(selector, "SELECT * FROM [nt:base]", null);
         return Sets.newHashSet(lookup.query(filter, name,
                 PropertyValues.newString(value)));
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java
Thu Aug  8 14:35:49 2013
@@ -45,7 +45,7 @@ public class DiffCollectorTest {
 
         UUIDDiffCollector collector = new UUIDDiffCollector(root, after);
 
-        FilterImpl f = new FilterImpl(null, null);
+        FilterImpl f = new FilterImpl();
         f.restrictProperty("jcr:uuid", Operator.EQUAL,
                 PropertyValues.newString("abc"));
 
@@ -71,7 +71,7 @@ public class DiffCollectorTest {
 
         UUIDDiffCollector collector = new UUIDDiffCollector(before, after);
 
-        FilterImpl f = new FilterImpl(null, null);
+        FilterImpl f = new FilterImpl();
         f.restrictProperty("jcr:uuid", Operator.EQUAL,
                 PropertyValues.newString("xyz"));
 
@@ -111,7 +111,7 @@ public class DiffCollectorTest {
 
         UUIDDiffCollector collector = new UUIDDiffCollector(before, after);
 
-        FilterImpl f = new FilterImpl(null, null);
+        FilterImpl f = new FilterImpl();
         f.restrictProperty("jcr:uuid", Operator.EQUAL, PropertyValues
                 .newString("ee59b554-76b7-3e27-9fc6-15bda1388894"));
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
Thu Aug  8 14:35:49 2013
@@ -106,7 +106,7 @@ public class NodeTypeIndexTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(nodeTypeName);
         SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
-        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]");
+        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", null);
     }
 
     private static void checkCursor(Cursor cursor, String... matches) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
Thu Aug  8 14:35:49 2013
@@ -197,7 +197,7 @@ public class PropertyIndexTest {
         NodeState types = system.getChildNode(JCR_NODE_TYPES);
         NodeState type = types.getChildNode(nodeTypeName);
         SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
-        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]");
+        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", null);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/FilterTest.java
Thu Aug  8 14:35:49 2013
@@ -42,7 +42,7 @@ public class FilterTest {
         PropertyValue one = PropertyValues.newString("1");
         PropertyValue two = PropertyValues.newString("2");
 
-        FilterImpl f = new FilterImpl(null, null);
+        FilterImpl f = new FilterImpl();
         assertTrue(null == f.getPropertyRestriction("x"));
         f.restrictProperty("x", Operator.LESS_OR_EQUAL, two);
         assertEquals("..2]", f.getPropertyRestriction("x").toString());
@@ -55,7 +55,7 @@ public class FilterTest {
         f.restrictProperty("x", Operator.EQUAL, two);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictProperty("x", Operator.EQUAL, one);
         assertEquals("1", f.getPropertyRestriction("x").toString());
         f.restrictProperty("x", Operator.EQUAL, one);
@@ -67,13 +67,13 @@ public class FilterTest {
         f.restrictProperty("x", Operator.GREATER_THAN, one);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictProperty("x", Operator.EQUAL, one);
         assertEquals("1", f.getPropertyRestriction("x").toString());
         f.restrictProperty("x", Operator.LESS_THAN, one);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictProperty("x", Operator.NOT_EQUAL, null);
         assertEquals("", f.getPropertyRestriction("x").toString());
         f.restrictProperty("x", Operator.LESS_THAN, one);
@@ -108,11 +108,11 @@ public class FilterTest {
                     .nextInt(Filter.PathRestriction.values().length)];
             Filter.PathRestriction r2 = Filter.PathRestriction.values()[r
                     .nextInt(Filter.PathRestriction.values().length)];
-            FilterImpl f1 = new FilterImpl(null, null);
+            FilterImpl f1 = new FilterImpl();
             f1.restrictPath(p1, r1);
-            FilterImpl f2 = new FilterImpl(null, null);
+            FilterImpl f2 = new FilterImpl();
             f2.restrictPath(p2, r2);
-            FilterImpl fc = new FilterImpl(null, null);
+            FilterImpl fc = new FilterImpl();
             fc.restrictPath(p1, r1);
             fc.restrictPath(p2, r2);
             int tooMany = 0;
@@ -122,7 +122,7 @@ public class FilterTest {
                 if (expected == got) {
                     // good
                 } else if (expected && !got) {
-                    fc = new FilterImpl(null, null);
+                    fc = new FilterImpl();
                     fc.restrictPath(p1, r1);
                     fc.restrictPath(p2, r2);
                     fail("not matched: " + p1 + "/" + r1.name() + " && " + p2
@@ -141,7 +141,7 @@ public class FilterTest {
 
     @Test
     public void pathRestrictions() throws Exception {
-        FilterImpl f = new FilterImpl(null, null);
+        FilterImpl f = new FilterImpl();
         assertEquals("/", f.getPath());
         assertEquals(Filter.PathRestriction.NO_RESTRICTION,
                 f.getPathRestriction());
@@ -150,7 +150,7 @@ public class FilterTest {
         f.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         assertEquals("/test", f.getPath());
         assertEquals(Filter.PathRestriction.ALL_CHILDREN,
@@ -163,7 +163,7 @@ public class FilterTest {
         assertEquals("/test/x/y", f.getPath());
         assertEquals(Filter.PathRestriction.PARENT, f.getPathRestriction());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.DIRECT_CHILDREN);
         f.restrictPath("/test/x/y", Filter.PathRestriction.PARENT);
         assertEquals("/test/x/y", f.getPath());
@@ -171,7 +171,7 @@ public class FilterTest {
         f.restrictPath("/test/y", Filter.PathRestriction.DIRECT_CHILDREN);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test/x/y", Filter.PathRestriction.PARENT);
         f.restrictPath("/test/x", Filter.PathRestriction.EXACT);
         assertEquals("/test/x", f.getPath());
@@ -179,12 +179,12 @@ public class FilterTest {
         f.restrictPath("/test/y", Filter.PathRestriction.EXACT);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         f.restrictPath("/test", Filter.PathRestriction.PARENT);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test/x", Filter.PathRestriction.PARENT);
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         assertEquals("/test/x", f.getPath());
@@ -192,23 +192,23 @@ public class FilterTest {
         f.restrictPath("/test/x", Filter.PathRestriction.ALL_CHILDREN);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
         f.restrictPath("/test", Filter.PathRestriction.EXACT);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.DIRECT_CHILDREN);
         f.restrictPath("/test/x", Filter.PathRestriction.EXACT);
         assertEquals("/test/x", f.getPath());
         assertEquals(Filter.PathRestriction.EXACT, f.getPathRestriction());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.DIRECT_CHILDREN);
         f.restrictPath("/test/x/y", Filter.PathRestriction.EXACT);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test/x", Filter.PathRestriction.PARENT);
         f.restrictPath("/", Filter.PathRestriction.ALL_CHILDREN);
         assertEquals("/test/x", f.getPath());
@@ -216,7 +216,7 @@ public class FilterTest {
         f.restrictPath("/test/y", Filter.PathRestriction.EXACT);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test", Filter.PathRestriction.DIRECT_CHILDREN);
         assertEquals("/test", f.getPath());
         assertEquals(Filter.PathRestriction.DIRECT_CHILDREN,
@@ -235,7 +235,7 @@ public class FilterTest {
         f.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test/x", Filter.PathRestriction.EXACT);
         assertEquals("/test/x", f.getPath());
         assertEquals(Filter.PathRestriction.EXACT, f.getPathRestriction());
@@ -245,7 +245,7 @@ public class FilterTest {
         f.restrictPath("/test/y", Filter.PathRestriction.DIRECT_CHILDREN);
         assertTrue(f.isAlwaysFalse());
 
-        f = new FilterImpl(null, null);
+        f = new FilterImpl();
         f.restrictPath("/test/x/y", Filter.PathRestriction.PARENT);
         assertEquals("/test/x/y", f.getPath());
         assertEquals(Filter.PathRestriction.PARENT, f.getPathRestriction());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java?rev=1511808&r1=1511807&r2=1511808&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexTest.java
Thu Aug  8 14:35:49 2013
@@ -69,7 +69,7 @@ public class TraversingIndexTest {
         String head = mk.getHeadRevision();
         head = mk.commit("/", "+ \"parents\": { \"p0\": {\"id\": \"0\"}, \"p1\": {\"id\":
\"1\"}, \"p2\": {\"id\": \"2\"}}", head, "");
         head = mk.commit("/", "+ \"children\": { \"c1\": {\"p\": \"1\"}, \"c2\": {\"p\":
\"1\"}, \"c3\": {\"p\": \"2\"}, \"c4\": {\"p\": \"3\"}}", head, "");
-        FilterImpl f = new FilterImpl(null, null);
+        FilterImpl f = new FilterImpl();
 
         f.setPath("/");
         List<String> paths = new ArrayList<String>();



Mime
View raw message