jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1498418 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/mongomk/ test/java/org/apache/jackrabbit/oak/plugins/mongomk/
Date Mon, 01 Jul 2013 12:52:06 GMT
Author: thomasm
Date: Mon Jul  1 12:52:06 2013
New Revision: 1498418

URL: http://svn.apache.org/r1498418
Log:
OAK-885 Skinny MongoMK Children objects (including changed memory calculation)

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/MeasureMemory.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=1498418&r1=1498417&r2=1498418&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
Mon Jul  1 12:52:06 2013
@@ -631,7 +631,7 @@ public class MongoMK implements MicroKer
         String to = Utils.getKeyUpperLimit(path);
         List<Map<String, Object>> list = store.query(DocumentStore.Collection.NODES,

                 from, to, limit);
-        Children c = new Children(path, rev);
+        Children c = new Children();
         Set<Revision> validRevisions = new HashSet<Revision>();
         if (list.size() >= limit) {
             c.hasMore = true;
@@ -841,7 +841,7 @@ public class MongoMK implements MicroKer
         fromChildren = getChildren(path, fromRev, max);
         toChildren = getChildren(path, toRev, max);
         if (!fromChildren.hasMore && !toChildren.hasMore) {
-            diffFewChildren(w, fromChildren, toChildren);
+            diffFewChildren(w, fromChildren, fromRev, toChildren, toRev);
         } else {
             if (FAST_DIFF) {
                 diffManyChildren(w, path, fromRev, toRev);
@@ -849,7 +849,7 @@ public class MongoMK implements MicroKer
                 max = Integer.MAX_VALUE;
                 fromChildren = getChildren(path, fromRev, max);
                 toChildren = getChildren(path, toRev, max);
-                diffFewChildren(w, fromChildren, toChildren);
+                diffFewChildren(w, fromChildren, fromRev, toChildren, toRev);
             }
         }
         return w.toString();
@@ -891,14 +891,14 @@ public class MongoMK implements MicroKer
         }
     }
     
-    private void diffFewChildren(JsopWriter w, Children fromChildren, Children toChildren)
{
+    private void diffFewChildren(JsopWriter w, Children fromChildren, Revision fromRev, Children
toChildren, Revision toRev) {
         Set<String> childrenSet = new HashSet<String>(toChildren.children);
         for (String n : fromChildren.children) {
             if (!childrenSet.contains(n)) {
                 w.tag('-').value(n).newline();
             } else {
-                Node n1 = getNode(n, fromChildren.rev);
-                Node n2 = getNode(n, toChildren.rev);
+                Node n1 = getNode(n, fromRev);
+                Node n2 = getNode(n, toRev);
                 // this is not fully correct:
                 // a change is detected if the node changed recently,
                 // even if the revisions are well in the past
@@ -1520,7 +1520,7 @@ public class MongoMK implements MicroKer
         Children c = nodeChildrenCache.getIfPresent(path + "@" + rev);
         if (isNew || (!isDelete && c != null)) {
             String key = path + "@" + rev;
-            Children c2 = new Children(path, rev);
+            Children c2 = new Children();
             TreeSet<String> set = new TreeSet<String>();
             if (c != null) {
                 set.addAll(c.children);

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=1498418&r1=1498417&r2=1498418&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
Mon Jul  1 12:52:06 2013
@@ -115,29 +115,22 @@ public class Node {
      * A list of children for a node.
      */
     static class Children {
-        
-        final String path;
-        final Revision rev;
+
         final ArrayList<String> children = new ArrayList<String>();
         boolean hasMore;
         long offset;
-        
-        Children(String path, Revision rev) {
-            this.path = path;
-            this.rev = rev;
-        }
 
         public int getMemory() {
-            int size = 200 + path.length() * 2;
+            int size = 114;
             for (String c : children) {
-                size += c.length() * 2 + 40;
+                size += c.length() * 2 + 56;
             }
             return size;
         }
-        
+
         @Override
         public String toString() {
-            return path + ": " + children.toString();
+            return children.toString();
         }
         
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MeasureMemory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MeasureMemory.java?rev=1498418&r1=1498417&r2=1498418&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MeasureMemory.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MeasureMemory.java
Mon Jul  1 12:52:06 2013
@@ -89,13 +89,24 @@ public class MeasureMemory {
             }
         });
     }
+    
+    @Test
+    public void nodeChildManyChildren() throws Exception {
+        measureMemory(new Callable<Object[]>() {
+            @Override
+            public Object[] call() {
+                Children n = generateNodeChild(100);
+                return new Object[]{n, n.getMemory() + OVERHEAD};
+            }
+        });
+    }
 
     @Test
     public void nodeChild() throws Exception {
         measureMemory(new Callable<Object[]>() {
             @Override
             public Object[] call() {
-                Children n = generateNodeChild(15);
+                Children n = generateNodeChild(5);
                 return new Object[]{n, n.getMemory() + OVERHEAD};
             }
         });
@@ -106,7 +117,7 @@ public class MeasureMemory {
         measureMemory(new Callable<Object[]>() {
             @Override
             public Object[] call() {
-                Children n = generateNodeChild(15);
+                Children n = generateNodeChild(0);
                 return new Object[]{n, n.getMemory() + OVERHEAD};
             }
         });
@@ -157,7 +168,7 @@ public class MeasureMemory {
     }
 
     static Children generateNodeChild(int childCount) {
-        Children n = new Children(new String("_id"), new Revision(1, 2, 3));
+        Children n = new Children();
         for (int i = 0; i < childCount; i++) {
             n.children.add("child" + i);
         }



Mime
View raw message