reschke commented on code in PR #2626:
URL: https://github.com/apache/jackrabbit-oak/pull/2626#discussion_r2786188198


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java:
##########
@@ -1285,6 +1285,37 @@ 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 
unavailable because of re-indexing:\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);
+                if (reindexProp != null && reindexProp.getValue(Type.BOOLEAN)) 
{
+                    reindex.add(name);
+                }

Review Comment:
   If that's a weird case, should we add a DEBUG log for this somewhere?



-- 
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]

Reply via email to