jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1526253 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: MapRecord.java Record.java
Date Wed, 25 Sep 2013 18:23:05 GMT
Author: jukka
Date: Wed Sep 25 18:23:05 2013
New Revision: 1526253

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

Improve the Record base class in preparation for broader changes.

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/Record.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=1526253&r1=1526252&r2=1526253&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
Wed Sep 25 18:23:05 2013
@@ -97,10 +97,6 @@ abstract class MapRecord extends Record 
         return store.readSegment(uuid);
     }
 
-    protected int getOffset() {
-        return getRecordId().getOffset();
-    }
-
     int size() {
         return size;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Record.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Record.java?rev=1526253&r1=1526252&r2=1526253&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Record.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Record.java
Wed Sep 25 18:23:05 2013
@@ -16,16 +16,59 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+/**
+ * Record within a segment.
+ */
 class Record {
 
+    /**
+     * Identifier of this record.
+     */
     private final RecordId id;
 
     protected Record(RecordId id) {
         this.id = id;
     }
 
+    /**
+     * Returns the identifier of this record.
+     *
+     * @return record identifier
+     */
     public RecordId getRecordId() {
         return id;
     }
 
+    /**
+     * Returns the segment offset of this record.
+     *
+     * @return segment offset of this record
+     */
+    protected int getOffset() {
+        return id.getOffset();
+    }
+
+    /**
+     * Returns the segment offset of the given byte position in this record.
+     *
+     * @param position byte position within this record
+     * @return segment offset of the given byte position
+     */
+    protected int getOffset(int position) {
+        return getOffset() + position;
+    }
+
+    /**
+     * Returns the segment offset of a byte position in this record.
+     * The position is calculated from the given number of raw bytes and
+     * record identifiers.
+     *
+     * @param bytes number of raw bytes before the position
+     * @param ids number of record identifiers before the position
+     * @return segment offset of the specified byte position
+     */
+    protected int getOffset(int bytes, int ids) {
+        return getOffset(bytes + ids * Segment.RECORD_ID_BYTES);
+    }
+
 }



Mime
View raw message