mbaedke commented on code in PR #2626:
URL: https://github.com/apache/jackrabbit-oak/pull/2626#discussion_r2816546890
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java:
##########
@@ -1285,6 +1292,38 @@ public void verifyNotPotentiallySlow() {
}
}
}
+
+ private String createTraversalWarningMessage(Traversal traversal) {
+ String caller =
IndexUtils.getCaller(settings.getIgnoredClassNamesInCallTrace());
+ String message = "Traversal query (query without index): " + statement
+ "; called by " + caller + "; consider creating an index";
+ if (traversal == Traversal.FAIL || traversal == Traversal.WARN &&
!potentiallySlowTraversalQueryLogged) {
+ Set<String> reindex = getNamesOfReindexingIndexes();
+ message += "\n\nExecution plan:\n" + getPlan();
+ if (!reindex.isEmpty()) {
+ String reindexNames = reindex.stream().map(name -> name +
",").collect(Collectors.joining());
+ message += "\n\nNote that the following indexes were
re-indexing at query time:\n"
+ + reindexNames.substring(0, reindexNames.length() - 1);
+ }
+ }
+ return message;
+ }
+
+ private Set<String> getNamesOfReindexingIndexes() {
+ Set<String> reindex = new HashSet<>();
+ Iterable<Tree> indexes = context.getRoot().getTree("/" +
INDEX_DEFINITIONS_NAME).getChildren();
+ for (Tree index : indexes) {
+ String name = index.getName();
+ PropertyState primaryType = index.getProperty(JCR_PRIMARYTYPE);
+ if (primaryType != null &&
INDEX_DEFINITIONS_NODE_TYPE.equals(primaryType.getValue(Type.STRING))) {
+ PropertyState reindexProp =
index.getProperty(REINDEX_PROPERTY_NAME);
+ PropertyState typeProp = index.getProperty(TYPE_PROPERTY_NAME);
+ if (reindexProp != null && reindexProp.getValue(Type.BOOLEAN)
&& !(typeProp != null && TYPE_DISABLED.equals(typeProp.getValue(Type.STRING))))
{
Review Comment:
Since this only makes a difference in the case of typeProp == null, I don't
really care.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]