jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1448937 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/segment/ test/java/org/apache/jackrabbit/oak/plugins/segment/
Date Fri, 22 Feb 2013 08:37:11 GMT
Author: jukka
Date: Fri Feb 22 08:37:10 2013
New Revision: 1448937

URL: http://svn.apache.org/r1448937
Log:
OAK-632: SegmentMK: Efficient updates of flat nodes

Use 32 instead of 64 buckets per HAMT level to reduce the size overhead of small updates.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java?rev=1448937&r1=1448936&r2=1448937&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MapRecord.java
Fri Feb 22 08:37:10 2013
@@ -31,7 +31,7 @@ class MapRecord extends Record {
     public interface Entry extends Map.Entry<String, RecordId> {    
     }
 
-    static final int LEVEL_BITS = 6;
+    static final int LEVEL_BITS = 5;
 
     MapRecord(RecordId id) {
         super(id);
@@ -82,12 +82,12 @@ class MapRecord extends Record {
             }
             return null;
         } else {
-            long bucketMap = reader.readLong(getRecordId(), 4);
+            int bucketMap = reader.readInt(getRecordId(), 4);
             int bucketIndex = (code >> shift) & mask;
-            long bucketBit = 1L << bucketIndex;
+            int bucketBit = 1 << bucketIndex;
             if ((bucketMap & bucketBit) != 0) {
-                bucketIndex = Long.bitCount(bucketMap & (bucketBit - 1));
-                RecordId bucketId = reader.readRecordId(getRecordId(), 12 + bucketIndex *
Segment.RECORD_ID_BYTES);
+                bucketIndex = Integer.bitCount(bucketMap & (bucketBit - 1));
+                RecordId bucketId = reader.readRecordId(getRecordId(), 8 + bucketIndex *
Segment.RECORD_ID_BYTES);
                 return new MapRecord(bucketId).getEntry(reader, key, level + 1);
             } else {
                 return null;
@@ -145,13 +145,13 @@ class MapRecord extends Record {
                 }
             };
         } else {
-            long bucketMap = reader.readLong(getRecordId(), 4);
-            int bucketCount = Long.bitCount(bucketMap);
+            int bucketMap = reader.readInt(getRecordId(), 4);
+            int bucketCount = Integer.bitCount(bucketMap);
             List<Iterable<Entry>> iterables =
                     Lists.newArrayListWithCapacity(bucketCount);
             for (int i = 0; i < bucketCount; i++) {
                 RecordId bucketId = reader.readRecordId(
-                        getRecordId(), 12 + i * Segment.RECORD_ID_BYTES);
+                        getRecordId(), 8 + i * Segment.RECORD_ID_BYTES);
                 iterables.add(new MapRecord(bucketId).getEntries(reader, level + 1));
             }
             return Iterables.concat(iterables);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java?rev=1448937&r1=1448936&r2=1448937&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
Fri Feb 22 08:37:10 2013
@@ -277,17 +277,17 @@ public class SegmentWriter {
                     buckets[bucketIndex].add(entry);
                 }
 
-                long baseMap = reader.readLong(baseId, 4);
+                int baseMap = reader.readInt(baseId, 4);
 
                 int newSize = 0;
                 RecordId[] bucketIds = new RecordId[size];
                 for (int i = 0; i < buckets.length; i++) {
-                    long bucketBit = 1L << i;
+                    int bucketBit = 1 << i;
                     RecordId baseBucketId = null;
                     if ((baseMap & bucketBit) != 0) {
-                        int index = Long.bitCount(baseMap & (bucketBit - 1));
+                        int index = Integer.bitCount(baseMap & (bucketBit - 1));
                         baseBucketId = reader.readRecordId(
-                                baseId, 12 + index * Segment.RECORD_ID_BYTES);
+                                baseId, 8 + index * Segment.RECORD_ID_BYTES);
                     }
                     if (buckets[i] != null) {
                         BucketInfo info = writeMapBucket(
@@ -303,17 +303,17 @@ public class SegmentWriter {
                 }
                 
                 List<RecordId> ids = Lists.newArrayList();
-                long bucketMap = 0L;
+                int bucketMap = 0;
                 for (int i = 0; i < buckets.length; i++) {
                     if (bucketIds[i] != null) {
                         ids.add(bucketIds[i]);
-                        bucketMap |= 1L << i;
+                        bucketMap |= 1 << i;
                     }
                 }
 
                 RecordId bucketId = prepare(12, ids);
                 writeInt(newSize);
-                writeLong(bucketMap);
+                writeInt(bucketMap);
                 for (RecordId id : ids) {
                     writeRecordId(id);
                 }
@@ -351,17 +351,17 @@ public class SegmentWriter {
             }
 
             List<RecordId> bucketIds = Lists.newArrayList();
-            long bucketMap = 0L;
+            int bucketMap = 0;
             for (int i = 0; i < buckets.length; i++) {
                 if (buckets[i] != null) {
                     bucketIds.add(writeMapBucket(null, buckets[i], level + 1).id);
-                    bucketMap |= 1L << i;
+                    bucketMap |= 1 << i;
                 }
             }
 
-            RecordId bucketId = prepare(12, bucketIds);
+            RecordId bucketId = prepare(8, bucketIds);
             writeInt(entries.size());
-            writeLong(bucketMap);
+            writeInt(bucketMap);
             for (RecordId id : bucketIds) {
                 writeRecordId(id);
             }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java?rev=1448937&r1=1448936&r2=1448937&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java
Fri Feb 22 08:37:10 2013
@@ -156,14 +156,14 @@ public class SegmentSizeTest {
         SegmentNodeState state = writer.writeNode(builder.getNodeState());
         writer.flush();
         Segment segment = store.readSegment(state.getRecordId().getSegmentId());
-        assertEquals(26040, segment.getData().length);
+        assertEquals(28588, segment.getData().length);
 
         builder = state.builder();
         builder.child("child1000");
         state = writer.writeNode(builder.getNodeState());
         writer.flush();
         segment = store.readSegment(state.getRecordId().getSegmentId());
-        assertEquals(576, segment.getData().length);
+        assertEquals(260, segment.getData().length);
     }
 
     private int getSize(NodeBuilder builder) {



Mime
View raw message