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 md...@apache.org on 2015/06/02 10:26:54 UTC

svn commit: r1683059 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java

Author: mduerig
Date: Tue Jun  2 08:26:53 2015
New Revision: 1683059

URL: http://svn.apache.org/r1683059
Log:
OAK-2945: Sampling rate feature CompactionGainEstimate is not efficient
Removed the sampling rate feature

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java?rev=1683059&r1=1683058&r2=1683059&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java Tue Jun  2 08:26:53 2015
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment.file;
 
-import static java.lang.Integer.getInteger;
 import static org.apache.jackrabbit.oak.api.Type.BINARIES;
 
 import java.io.File;
@@ -36,17 +35,6 @@ import org.apache.jackrabbit.oak.spi.sta
 
 class CompactionGainEstimate implements TarEntryVisitor {
 
-    /**
-     * The sampling rate of the compaction estimation process.
-     * For a value of {@code n} only a random sample containing
-     * every n-th segment is taken into account for estimating the
-     * compaction gain.
-     * <p>
-     * Defaults to 1.
-     */
-    public static final int UUID_SAMPLING_RATE =
-            getInteger("compaction.estimate.sampling.rate", 1);
-
     private static final Funnel<UUID> UUID_FUNNEL = new Funnel<UUID>() {
         @Override
         public void funnel(UUID from, PrimitiveSink into) {
@@ -68,15 +56,15 @@ class CompactionGainEstimate implements
 
     private void collectReferencedSegments(SegmentNodeState node, RecordIdSet visited) {
         if (visited.addIfNotPresent(node.getRecordId())) {
-            collectUUID(asUUID(node.getRecordId().getSegmentId()));
+            collectUUID(node.getRecordId().getSegmentId());
             for (PropertyState property : node.getProperties()) {
                 if (property instanceof SegmentPropertyState) {
-                    collectUUID(asUUID(((SegmentPropertyState) property)
-                            .getRecordId().getSegmentId()));
+                    collectUUID(((SegmentPropertyState) property)
+                            .getRecordId().getSegmentId());
                 }
                 for (Blob blob : property.getValue(BINARIES)) {
                     for (SegmentId id : SegmentBlob.getBulkSegmentIds(blob)) {
-                        collectUUID(asUUID(id));
+                        collectUUID(id);
                     }
                 }
             }
@@ -87,19 +75,10 @@ class CompactionGainEstimate implements
         }
     }
 
-    private void collectUUID(UUID uuid) {
-        if (includeUUID(uuid)) {
-            uuids.put(uuid);
-        }
-    }
-
-    private static boolean includeUUID(UUID uuid) {
-        return uuid.getLeastSignificantBits() % UUID_SAMPLING_RATE == 0;
-    }
-
-    private static UUID asUUID(SegmentId id) {
-        return new UUID(id.getMostSignificantBits(),
-                id.getLeastSignificantBits());
+    private void collectUUID(SegmentId segmentId) {
+        uuids.put(new UUID(
+            segmentId.getMostSignificantBits(),
+            segmentId.getLeastSignificantBits()));
     }
 
     /**
@@ -128,12 +107,10 @@ class CompactionGainEstimate implements
     @Override
     public void visit(long msb, long lsb, File file, int offset, int size) {
         UUID uuid = new UUID(msb, lsb);
-        if (includeUUID(uuid)) {
-            int entrySize = TarReader.getEntrySize(size);
-            totalSize += entrySize;
-            if (uuids.mightContain(uuid)) {
-                reachableSize += entrySize;
-            }
+        int entrySize = TarReader.getEntrySize(size);
+        totalSize += entrySize;
+        if (uuids.mightContain(uuid)) {
+            reachableSize += entrySize;
         }
     }