jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1501680 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/mongomk/ test/java/org/apache/jackrabbit/oak/plugins/mongomk/
Date Wed, 10 Jul 2013 09:02:25 GMT
Author: mreutegg
Date: Wed Jul 10 09:02:24 2013
New Revision: 1501680

URL: http://svn.apache.org/r1501680
Log:
OAK-619 Lock-free MongoMK implementation
- Extend diff test and fix minor issue with many child nodes

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKDiffTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1501680&r1=1501679&r2=1501680&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Wed Jul 10 09:02:24 2013
@@ -895,23 +895,25 @@ public class MongoMK implements MicroKer
         List<Map<String, Object>> list = store.query(DocumentStore.Collection.NODES,
fromKey, toKey, 
                 UpdateOp.MODIFIED, minValue, Integer.MAX_VALUE);
         for (Map<String, Object> e : list) {
-            if (isOlder(e, rev)) {
-                continue;
-            }
             String id = e.get(UpdateOp.ID).toString();
             String p = Utils.getPathFromId(id);
-            if (getNode(p, fromRev) != null) {
+            Node fromNode = getNode(p, fromRev);
+            Node toNode = getNode(p, toRev);
+            if (fromNode != null) {
                 // exists in fromRev
-                if (getNode(p, toRev) != null) {
+                if (toNode != null) {
                     // exists in both revisions
-                    w.tag('^').key(p).object().endObject().newline();
+                    // check if different
+                    if (!fromNode.getLastRevision().equals(toNode.getLastRevision())) {
+                        w.tag('^').key(p).object().endObject().newline();
+                    }
                 } else {
                     // does not exist in toRev -> was removed
                     w.tag('-').value(p).newline();
                 }
             } else {
                 // does not exist in fromRev
-                if (getNode(p, toRev) != null) {
+                if (toNode != null) {
                     // exists in toRev
                     w.tag('+').key(p).object().endObject().newline();
                 } else {
@@ -1276,34 +1278,6 @@ public class MongoMK implements MicroKer
         return liveRev;
     }
     
-    boolean isOlder(Map<String, Object> map, Revision rev) {
-        Revision revision;
-        for (String key : map.keySet()) {
-            if (!Utils.isPropertyName(key)) {
-                if (key.equals(UpdateOp.ID)) {
-                    continue;
-                } else if (key.equals(UpdateOp.LAST_REV)) {
-                    // TODO could use just this property? it would be faster
-                    continue;
-                } else if (key.equals(UpdateOp.PREVIOUS)) {
-                    continue;
-                } else if (key.equals(UpdateOp.MODIFIED)) {
-                    continue;
-                }                    
-            }
-            Object v = map.get(key);
-            @SuppressWarnings("unchecked")
-            Map<String, String> valueMap = (Map<String, String>) v;
-            for (String r : valueMap.keySet()) {
-                revision = Revision.fromString(r);
-                if (!isRevisionNewer(rev, revision)) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-    
     /**
      * Get the revision of the latest change made to this node.
      * 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java?rev=1501680&r1=1501679&r2=1501680&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Node.java
Wed Jul 10 09:02:24 2013
@@ -102,6 +102,10 @@ public class Node implements CacheValue 
     public void setLastRevision(Revision lastRevision) {
         this.lastRevision = lastRevision;
     }
+
+    public Revision getLastRevision() {
+        return lastRevision;
+    }
     
     @Override
     public int getMemory() {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKDiffTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKDiffTest.java?rev=1501680&r1=1501679&r2=1501680&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKDiffTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKDiffTest.java
Wed Jul 10 09:02:24 2013
@@ -249,6 +249,15 @@ public class MongoMKDiffTest extends Abs
 
     @Test
     public void diffManyChildren() {
+        diffManyChildren(false);
+    }
+
+    @Test
+    public void diffManyChildrenOnBranch() {
+        diffManyChildren(true);
+    }
+
+    private void diffManyChildren(boolean onBranch) {
         String baseRev = mk.getHeadRevision();
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < MongoMK.MANY_CHILDREN_THRESHOLD * 2; i++) {
@@ -263,5 +272,28 @@ public class MongoMKDiffTest extends Abs
         for (int i = 0; i < MongoMK.MANY_CHILDREN_THRESHOLD * 2; i++) {
             assertTrue(jsop.contains("-\"/node-" + i + "\""));
         }
+
+        if (onBranch) {
+            rev = mk.branch(rev);
+        }
+        String rev2 = mk.commit("/", "+\"node-new\":{}", rev, null);
+        jsop = mk.diff(rev, rev2, "/", 0);
+        assertTrue(jsop.contains("+\"/node-new\""));
+
+        String rev3 = mk.commit("/", "^\"node-new/prop\":\"value\"", rev2, null);
+        jsop = mk.diff(rev2, rev3, "/", 0);
+        assertTrue(jsop.contains("^\"/node-new\""));
+
+        String rev4 = mk.commit("/", "+\"node-new/foo\":{}", rev3, null);
+        jsop = mk.diff(rev3, rev4, "/", 0);
+        assertTrue(jsop.contains("^\"/node-new\""));
+
+        String rev5 = mk.commit("/", "^\"node-new/foo/prop\":\"value\"", rev4, null);
+        jsop = mk.diff(rev4, rev5, "/", 0);
+        assertTrue(jsop.contains("^\"/node-new\""));
+
+        String rev6 = mk.commit("/", "-\"node-new/foo\"", rev5, null);
+        jsop = mk.diff(rev5, rev6, "/", 0);
+        assertTrue(jsop.contains("^\"/node-new\""));
     }
 }
\ No newline at end of file



Mime
View raw message