jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1504111 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: SegmentPropertyState.java SegmentWriter.java
Date Wed, 17 Jul 2013 13:05:35 GMT
Author: jukka
Date: Wed Jul 17 13:05:35 2013
New Revision: 1504111

URL: http://svn.apache.org/r1504111
Log:
OAK-630: SegmentMK: Implement compareAgainstBaseState

Be more aggressive aobut reusing property records, so that comparisons will be quicker in
common cases

Modified:
    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/SegmentWriter.java

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=1504111&r1=1504110&r2=1504111&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
Wed Jul 17 13:05:35 2013
@@ -45,6 +45,11 @@ class SegmentPropertyState extends Abstr
         this.recordId = checkNotNull(recordId);
     }
 
+    RecordId getRecordId() {
+        return recordId;
+    }
+
+
     @Override @Nonnull
     public String getName() {
         return template.getName();

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=1504111&r1=1504110&r2=1504111&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 Jul 17 13:05:35 2013
@@ -687,8 +687,23 @@ public class SegmentWriter {
             ids.add(writeNode(state.getChildNode(template.getChildName())).getRecordId());
         }
 
-        for (PropertyTemplate property : template.getPropertyTemplates()) {
-            ids.add(writeProperty(state.getProperty(property.getName())));
+        for (PropertyTemplate pt : template.getPropertyTemplates()) {
+            RecordId propertyId = null;
+            String name = pt.getName();
+            PropertyState property = state.getProperty(name);
+            if (before != null) {
+                // reuse previously stored property record, if possible
+                PropertyState beforeProperty = before.getProperty(name);
+                if (beforeProperty instanceof SegmentPropertyState
+                        && property.equals(beforeProperty)) {
+                    propertyId = ((SegmentPropertyState) beforeProperty)
+                            .getRecordId();
+                }
+            }
+            if (propertyId == null) {
+                propertyId = writeProperty(property);
+            }
+            ids.add(propertyId);
         }
 
         RecordId recordId = prepare(0, ids);



Mime
View raw message