jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1547665 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Date Wed, 04 Dec 2013 01:08:05 GMT
Author: jukka
Date: Wed Dec  4 01:08:05 2013
New Revision: 1547665

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

Simplify the rebase/reset logic

Modified:
    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/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=1547665&r1=1547664&r2=1547665&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
Wed Dec  4 01:08:05 2013
@@ -143,22 +143,33 @@ public class SegmentNodeStore implements
     @Override @Nonnull
     public NodeState rebase(@Nonnull NodeBuilder builder) {
         checkArgument(builder instanceof SegmentNodeBuilder);
-        NodeState newBase = getRoot();
-        NodeState oldBase = builder.getBaseState();
-        if (!fastEquals(oldBase, newBase)) {
-            NodeState head = builder.getNodeState();
-            ((SegmentNodeBuilder) builder).reset(newBase);
-            head.compareAgainstBaseState(oldBase, new ConflictAnnotatingRebaseDiff(builder));
+
+        SegmentNodeBuilder snb = (SegmentNodeBuilder) builder;
+        checkArgument(store == snb.getBaseState().getStore());
+
+        NodeState root = getRoot();
+        SegmentNodeState before = snb.getBaseState();
+        if (!fastEquals(before, root)) {
+            SegmentNodeState after = snb.getNodeState();
+            snb.reset(root);
+            after.compareAgainstBaseState(
+                    before, new ConflictAnnotatingRebaseDiff(snb));
         }
-        return builder.getNodeState();
+
+        return snb.getNodeState();
     }
 
     @Override @Nonnull
     public NodeState reset(@Nonnull NodeBuilder builder) {
         checkArgument(builder instanceof SegmentNodeBuilder);
-        NodeState state = getRoot();
-        ((SegmentNodeBuilder) builder).reset(state);
-        return state;
+
+        SegmentNodeBuilder snb = (SegmentNodeBuilder) builder;
+        checkArgument(store == snb.getBaseState().getStore());
+
+        NodeState root = getRoot();
+        snb.reset(root);
+
+        return root;
     }
 
     @Override



Mime
View raw message