jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shu...@apache.org
Subject svn commit: r1044239 - in /jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance: AbstractPerformanceTest.java DescendantSearchTest.java SQL2DescendantSearchTest.java
Date Fri, 10 Dec 2010 08:06:05 GMT
Author: shuber
Date: Fri Dec 10 08:06:04 2010
New Revision: 1044239

URL: http://svn.apache.org/viewvc?rev=1044239&view=rev
Log:
JCR-2835 Poor performance of ISDESCENDANTNODE on SQL 2 queries

Here are two performance test units for testing descendant nodes.

Added:
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/DescendantSearchTest.java
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SQL2DescendantSearchTest.java
Modified:
    jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractPerformanceTest.java

Modified: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractPerformanceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractPerformanceTest.java?rev=1044239&r1=1044238&r2=1044239&view=diff
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractPerformanceTest.java
(original)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractPerformanceTest.java
Fri Dec 10 08:06:04 2010
@@ -101,6 +101,8 @@ public abstract class AbstractPerformanc
         runTest(new ConcurrentReadWriteTest(), name, conf);
         runTest(new SimpleSearchTest(), name, conf);
         runTest(new SQL2SearchTest(), name, conf);
+        runTest(new DescendantSearchTest(), name, conf);
+        runTest(new SQL2DescendantSearchTest(), name, conf);
         runTest(new TwoWayJoinTest(), name, conf);
         runTest(new ThreeWayJoinTest(), name, conf);
         runTest(new CreateManyChildNodesTest(), name, conf);

Added: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/DescendantSearchTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/DescendantSearchTest.java?rev=1044239&view=auto
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/DescendantSearchTest.java
(added)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/DescendantSearchTest.java
Fri Dec 10 08:06:04 2010
@@ -0,0 +1,65 @@
+package org.apache.jackrabbit.performance;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+/**
+ * Performance test to check performance of queries on sub-trees.
+ */
+public class DescendantSearchTest extends AbstractTest {
+
+    private static final int NODE_COUNT = 100;
+
+    private Session session;
+
+    private Node root;
+
+    protected Query createQuery(QueryManager manager, int i)
+            throws RepositoryException {
+        return manager.createQuery("/testroot//*[@testcount=" + i + "]", Query.XPATH);
+    }
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+
+        root = session.getRootNode().addNode("testroot", "nt:unstructured");
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Node node = root.addNode("node" + i, "nt:unstructured");
+            for (int j = 0; j < NODE_COUNT; j++) {
+                Node child = node.addNode("node" + j, "nt:unstructured");
+                child.setProperty("testcount", j);
+            }
+            session.save();
+        }
+    }
+
+    public void runTest() throws Exception {
+        QueryManager manager = session.getWorkspace().getQueryManager();
+        for (int i = 0; i < NODE_COUNT; i++) {
+            Query query = createQuery(manager, i);
+            NodeIterator iterator = query.execute().getNodes();
+            while (iterator.hasNext()) {
+                Node node = iterator.nextNode();
+                if (node.getProperty("testcount").getLong() != i) {
+                    throw new Exception("Invalid test result: " + node.getPath());
+                }
+            }
+        }
+    }
+
+    public void afterSuite() throws RepositoryException {
+        for (int i = 0; i < NODE_COUNT; i++) {
+            root.getNode("node" + i).remove();
+            session.save();
+        }
+
+        root.remove();
+        session.save();
+        session.logout();
+    }
+
+}

Added: jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SQL2DescendantSearchTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SQL2DescendantSearchTest.java?rev=1044239&view=auto
==============================================================================
--- jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SQL2DescendantSearchTest.java
(added)
+++ jackrabbit/trunk/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SQL2DescendantSearchTest.java
Fri Dec 10 08:06:04 2010
@@ -0,0 +1,19 @@
+package org.apache.jackrabbit.performance;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+/**
+ * SQL-2 version of the sub-tree performance test.
+ */
+public class SQL2DescendantSearchTest extends DescendantSearchTest {
+
+    protected Query createQuery(QueryManager manager, int i)
+            throws RepositoryException {
+        return manager.createQuery(
+                "SELECT * FROM [nt:base] AS n WHERE ISDESCENDANTNODE(n, '/testroot') AND
testcount=" + i,
+                "JCR-SQL2");
+    }
+
+}



Mime
View raw message