[
https://issues.apache.org/jira/browse/SLING-4512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14377679#comment-14377679
]
Amit Gupta commented on SLING-4512:
-----------------------------------
Attached is a patch that uses TreeTraverser, instead of query. As we are
already doing a query to find language roots, second query to find messages is
a not needed.
Traversal should be better than query in such cases where all the nodes
returned by the query need to be used.
While fixing it, I had to modify tests as well. I am not quite sure about one
particular thing in tests, Test data create nodes of type sling:MessageEntry,
while the xpath query was looking for sling:Message. Assuming xpath query finds
sub types as well, I have taken care of following cases in my implementation
1, Node has a mixin sling:Message
2. Node is of type sling:MessageEntry
{code}
final NodeType[] mixinNodeTypes = node.getMixinNodeTypes();
for (NodeType ntype: mixinNodeTypes) {
if (MIXIN_NAME.equals(ntype.getName())) {
return true;
}
}
//if the node is of type sling:MessageEntry
final NodeType primaryNodeType =
node.getPrimaryNodeType();
if
(primaryNodeType.isNodeType(SLING_MESSAGE_ENTRY)) {
return true;
}
return false;
{code}
can this check be optimized?
> Traversal Warnings in OAK while creating i18n JcrResourceBundle
> ---------------------------------------------------------------
>
> Key: SLING-4512
> URL: https://issues.apache.org/jira/browse/SLING-4512
> Project: Sling
> Issue Type: Improvement
> Components: Extensions
> Reporter: Srijan Bhatnagar
> Assignee: Amit Gupta
> Attachments: SLING-4512.diff
>
>
> org.apache.sling.i18n.impl.JcrResourceBundle#loadFully uses an XPath query to
> load [sling:Message] nodes under given paths. If the subtree under the path
> is too big (>1000), we receive traversal warnings in Oak. The following
> warning is generated if the path is /libs/wcm/core/i18n/de :
> {code}
> GET /content/geometrixx/de.html HTTP/1.1]
> org.apache.jackrabbit.oak.spi.query.Cursors$TraversingCursor Traversed 1000
> nodes with filter Filter(query=select [jcr:path], [jcr:score], * from
> [sling:Message] as a where isdescendantnode(a, '/libs/wcm/core/i18n/de') /*
> xpath: /jcr:root/libs/wcm/core/i18n/de//element(*,sling:Message) */,
> path=/libs/wcm/core/i18n/de//*); consider creating an index or changing the
> query
> {code}
> A suggestion would be to use
> [TreeTraverser|http://jackrabbit.apache.org/api/2.4/org/apache/jackrabbit/commons/flat/TreeTraverser.html]
> instead of XPath query since the subtree is mostly a flat list.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)