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 2014/12/08 14:11:48 UTC

svn commit: r1643806 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java

Author: thomasm
Date: Mon Dec  8 13:11:47 2014
New Revision: 1643806

URL: http://svn.apache.org/r1643806
Log:
OAK-1907 Better cost estimates for traversal, property, and ordered indexes

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java?rev=1643806&r1=1643805&r2=1643806&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java Mon Dec  8 13:11:47 2014
@@ -50,8 +50,14 @@ public class QueryPlanTest extends Abstr
     public void propertyIndexVersusNodeTypeIndex() throws Exception {
         Session session = getAdminSession();
         Node nt = session.getRootNode().getNode("oak:index").getNode("nodetype");
-        nt.setProperty("entryCount", Long.MAX_VALUE);
+        nt.setProperty("entryCount", 200);
+        Node uuid = session.getRootNode().getNode("oak:index").getNode("uuid");
+        uuid.setProperty("entryCount", 100);
         QueryManager qm = session.getWorkspace().getQueryManager();
+        if (session.getRootNode().hasNode("testroot")) {
+            session.getRootNode().getNode("testroot").remove();
+            session.save();
+        }
         Node testRootNode = session.getRootNode().addNode("testroot");
         for (int i = 0; i < 100; i++) {
             Node n = testRootNode.addNode("n" + i, "oak:Unstructured");
@@ -63,7 +69,7 @@ public class QueryPlanTest extends Abstr
         QueryResult result;
         RowIterator it;
 
-        String xpath = "/jcr:root/a/b/c/d/e/f/g/h/i/j/k/element(*, oak:Unstructured)";
+        String xpath = "/jcr:root//element(*, oak:Unstructured)";
         q = qm.createQuery("explain " + xpath, "xpath");
         result = q.execute();
         it = result.getRows();
@@ -72,25 +78,23 @@ public class QueryPlanTest extends Abstr
         // System.out.println("plan: " + plan);
         // should use the node type index
         assertEquals("[oak:Unstructured] as [a] " + 
-                "/* Filter(query=explain select [jcr:path], [jcr:score], * " + 
+                "/* nodeType Filter(query=explain select [jcr:path], [jcr:score], * " + 
                 "from [oak:Unstructured] as a " + 
-                "where ischildnode(a, '/a/b/c/d/e/f/g/h/i/j/k') " + 
-                "/* xpath: /jcr:root/a/b/c/d/e/f/g/h/i/j/k/element(*, oak:Unstructured) */" + 
-                ", path=/a/b/c/d/e/f/g/h/i/j/k/*) where " + 
-                "ischildnode([a], [/a/b/c/d/e/f/g/h/i/j/k]) */", 
+                "where isdescendantnode(a, '/') " + 
+                "/* xpath: /jcr:root//element(*, oak:Unstructured) */" + 
+                ", path=//*) where isdescendantnode([a], [/]) */", 
                 plan);
 
-        String xpath2 = "/jcr:root/a/b/c/d/e/f/g/h/i/j/k/element(*, oak:Unstructured)[@jcr:uuid]";
+        String xpath2 = "/jcr:root//element(*, oak:Unstructured)[@jcr:uuid]";
         q = qm.createQuery("explain " + xpath2 + "", "xpath");
         result = q.execute();
         it = result.getRows();
         assertTrue(it.hasNext());
         plan = it.nextRow().getValue("plan").getString();
-        // System.out.println("plan: " + plan);
         // should use the index on "jcr:uuid"
         assertEquals("[oak:Unstructured] as [a] " +
                 "/* property uuid IS NOT NULL where ([a].[jcr:uuid] is not null) " +
-                "and (ischildnode([a], [/a/b/c/d/e/f/g/h/i/j/k])) */",
+                "and (isdescendantnode([a], [/])) */",
                 plan);
     }     
     
@@ -384,6 +388,7 @@ public class QueryPlanTest extends Abstr
         Node n = s.getRootNode().getNode("oak:index").
                 addNode(propertyName, "oak:QueryIndexDefinition");
         n.setProperty("type", "property");
+        n.setProperty("entryCount", "-1");
         n.setProperty("propertyNames", new String[]{propertyName}, PropertyType.NAME);
         s.save();
     }