jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1526662 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/segment/ test/java/org/apache/jackrabbit/oak/plugins/segment/
Date Thu, 26 Sep 2013 19:59:54 GMT
Author: jukka
Date: Thu Sep 26 19:59:53 2013
New Revision: 1526662

URL: http://svn.apache.org/r1526662
Log:
OAK-1031: SegmentMK: Fewer segment lookups

Reduce the number of uses of the SegmentReader class

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ListRecord.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ListRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ListRecord.java?rev=1526662&r1=1526661&r2=1526662&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ListRecord.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ListRecord.java
Thu Sep 26 19:59:53 2013
@@ -43,7 +43,7 @@ class ListRecord extends Record {
         return size;
     }
 
-    public RecordId getEntry(SegmentReader reader, int index) {
+    public RecordId getEntry(int index) {
         checkElementIndex(index, size);
 
         if (size == 1) {
@@ -54,7 +54,7 @@ class ListRecord extends Record {
             Segment segment = getSegment();
             RecordId bucketId = segment.readRecordId(getOffset(0, bucketIndex));
             ListRecord bucket = new ListRecord(segment, bucketId, bucketSize);
-            return bucket.getEntry(reader, bucketOffset);
+            return bucket.getEntry(bucketOffset);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java?rev=1526662&r1=1526661&r2=1526662&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentPropertyState.java
Thu Sep 26 19:59:53 2013
@@ -75,9 +75,8 @@ class SegmentPropertyState extends Abstr
 
         ListRecord values = getValueList();
         Segment segment = store.readSegment(recordId.getSegmentId());
-        SegmentReader reader = new SegmentReader(store);
         for (int i = 0; i < values.size(); i++) {
-            RecordId valueId = values.getEntry(reader, i);
+            RecordId valueId = values.getEntry(i);
             String value = segment.readString(valueId);
             map.put(value, valueId);
         }
@@ -163,7 +162,7 @@ class SegmentPropertyState extends Abstr
         }
 
         SegmentReader reader = new SegmentReader(store);
-        RecordId valueId = values.getEntry(reader, index);
+        RecordId valueId = values.getEntry(index);
         if (type == Type.BINARY) {
             return (T) new SegmentBlob(reader, valueId);
         } else {
@@ -206,10 +205,12 @@ class SegmentPropertyState extends Abstr
     public long size(int index) {
         ListRecord values = getValueList();
         checkElementIndex(index, values.size());
-        SegmentReader reader = new SegmentReader(store);
-        return reader.readLength(values.getEntry(reader, 0));
+        RecordId valueId = values.getEntry(0);
+        Segment segment = store.readSegment(valueId.getSegmentId());
+        return segment.readLength(valueId.getOffset());
     }
 
+
     //------------------------------------------------------------< Object >--
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java?rev=1526662&r1=1526661&r2=1526662&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentReader.java
Thu Sep 26 19:59:53 2013
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
 public class SegmentReader {
 
     private final SegmentStore store;
@@ -27,58 +24,9 @@ public class SegmentReader {
         this.store = store;
     }
 
-    public long readLength(RecordId recordId) {
-        checkNotNull(recordId);
-        Segment segment = store.readSegment(recordId.getSegmentId());
-        return readLength(segment, recordId.getOffset());
-    }
-
-    private long readLength(Segment segment, int offset) {
-        return segment.readLength(offset);
-    }
-
     public SegmentStream readStream(RecordId recordId) {
         Segment segment = store.readSegment(recordId.getSegmentId());
         return segment.readStream(recordId.getOffset());
     }
 
-    public byte readByte(RecordId recordId, int position) {
-        checkNotNull(recordId);
-        checkArgument(position >= 0);
-        Segment segment = store.readSegment(recordId.getSegmentId());
-        return segment.readByte(recordId.getOffset() + position);
-    }
-
-    public int readInt(RecordId recordId, int position) {
-        checkNotNull(recordId);
-        checkArgument(position >= 0);
-        Segment segment = store.readSegment(recordId.getSegmentId());
-        return segment.readInt(recordId.getOffset() + position);
-    }
-
-    public RecordId readRecordId(RecordId recordId, int position) {
-        checkNotNull(recordId);
-        checkArgument(position >= 0);
-
-        Segment segment = store.readSegment(recordId.getSegmentId());
-        return segment.readRecordId(recordId.getOffset() + position);
-    }
-
-    public ListRecord readList(RecordId recordId, int numberOfEntries) {
-        checkNotNull(recordId);
-        checkArgument(numberOfEntries >= 0);
-
-        Segment segment = store.readSegment(recordId.getSegmentId());
-        if (numberOfEntries > 0) {
-            RecordId id = segment.readRecordId(recordId.getOffset());
-            return new ListRecord(segment, id, numberOfEntries);
-        } else {
-            return new ListRecord(segment, recordId, numberOfEntries);
-        }
-    }
-
-    SegmentStore getStore() {
-        return store;
-    }
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java?rev=1526662&r1=1526661&r2=1526662&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStream.java
Thu Sep 26 19:59:53 2013
@@ -156,10 +156,9 @@ public class SegmentStream extends Input
                 len = (int) (length - position);
             }
 
-            SegmentReader reader = new SegmentReader(store);
             BlockRecord block = new BlockRecord(
                     blocks.getSegment(),
-                    blocks.getEntry(reader, blockIndex),
+                    blocks.getEntry(blockIndex),
                     BLOCK_SIZE);
             len = block.read(blockOffset, b, off, len);
             position += len;

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java?rev=1526662&r1=1526661&r2=1526662&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java
Thu Sep 26 19:59:53 2013
@@ -93,19 +93,19 @@ public class RecordTest {
         ListRecord level2p = writeList(LEVEL_SIZE * LEVEL_SIZE + 1, blockId);
 
         assertEquals(1, one.size());
-        assertEquals(blockId, one.getEntry(reader, 0));
+        assertEquals(blockId, one.getEntry(0));
         assertEquals(LEVEL_SIZE, level1.size());
-        assertEquals(blockId, level1.getEntry(reader, 0));
-        assertEquals(blockId, level1.getEntry(reader, LEVEL_SIZE - 1));
+        assertEquals(blockId, level1.getEntry(0));
+        assertEquals(blockId, level1.getEntry(LEVEL_SIZE - 1));
         assertEquals(LEVEL_SIZE + 1, level1p.size());
-        assertEquals(blockId, level1p.getEntry(reader, 0));
-        assertEquals(blockId, level1p.getEntry(reader, LEVEL_SIZE));
+        assertEquals(blockId, level1p.getEntry(0));
+        assertEquals(blockId, level1p.getEntry(LEVEL_SIZE));
         assertEquals(LEVEL_SIZE * LEVEL_SIZE, level2.size());
-        assertEquals(blockId, level2.getEntry(reader, 0));
-        assertEquals(blockId, level2.getEntry(reader, LEVEL_SIZE * LEVEL_SIZE - 1));
+        assertEquals(blockId, level2.getEntry(0));
+        assertEquals(blockId, level2.getEntry(LEVEL_SIZE * LEVEL_SIZE - 1));
         assertEquals(LEVEL_SIZE * LEVEL_SIZE + 1, level2p.size());
-        assertEquals(blockId, level2p.getEntry(reader, 0));
-        assertEquals(blockId, level2p.getEntry(reader, LEVEL_SIZE * LEVEL_SIZE));
+        assertEquals(blockId, level2p.getEntry(0));
+        assertEquals(blockId, level2p.getEntry(LEVEL_SIZE * LEVEL_SIZE));
     }
 
     private ListRecord writeList(int size, RecordId id) {



Mime
View raw message