jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1514191 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: SegmentNodeState.java SegmentNodeStore.java
Date Thu, 15 Aug 2013 07:55:12 GMT
Author: jukka
Date: Thu Aug 15 07:55:12 2013
New Revision: 1514191

URL: http://svn.apache.org/r1514191
Log:
OAK-659: Move purge logic for transient changes below the NodeBuilder interface

Implement SegmentNodeStore.rebase()

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/SegmentNodeStore.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=1514191&r1=1514190&r2=1514191&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
Thu Aug 15 07:55:12 2013
@@ -33,6 +33,13 @@ import org.apache.jackrabbit.oak.spi.sta
 
 public class SegmentNodeState extends AbstractNodeState {
 
+    static boolean fastEquals(NodeState a, NodeState b) {
+        return a instanceof SegmentNodeState
+                && b instanceof SegmentNodeState
+                && ((SegmentNodeState) a).recordId.equals(
+                        ((SegmentNodeState) b).recordId);
+    }
+
     private final SegmentStore store;
 
     private final RecordId recordId;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1514191&r1=1514190&r2=1514191&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Thu Aug 15 07:55:12 2013
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.Observer;
 import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStore;
+import org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -83,12 +84,20 @@ public class SegmentNodeStore extends Ab
         return super.merge(builder, commitHook, committed);    // TODO implement merge
     }
 
-    @Override
+    @Override @Nonnull
     public NodeState rebase(@Nonnull NodeBuilder builder) {
-        return super.rebase(builder);    // TODO implement rebase
+        NodeState oldBase = builder.getBaseState();
+        NodeState newBase = getRoot();
+        if (!SegmentNodeState.fastEquals(oldBase, newBase)) {
+            NodeBuilder newBuilder = newBase.builder();
+            builder.getNodeState().compareAgainstBaseState(
+                    oldBase, new ConflictAnnotatingRebaseDiff(newBuilder));
+            builder.reset(newBuilder.getNodeState());
+        }
+        return builder.getNodeState();
     }
 
-    @Override
+    @Override @Nonnull
     public NodeState reset(@Nonnull NodeBuilder builder) {
         NodeState state = getRoot();
         checkNotNull(builder).reset(state);



Mime
View raw message