Author: mduerig
Date: Mon Oct 3 09:48:30 2016
New Revision: 1763140
URL: http://svn.apache.org/viewvc?rev=1763140&view=rev
Log:
OAK-2498: Root record references provide too little context for parsing a
segment
Now that the roots have gone the exact segment size calculation can be
simplified
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBufferWriter.java
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBufferWriter.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBufferWriter.java?rev=1763140&r1=1763139&r2=1763140&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBufferWriter.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBufferWriter.java
Mon Oct 3 09:48:30 2016
@@ -23,7 +23,6 @@ import static com.google.common.base.Cha
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Sets.newHashSet;
import static java.lang.System.arraycopy;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.identityHashCode;
@@ -36,7 +35,6 @@ import static org.apache.jackrabbit.oak.
import java.io.IOException;
import java.util.Collection;
-import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -422,30 +420,11 @@ public class SegmentBufferWriter impleme
// avoid the somewhat expensive list and set traversals.
if (segmentSize > buffer.length) {
-
- // The set of old record ids in this segment
- // that were previously root record ids, but will no longer be,
- // because the record to be written references them.
- // This needs to be a set, because the list of ids can
- // potentially reference the same record multiple times
-
- Set<SegmentId> segmentIds = newHashSet();
-
- for (RecordId recordId : ids) {
- SegmentId segmentId = recordId.getSegmentId();
- if (!(segmentId.equals(segment.getSegmentId()))) {
- segmentIds.add(segmentId);
- }
- }
-
- // Adjust the estimation of the new referenced segment ID count.
-
- for (SegmentId segmentId : segmentIds) {
- if (segmentReferences.contains(segmentId)) {
+ for (RecordId id : ids) {
+ if (segmentReferences.contains(id.getSegmentId())) {
referencedIdCount--;
}
}
-
headerSize = HEADER_SIZE + referencedIdCount * 16 +
recordNumbersCount * 12;
segmentSize = align(headerSize + recordSize + length, 16);
}