XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • jackrabbit-core
    • None

    Description

      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

      Attachments

        Activity

          People

            thomasm Thomas Mueller
            thomasm Thomas Mueller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: