You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2025/01/23 09:11:09 UTC
(jackrabbit-oak) branch trunk updated: OAK-11425: MarkSweepGarbageColllector.iterateNodeTree() passes open file to FileIOUtils.sort() (#2017)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 39b1b6c1f7 OAK-11425: MarkSweepGarbageColllector.iterateNodeTree() passes open file to FileIOUtils.sort() (#2017)
39b1b6c1f7 is described below
commit 39b1b6c1f741aa11c0b6f1e07da9d29b810b9878
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Jan 23 10:11:04 2025 +0100
OAK-11425: MarkSweepGarbageColllector.iterateNodeTree() passes open file to FileIOUtils.sort() (#2017)
---
.../plugins/blob/MarkSweepGarbageCollector.java | 24 ++++++++--------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
index 761bc1b4b4..578377ded5 100644
--- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
+++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
@@ -41,7 +41,6 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -622,9 +621,8 @@ public class MarkSweepGarbageCollector implements BlobGarbageCollector {
* @param logPath whether to log path in the file or not
*/
protected void iterateNodeTree(GarbageCollectorFileState fs, final boolean logPath) throws IOException {
- final BufferedWriter writer = new BufferedWriter(new FileWriter(fs.getMarkedRefs(), StandardCharsets.UTF_8));
final AtomicInteger count = new AtomicInteger();
- try {
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(fs.getMarkedRefs(), StandardCharsets.UTF_8))) {
marker.collectReferences(
new ReferenceCollector() {
private final boolean debugMode = LOG.isTraceEnabled();
@@ -663,21 +661,15 @@ public class MarkSweepGarbageCollector implements BlobGarbageCollector {
}
}
);
- LOG.info("Number of valid blob references marked under mark phase of " +
- "Blob garbage collection [{}]", count.get());
- // sort the marked references with the first part of the key
- sort(fs.getMarkedRefs(),
- new Comparator<String>() {
- @Override
- public int compare(String s1, String s2) {
- return s1.split(DELIM)[0].compareTo(s2.split(DELIM)[0]);
- }
- });
- } finally {
- closeQuietly(writer);
}
+
+ LOG.info("Number of valid blob references marked under mark phase of " +
+ "Blob garbage collection [{}]", count.get());
+ // sort the marked references with the first part of the key
+ sort(fs.getMarkedRefs(),
+ (s1, s2) -> s1.split(DELIM)[0].compareTo(s2.split(DELIM)[0]));
}
-
+
@Override
public long checkConsistency(boolean markOnly) throws Exception {
consistencyStatsCollector.start();