Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-9332

Document best practices and anti-patterns in repository tree traversal

    XMLWordPrintableJSON

Details

    • Documentation
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.40.0
    • doc
    • None

    Description

      When using JCR API, there is more than one way to perform tree/path traversal:

      Node c = session.getNode("/a/b/c");
      Node d = null;
      
      //get child node
      d = session.getNode("/a/b/c/d");
      d = c.getNode("d");
      
      // get parent node
      c = d.getParent();
      c = session.getNode("/a/b/c");
      

      To traverse a path using Node API with  performs better compared to Session API. 

      > java -jar target/oak-benchmarks-*-SNAPSHOT.jar benchmark  GetParentNodeWithNodeAPI  GetParentNodeWithSessionAPI  Oak-Segment-Tar
      Apache Jackrabbit Oak 1.37-SNAPSHOT
      # GetParentNodeWithNodeAPI         C     min     10%     50%     90%     max     N       mean 
      Oak-Segment-Tar                    1       2       2       2       3      5   25891       2
      # GetParentNodeWithSessionAP       C     min     10%     50%     90%     max     N       mean 
      Oak-Segment-Tar                    1      26      27      29      32     40    2069      29

      Example where Session API is used: https://issues.apache.org/jira/browse/SLING-10011

      Considering Oak implementation details (tree repository structure, ACL evaluation, ...) the best practice for path traversal should be explicitly documented.

      Attachments

        Activity

          People

            miroslav Miroslav Smiljanic
            miroslav Miroslav Smiljanic
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: