jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1453786 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: MemoryJournal.java MergeDiff.java
Date Thu, 07 Mar 2013 11:48:14 GMT
Author: jukka
Date: Thu Mar  7 11:48:14 2013
New Revision: 1453786

URL: http://svn.apache.org/r1453786
Log:
OAK-633: SegmentMK: Hierarchy of journals

Use a more aggressive merge strategy to prevent conflict markers from showing up

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryJournal.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryJournal.java?rev=1453786&r1=1453785&r2=1453786&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryJournal.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryJournal.java
Thu Mar  7 11:48:14 2013
@@ -20,7 +20,6 @@ import static com.google.common.base.Pre
 
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.RebaseDiff;
 
 final class MemoryJournal implements Journal {
 
@@ -77,8 +76,7 @@ final class MemoryJournal implements Jou
                 RecordId newBase = parent.getHead();
                 NodeBuilder builder =
                         new SegmentNodeState(store, newBase).builder();
-                after.compareAgainstBaseState(
-                        before, new RebaseDiff(builder));
+                after.compareAgainstBaseState(before, new MergeDiff(builder));
                 NodeState state = builder.getNodeState();
                 RecordId newHead = writer.writeNode(state).getRecordId();
                 writer.flush();

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java?rev=1453786&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
Thu Mar  7 11:48:14 2013
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.segment;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
+
+class MergeDiff implements NodeStateDiff {
+
+    private final NodeBuilder builder;
+
+    public MergeDiff(NodeBuilder builder) {
+        this.builder = builder;
+    }
+
+    @Override
+    public void propertyAdded(PropertyState after) {
+        PropertyState other = builder.getProperty(after.getName());
+        if (other == null) {
+            builder.setProperty(after);
+        }
+    }
+
+    @Override
+    public void propertyChanged(PropertyState before, PropertyState after) {
+        PropertyState other = builder.getProperty(before.getName());
+        if (other != null && other.equals(before)) {
+            builder.setProperty(after);
+        }
+    }
+
+    @Override
+    public void propertyDeleted(PropertyState before) {
+        PropertyState other = builder.getProperty(before.getName());
+        if (other != null && other.equals(before)) {
+            builder.removeProperty(before.getName());
+        }
+    }
+
+    @Override
+    public void childNodeAdded(String name, NodeState after) {
+        if (!builder.hasChildNode(name)) {
+            builder.setNode(name, after);
+        }
+    }
+
+    @Override
+    public void childNodeChanged(
+            String name, NodeState before, NodeState after) {
+        if (builder.hasChildNode(name)) {
+            after.compareAgainstBaseState(
+                    before, new MergeDiff(builder.child(name)));
+        }
+    }
+
+    @Override
+    public void childNodeDeleted(String name, NodeState before) {
+        if (builder.hasChildNode(name)
+                && before.equals(builder.child(name).getNodeState())) {
+            builder.removeNode(name);
+        }
+    }
+
+}



Mime
View raw message