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


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java:
##########
@@ -605,8 +773,147 @@ private void collectDeletedDocuments(GCPhases phases,
                     gc.updateResurrectedDocuments(phases.stats);
                     phases.stop(GCPhase.UPDATING);
                 }
+            }
+        }
+    }
+
+    private class DetailedGC implements Closeable {
+
+        private final RevisionVector headRevision;
+        private final GCMonitor monitor;
+        private final AtomicBoolean cancel;
+        private final Stopwatch timer;
+        private final List<UpdateOp> updateOpList;
+        private int garbageDocsCount;
+
+        public DetailedGC(@NotNull RevisionVector headRevision, @NotNull 
GCMonitor monitor, @NotNull AtomicBoolean cancel) {
+            this.headRevision = requireNonNull(headRevision);
+            this.monitor = monitor;
+            this.cancel = cancel;
+            this.updateOpList = new ArrayList<>();
+            this.timer = Stopwatch.createUnstarted();
+        }
+
+        public void collectGarbage(final NodeDocument doc, final GCPhases 
phases) {
+
+            monitor.info("Collecting Detailed Garbage for doc [{}]", 
doc.getId());
+
+            final UpdateOp op = new UpdateOp(requireNonNull(doc.getId()), 
false);
+            collectDeletedProperties(doc, phases, op);
+            collectUnmergedBranchCommitDocument(doc, phases, op);
+            collectOldRevisions(doc, phases, op);
+            // only add if there are changes for this doc
+            if (op.hasChanges()) {
+                garbageDocsCount++;
+                monitor.info("Collected [{}] garbage for doc [{}]", 
op.getChanges().size(), doc.getId());
+                updateOpList.add(op);
+            }
+        }
+
+        private boolean hasGarbage() {
+            return garbageDocsCount > 0;
+        }
+
+        private void collectUnmergedBranchCommitDocument(final NodeDocument 
doc, final GCPhases phases, final UpdateOp updateOp) {
+            if (phases.start(GCPhase.COLLECT_UNMERGED_BC)){
+                // TODO add umerged BC collection logic
+                phases.stop(GCPhase.COLLECT_UNMERGED_BC);
+            }
+
+        }
+
+        private void collectDeletedProperties(final NodeDocument doc, final 
GCPhases phases, final UpdateOp updateOp) {
+
+            // get Map of all properties along with their values
+            if (phases.start(GCPhase.COLLECT_PROPS)) {
+                final Set<String> properties = doc.getPropertyNames();

Review Comment:
   There is a problem with using `NodeDocument.getPropertyNames()` here and 
comparing it directly with `DocumentNodeState.getPropertyNames()` below : the 
former containes escaped values while the latter does not. The escaping is 
handled in `Utils.escapePropertyName` / `Utils.unescapePropertyName`



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