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.