jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1504116 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java
Date Wed, 17 Jul 2013 13:19:23 GMT
Author: jukka
Date: Wed Jul 17 13:19:23 2013
New Revision: 1504116

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

Add special cases for many-to-none and many-to-one comparisons

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java?rev=1504116&r1=1504115&r2=1504116&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Template.java
Wed Jul 17 13:19:23 2013
@@ -485,6 +485,36 @@ public class Template {
                     }
                 }
             }
+        } else if (beforeTemplate.hasNoChildNodes()) {
+            for (ChildNodeEntry entry : getChildNodeEntries(store, afterId)) {
+                if (!diff.childNodeAdded(
+                        entry.getName(), entry.getNodeState())) {
+                    return false;
+                }
+            }
+        } else if (beforeTemplate.hasOneChildNode()) {
+            String name = beforeTemplate.getChildName();
+            for (ChildNodeEntry entry : getChildNodeEntries(store, afterId)) {
+                String childName = entry.getName();
+                NodeState afterChild = entry.getNodeState();
+                if (name.equals(childName)) {
+                    NodeState beforeChild =
+                            beforeTemplate.getChildNode(name, store, beforeId);
+                    if (beforeChild.exists()) {
+                        if (!afterChild.equals(beforeChild)
+                                && !diff.childNodeChanged(
+                                        childName, beforeChild, afterChild)) {
+                            return false;
+                        }
+                    } else {
+                        if (!diff.childNodeAdded(childName, afterChild)) {
+                            return false;
+                        }
+                    }
+                } else if (!diff.childNodeAdded(childName, afterChild)) {
+                    return false;
+                }
+            }
         } else {
             // TODO: Leverage the HAMT data structure for the comparison
             Set<String> baseChildNodes = new HashSet<String>();
@@ -499,7 +529,7 @@ public class Template {
                     }
                 } else {
                     baseChildNodes.add(name);
-                    if (!beforeChild.equals(afterChild)) {
+                    if (!afterChild.equals(beforeChild)) {
                         if (!diff.childNodeChanged(name, beforeChild, afterChild)) {
                             return false;
                         }



Mime
View raw message