jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1490256 - in /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk: MongoMK.java Node.java
Date Thu, 06 Jun 2013 12:36:35 GMT
Author: thomasm
Date: Thu Jun  6 12:36:35 2013
New Revision: 1490256

URL: http://svn.apache.org/r1490256
Log:
OAK-857 MongoMK: support for many child nodes (bugfix)

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

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java?rev=1490256&r1=1490255&r2=1490256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoMK.java
Thu Jun  6 12:36:35 2013
@@ -623,6 +623,9 @@ public class MongoMK implements MicroKer
     }
     
     Node.Children readChildren(String path, Revision rev, int limit) {
+        // TODO use offset, to avoid O(n^2) and running out of memory
+        // to do that, use the *name* of the last entry of the previous batch of children
+        // as the starting point
         String from = getPathLowerLimit(path);
         String to = getPathUpperLimit(path);
         List<Map<String, Object>> list = store.query(DocumentStore.Collection.NODES,

@@ -934,8 +937,14 @@ public class MongoMK implements MicroKer
             max = MANY_CHILDREN_THRESHOLD;
             maxChildNodes = Integer.MAX_VALUE;
         } else {
-            // avoid overflow (if maxChildNodes is Integer.MAX_VALUE)
-            max = Math.max(maxChildNodes, maxChildNodes + 1);
+            // use long to avoid overflows
+            long m = maxChildNodes + 1L + offset;
+            max = (int) Math.min(m, Integer.MAX_VALUE);
+        }
+        if (offset > 0) {
+            // TODO workaround for missing offset 
+            // support in getChildren
+            max = Integer.MAX_VALUE;
         }
         Children c = getChildren(path, rev, max);
         for (long i = offset; i < c.children.size(); i++) {
@@ -1122,8 +1131,7 @@ public class MongoMK implements MicroKer
             nodeCache.invalidate(path + "@" + rev);
             
             if (n != null) {
-                Node.Children c = getChildren(path, rev,
-                        Integer.MAX_VALUE);
+                Node.Children c = getChildren(path, rev, Integer.MAX_VALUE);
                 for (String childPath : c.children) {
                     markAsDeleted(childPath, commit, true);
                 }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java?rev=1490256&r1=1490255&r2=1490256&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/Node.java
Thu Jun  6 12:36:35 2013
@@ -118,10 +118,9 @@ public class Node {
         
         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;



Mime
View raw message