stefan-egli commented on code in PR #1547:
URL: https://github.com/apache/jackrabbit-oak/pull/1547#discussion_r1650518213


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java:
##########
@@ -132,6 +133,56 @@ public CloseableIterable<NodeDocument> 
getPossiblyDeletedDocs(final long fromMod
                 input -> store.convertFromDBObject(NODES, input)));
     }
 
+    /**
+     * Calculate the bson representing including only the provided
+     * include path prefixes and/or excluding the provided
+     * exclude path prefixes - if any are provided - AND the provided
+     * query.
+     * Please note that at the moment the includes do not
+     * take long paths into account. That is, if a long path was
+     * supposed to be included via an include, it is not.
+     * Reason for this is that long paths would require
+     * the mongo query to include a '_path' condition - which disallows
+     * mongo from using the '_modified_id' index. IOW long paths
+     * would result in full scans - which results in bad performance.
+     * @param includes set of path prefixes which should only be considered
+     * @param excludes set of path prefixes which should be excluded.
+     * if these overlap with includes, then exclude has precedence.
+     * @param query the query with which to do an AND
+     * @return the combined bson with include/exclude path prefixes
+     * AND the provided query
+     */
+    private Bson withIncludeExcludes(Set<String> includes, Set<String> 
excludes, Bson query) {
+        Bson inclExcl = null;
+        if (includes != null && !includes.isEmpty()) {
+            final List<Bson> ors = new ArrayList<>(includes.size());
+            for (String incl : includes) {
+                ors.add(Filters.regex(ID, ":" + incl));
+            }
+            inclExcl = or(ors);
+        }
+        if (excludes != null && !excludes.isEmpty()) {
+            final List<Bson> ands = new ArrayList<>(excludes.size());
+            for (String excl : excludes) {
+                ands.add(not(Filters.regex(ID, ":" + excl)));
+            }

Review Comment:
   Great, thanks for the heads-up @nfsantos ! I'll need to see how to fix this 
(worst case would I guess be to disallow exclude paths until that's improved)



-- 
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: oak-dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to