jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1453556 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/segment/ test/java/org/apache/jackrabbit/oak/plugins/segment/
Date Wed, 06 Mar 2013 21:00:15 GMT
Author: jukka
Date: Wed Mar  6 21:00:15 2013
New Revision: 1453556

URL: http://svn.apache.org/r1453556
Log:
OAK-593: Segment-based MK

Avoid rewriting templates if there are no changes to node structure

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.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/SegmentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java?rev=1453556&r1=1453555&r2=1453556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
Wed Mar  6 21:00:15 2013
@@ -35,6 +35,8 @@ class SegmentNodeState extends AbstractN
 
     private final RecordId recordId;
 
+    private RecordId templateId = null;
+
     private Template template = null;
 
     SegmentNodeState(SegmentStore store, RecordId id) {
@@ -46,10 +48,15 @@ class SegmentNodeState extends AbstractN
         return recordId;
     }
 
-    private synchronized Template getTemplate() {
+    RecordId getTemplateId() {
+        getTemplate(); // force loading of the template
+        return templateId;
+    }
+
+    synchronized Template getTemplate() {
         if (template == null) {
             Segment segment = store.readSegment(recordId.getSegmentId());
-            RecordId templateId = segment.readRecordId(recordId.getOffset());
+            templateId = segment.readRecordId(recordId.getOffset());
             template = segment.readTemplate(templateId);
         }
         return template;

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=1453556&r1=1453555&r2=1453556&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
Wed Mar  6 21:00:15 2013
@@ -642,9 +642,15 @@ public class SegmentWriter {
         }
 
         Template template = new Template(state);
+        RecordId templateId;
+        if (before != null && template.equals(before.getTemplate())) {
+            templateId = before.getTemplateId();
+        } else {
+            templateId = writeTemplate(template);
+        }
 
         List<RecordId> ids = Lists.newArrayList();
-        ids.add(writeTemplate(template));
+        ids.add(templateId);
 
         if (template.hasManyChildNodes()) {
             MapRecord base;

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=1453556&r1=1453555&r2=1453556&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
Wed Mar  6 21:00:15 2013
@@ -162,7 +162,7 @@ public class SegmentSizeTest {
         state = writer.writeNode(builder.getNodeState());
         writer.flush();
         segment = store.readSegment(state.getRecordId().getSegmentId());
-        assertEquals(260, segment.getData().length);
+        assertEquals(256, segment.getData().length);
     }
 
     private int getSize(NodeBuilder builder) {



Mime
View raw message