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 2024/11/29 11:32:34 UTC

(jackrabbit-oak) branch OAK-11288 updated: OAK-11288: remove usage of Immutable.Map.builder() - oak-segment-tar

This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch OAK-11288
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/OAK-11288 by this push:
     new aebc1bbf56 OAK-11288: remove usage of Immutable.Map.builder() - oak-segment-tar
aebc1bbf56 is described below

commit aebc1bbf56024920b70409011cf3f7e922f4076e
Author: Julian Reschke <re...@apache.org>
AuthorDate: Fri Nov 29 12:32:25 2024 +0100

    OAK-11288: remove usage of Immutable.Map.builder() - oak-segment-tar
---
 .../oak/segment/SegmentNodeStoreStats.java         | 17 ++++-----
 .../oak/segment/file/ReclaimersTest.java           | 42 ++++++++++++----------
 2 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java
index 0141b45df6..7e98e0c4c1 100644
--- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java
+++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreStats.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.jackrabbit.oak.segment;
 
 import static org.apache.jackrabbit.stats.TimeSeriesStatsUtil.asCompositeData;
@@ -39,7 +38,6 @@ import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.api.stats.TimeSeries;
 import org.apache.jackrabbit.oak.segment.CommitsTracker.Commit;
 import org.apache.jackrabbit.oak.segment.file.tar.GCGeneration;
@@ -202,14 +200,13 @@ public class SegmentNodeStoreStats implements SegmentNodeStoreStatsMBean, Segmen
 
     @NotNull
     private Map<String, Object> toMap(@NotNull Commit commit) {
-        return ImmutableMap.<String, Object>builder()
-            .put("writerName", commit.getThreadName())
-            .put("writerDetails", toString(commit.getStackTrace()))
-            .put("GCGeneration", toString(commit.getGCGeneration()))
-            .put("queued", commit.getQueued())
-            .put("dequeued", commit.getDequeued())
-            .put("applied", commit.getApplied())
-            .build();
+        return Map.of(
+            "writerName", commit.getThreadName(),
+            "writerDetails", toString(commit.getStackTrace()),
+            "GCGeneration", toString(commit.getGCGeneration()),
+            "queued", commit.getQueued(),
+            "dequeued", commit.getDequeued(),
+            "applied", commit.getApplied());
     }
 
     @NotNull
diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ReclaimersTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ReclaimersTest.java
index 23a3082128..933af519d1 100644
--- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ReclaimersTest.java
+++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ReclaimersTest.java
@@ -26,50 +26,56 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.function.Predicate;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
 import org.apache.jackrabbit.oak.segment.file.tar.GCGeneration;
 import org.junit.Test;
 
 public class ReclaimersTest {
 
-    private static final Map<String, GCGeneration> gcHistory = ImmutableMap.<String, GCGeneration>builder()
-        .put("00w", newGCGeneration(0, 0, false))
+    private static final Map<String, GCGeneration> gcHistory;
+
+    static  {
+        Map<String, GCGeneration> builder = new HashMap<>();
+
+        builder.put("00w", newGCGeneration(0, 0, false));
 
         // First compaction. Always FULL
-        .put("11c", newGCGeneration(1, 1, true))
-        .put("11w", newGCGeneration(1, 1, false))
+        builder.put("11c", newGCGeneration(1, 1, true));
+        builder.put("11w", newGCGeneration(1, 1, false));
 
         // TAIL compaction
-        .put("21c", newGCGeneration(2, 1, true))
-        .put("21w", newGCGeneration(2, 1, false))
+        builder.put("21c", newGCGeneration(2, 1, true));
+        builder.put("21w", newGCGeneration(2, 1, false));
 
         // TAIL compaction
-        .put("31c", newGCGeneration(3, 1, true))
-        .put("31w", newGCGeneration(3, 1, false))
+        builder.put("31c", newGCGeneration(3, 1, true));
+        builder.put("31w", newGCGeneration(3, 1, false));
 
         // FULL compaction
-        .put("42c", newGCGeneration(4, 2, true))
-        .put("42w", newGCGeneration(4, 2, false))
+        builder.put("42c", newGCGeneration(4, 2, true));
+        builder.put("42w", newGCGeneration(4, 2, false));
 
         // TAIL compaction
-        .put("52c", newGCGeneration(5, 2, true))
-        .put("52w", newGCGeneration(5, 2, false))
+        builder.put("52c", newGCGeneration(5, 2, true));
+        builder.put("52w", newGCGeneration(5, 2, false));
 
         // TAIL compaction
-        .put("62c", newGCGeneration(6, 2, true))
-        .put("62w", newGCGeneration(6, 2, false))
+        builder.put("62c", newGCGeneration(6, 2, true));
+        builder.put("62w", newGCGeneration(6, 2, false));
 
         // FULL compaction
-        .put("73c", newGCGeneration(7, 3, true))
-        .put("73w", newGCGeneration(7, 3, false))
+        builder.put("73c", newGCGeneration(7, 3, true));
+        builder.put("73w", newGCGeneration(7, 3, false));
 
-        .build();
+        gcHistory = Collections.unmodifiableMap(builder);
+    };
 
     private static void assertReclaim(Predicate<GCGeneration> reclaimer, String... reclaims) {
         Set<String> toReclaim = CollectionUtils.toSet(reclaims);