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 2017/02/07 15:20:07 UTC
svn commit: r1782011 - in /jackrabbit/oak/branches/1.6: ./
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/jmx/
oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/counter/
oak-jcr/src/test/java/org/apache/jackrabbit/o...
Author: thomasm
Date: Tue Feb 7 15:20:07 2017
New Revision: 1782011
URL: http://svn.apache.org/viewvc?rev=1782011&view=rev
Log:
OAK-5587 Node counter index estimates must not be used before first async index cycle
Added:
jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/counter/
- copied from r1782000, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/counter/
Modified:
jackrabbit/oak/branches/1.6/ (props changed)
jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/jmx/NodeCounter.java
jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java
jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Propchange: jackrabbit/oak/branches/1.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 7 15:20:07 2017
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1781068,1781075,1781386,1781846,1781907
+/jackrabbit/oak/trunk:1781068,1781075,1781386,1781846,1781907,1782000
/jackrabbit/trunk:1345480
Modified: jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/jmx/NodeCounter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/jmx/NodeCounter.java?rev=1782011&r1=1782010&r2=1782011&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/jmx/NodeCounter.java (original)
+++ jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/counter/jmx/NodeCounter.java Tue Feb 7 15:20:07 2017
@@ -123,6 +123,10 @@ public class NodeCounter implements Node
return -1;
}
s = child(s, NodeCounterEditor.DATA_NODE_NAME);
+ if (!s.exists()) {
+ // no index data (not yet indexed, or very few nodes)
+ return -1;
+ }
s = child(s, PathUtils.elements(path));
if (s == null || !s.exists()) {
// we have an index, but no data
@@ -164,6 +168,10 @@ public class NodeCounter implements Node
return -1;
}
s = child(s, NodeCounterEditor.DATA_NODE_NAME);
+ if (!s.exists()) {
+ // no index data (not yet indexed, or very few nodes)
+ return -1;
+ }
s = child(s, PathUtils.elements(path));
if (s != null && s.exists()) {
value = getCombinedCountIfAvailable(s);
Modified: jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java?rev=1782011&r1=1782010&r2=1782011&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java (original)
+++ jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java Tue Feb 7 15:20:07 2017
@@ -215,7 +215,7 @@ public class QueryPlanTest extends Abstr
Session session = getAdminSession();
QueryManager qm = session.getWorkspace().getQueryManager();
Node nodetype = session.getRootNode().getNode("oak:index").getNode("nodetype");
- nodetype.setProperty("entryCount", 100000);
+ nodetype.setProperty("entryCount", 10000000);
Node testRootNode = session.getRootNode().addNode("testroot");
Node n1 = testRootNode.addNode("node1");
Node n2 = n1.addNode("node2");
Modified: jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java?rev=1782011&r1=1782010&r2=1782011&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java (original)
+++ jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java Tue Feb 7 15:20:07 2017
@@ -817,8 +817,26 @@ public class QueryTest extends AbstractR
@Test
public void approxCount() throws Exception {
Session session = createAdminSession();
- double c = getCost(session, "//*[@x=1]");
+ session.getNode("/oak:index/counter").setProperty("resolution", 100);
+ session.save();
// *with* the counter index, the estimated cost to traverse is low
+ // but the counter index is not always up to date, so we need a loop
+ for (int i = 0; i < 100; i++) {
+ double c = getCost(session, "//*[@x=1]");
+ if (c > 0 && c < 100000) {
+ break;
+ }
+ // create a few nodes, in case there are not enough nodes
+ // for the node counter index to be available
+ Node testNode = session.getRootNode().addNode("test" + i);
+ for (int j = 0; j < 100; j++) {
+ testNode.addNode("n" + j);
+ }
+ session.save();
+ // wait for async indexing (the node counter index is async)
+ Thread.sleep(100);
+ }
+ double c = getCost(session, "//*[@x=1]");
assertTrue("cost: " + c, c > 0 && c < 100000);
// *without* the counter index, the estimated cost to traverse is high