thomasmueller commented on code in PR #2302:
URL: https://github.com/apache/jackrabbit-oak/pull/2302#discussion_r2101874783
##########
oak-run/src/main/java/org/apache/jackrabbit/oak/index/merge/IndexDefMergerUtils.java:
##########
@@ -287,6 +292,81 @@ private static JsonObject mergeChild(String path, String
child, int level, JsonO
}
}
+ private static JsonObject mergeAggregates(String path, String child, int
level, JsonObject ancestor, JsonObject custom, JsonObject product,
+ ArrayList<String> conflicts) {
+
+ // merge, with level + 1 so that we don't recurse into this function
again
+ // conflicts are redirected to a new, temporary list
+ ArrayList<String> aggregateConflicts = new ArrayList<>();
+ JsonObject merged = mergeChild(path, child, level + 1, ancestor,
custom, product, aggregateConflicts);
+
+ // if there were conflicts, resolve them
+ if (!aggregateConflicts.isEmpty()) {
+
+ // list of "include" elements to move to the end
+ ArrayList<JsonObject> elementToMove = new ArrayList<>();
+
+ // which is the next id for "include" (eg. 12)
+ long nextIncludeId =
getNextIncludeId(ancestor.getChildren().get(child));
+ nextIncludeId = Math.max(nextIncludeId,
getNextIncludeId(custom.getChildren().get(child)));
+ nextIncludeId = Math.max(nextIncludeId,
getNextIncludeId(product.getChildren().get(child)));
+
+ // loop over conflicts, and find + remove these
+ // the aggregateConflicts will contain entries that look like this:
+ // "Could not merge value;
path=/oak:index/assets-11/aggregates/asset/include11
+ // property=path; ancestor=null; custom=...; product=..."
+ // and we need to extract the path
+ for (String n : aggregateConflicts) {
+ String regex = "path=([^\\s]+)\\sproperty=";
Review Comment:
Yes it's a bit a hack. But this string is coming from the same class; it is
not a dependency to another library. So if we change the format, the test would
break; and a version bump of another library will not cause issues.
--
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]