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 al...@apache.org on 2014/12/08 11:06:22 UTC
svn commit: r1643774 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/CompactionGainEstimate.java
Author: alexparvulescu
Date: Mon Dec 8 10:06:22 2014
New Revision: 1643774
URL: http://svn.apache.org/r1643774
Log:
OAK-2322 Compaction estimation includes all data segments
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=1643774&r1=1643773&r2=1643774&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 Mon Dec 8 10:06:22 2014
@@ -29,6 +29,7 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.segment.SegmentBlob;
import org.apache.jackrabbit.oak.plugins.segment.SegmentId;
import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentPropertyState;
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
import com.google.common.hash.BloomFilter;
@@ -53,29 +54,38 @@ class CompactionGainEstimate implements
CompactionGainEstimate(SegmentNodeState node, int estimatedBulkCount) {
uuids = BloomFilter.create(UUID_FUNNEL, estimatedBulkCount);
- collectBulkSegments(node, new HashSet<ThinRecordId>());
+ collectReferencedSegments(node, new HashSet<ThinRecordId>());
}
- private void collectBulkSegments(SegmentNodeState node,
+ private void collectReferencedSegments(SegmentNodeState node,
Set<ThinRecordId> visited) {
ThinRecordId tr = ThinRecordId.apply(node.getRecordId());
if (!visited.contains(tr)) {
+ uuids.put(asUUID(node.getRecordId().getSegmentId()));
for (PropertyState property : node.getProperties()) {
+ if (property instanceof SegmentPropertyState) {
+ uuids.put(asUUID(((SegmentPropertyState) property)
+ .getRecordId().getSegmentId()));
+ }
for (Blob blob : property.getValue(BINARIES)) {
for (SegmentId id : SegmentBlob.getBulkSegmentIds(blob)) {
- uuids.put(new UUID(id.getMostSignificantBits(), id
- .getLeastSignificantBits()));
+ uuids.put(asUUID(id));
}
}
}
for (ChildNodeEntry child : node.getChildNodeEntries()) {
- collectBulkSegments((SegmentNodeState) child.getNodeState(),
+ collectReferencedSegments((SegmentNodeState) child.getNodeState(),
visited);
}
visited.add(tr);
}
}
+ private static UUID asUUID(SegmentId id) {
+ return new UUID(id.getMostSignificantBits(),
+ id.getLeastSignificantBits());
+ }
+
/**
* Returns a percentage estimate (scale 0-100) for how much disk space
* running compaction (and cleanup) could potentially release.
@@ -103,8 +113,7 @@ class CompactionGainEstimate implements
public void visit(long msb, long lsb, File file, int offset, int size) {
int entrySize = TarReader.getEntrySize(size);
totalSize += entrySize;
- if (SegmentId.isDataSegmentId(lsb)
- || uuids.mightContain(new UUID(msb, lsb))) {
+ if (uuids.mightContain(new UUID(msb, lsb))) {
reachableSize += entrySize;
}
}