You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Miroslav Smiljanic (Jira)" <ji...@apache.org> on 2021/01/21 12:00:01 UTC
[jira] [Updated] (OAK-9332) Document best practices and
anti-patterns in repository tree traversal
[ https://issues.apache.org/jira/browse/OAK-9332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Miroslav Smiljanic updated OAK-9332:
------------------------------------
Description:
When using JCR API, there is more than one way to perform tree/path traversal:
{code:java}
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");
{code}
To traverse a path using Node API with performs better compared to Session API.
{noformat}
> 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{noformat}
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.
was:
When using JCR API, there is more than one way to perform tree/path traversal:
{code:java}
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");
{code}
To traverse a path using Node API with relative paths performs better compared to Session API.
{noformat}
> 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{noformat}
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.
> Document best practices and anti-patterns in repository tree traversal
> ------------------------------------------------------------------------
>
> Key: OAK-9332
> URL: https://issues.apache.org/jira/browse/OAK-9332
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: doc
> Reporter: Miroslav Smiljanic
> Priority: Major
>
> When using JCR API, there is more than one way to perform tree/path traversal:
> {code:java}
> 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");
> {code}
> To traverse a path using Node API with performs better compared to Session API.
> {noformat}
> > 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{noformat}
> 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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)