jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] Created: (JCR-2033) Node.orderBefore is slow
Date Wed, 18 Mar 2009 09:07:50 GMT
Node.orderBefore is slow
------------------------

                 Key: JCR-2033
                 URL: https://issues.apache.org/jira/browse/JCR-2033
             Project: Jackrabbit Content Repository
          Issue Type: Improvement
          Components: jackrabbit-core
            Reporter: Thomas Mueller
            Assignee: Thomas Mueller
            Priority: Minor


Use case: I have a node with a medium number of child nodes, and want to sort the child nodes.
To do that, I use Node.orderBefore.

This is slow (31 seconds to sort 2000 child nodes), O(n^2).

Workarounds: 
1) don't use that many child nodes
2) instead of using orderBefore, create a new node with the children in the right order

Test case:

Session session = new TransientRepository().login(new SimpleCredentials("", new char[0]));
Node root = session.getRootNode();
Node test = root.hasNode("test") ? root.getNode("test") : root.addNode("test");
long start = System.currentTimeMillis();
int len = 2000;
for (int i = 0; i < len; i++) {
    test.addNode("n" + i);
}
System.out.println("creating: " + (System.currentTimeMillis() - start));
session.save();
start = System.currentTimeMillis();
for (int i = 0; i < len; i++) {
    test.orderBefore("n" + i, null);
}
System.out.println("sorted: " + (System.currentTimeMillis() - start));
session.logout();

Output:
creating: 712
sorted: 31281

Possible solutions:
- speed up Node.orderBefore
- create a 'sorting tool' that uses the 'create new node' trick
- create a new (Jackrabbit internal) solution to sort quickly


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message