jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1525154 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Date Fri, 20 Sep 2013 22:12:06 GMT
Author: jukka
Date: Fri Sep 20 22:12:06 2013
New Revision: 1525154

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

Basic implementation of SegmentNodeStore.merge()

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=1525154&r1=1525153&r2=1525154&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
Fri Sep 20 22:12:06 2013
@@ -80,14 +80,28 @@ public class SegmentNodeStore extends Ab
     }
 
     @Override
-    public synchronized NodeState merge(@Nonnull NodeBuilder builder, @Nonnull CommitHook
commitHook, PostCommitHook committed) throws CommitFailedException {
-        return super.merge(builder, commitHook, committed);    // TODO implement merge
+    public synchronized NodeState merge(
+            @Nonnull NodeBuilder builder,
+            @Nonnull CommitHook commitHook, PostCommitHook committed)
+            throws CommitFailedException {
+        checkNotNull(commitHook);
+        SegmentNodeState head = getHead();
+        rebase(builder, head.getChildNode(ROOT)); // TODO: can we avoid this?
+        SegmentNodeStoreBranch branch = new SegmentNodeStoreBranch(
+                this, new SegmentWriter(store), head);
+        branch.setRoot(builder.getNodeState());
+        NodeState merged = branch.merge(commitHook, committed);
+        builder.reset(merged);
+        return merged;
     }
 
     @Override @Nonnull
     public NodeState rebase(@Nonnull NodeBuilder builder) {
+        return rebase(builder, getRoot());
+    }
+
+    private NodeState rebase(@Nonnull NodeBuilder builder, NodeState newBase) {
         NodeState oldBase = builder.getBaseState();
-        NodeState newBase = getRoot();
         if (!SegmentNodeState.fastEquals(oldBase, newBase)) {
             NodeState head = builder.getNodeState();
             builder.reset(newBase);



Mime
View raw message