jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1524397 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Date Wed, 18 Sep 2013 13:11:40 GMT
Author: mreutegg
Date: Wed Sep 18 13:11:40 2013
New Revision: 1524397

URL: http://svn.apache.org/r1524397
Log:
OAK-926: MongoMK: split documents when they are too large
- Maintain children cache entry when incomplete

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.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=1524397&r1=1524396&r2=1524397&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 Sep 18 13:11:40 2013
@@ -1308,17 +1308,32 @@ public class MongoMK implements MicroKer
         if (!added.isEmpty()) {
             NodeDocument.Children docChildren = docChildrenCache.getIfPresent(path);
             if (docChildren != null) {
-                if (docChildren.isComplete) {
-                    TreeSet<String> names = new TreeSet<String>(docChildren.childNames);
+                int currentSize = docChildren.childNames.size();
+                TreeSet<String> names = new TreeSet<String>(docChildren.childNames);
+                // incomplete cache entries must not be updated with
+                // names at the end of the list because there might be
+                // a next name in MongoDB smaller than the one added
+                if (!docChildren.isComplete) {
+                    for (String childPath : added) {
+                        String name = PathUtils.getName(childPath);
+                        if (names.higher(name) != null) {
+                            names.add(name);
+                        }
+                    }
+                } else {
+                    // add all
                     for (String childPath : added) {
                         names.add(PathUtils.getName(childPath));
                     }
+                }
+                // any changes?
+                if (names.size() != currentSize) {
+                    // create new cache entry with updated names
+                    boolean complete = docChildren.isComplete;
                     docChildren = new NodeDocument.Children();
-                    docChildren.isComplete = true;
+                    docChildren.isComplete = complete;
                     docChildren.childNames.addAll(names);
                     docChildrenCache.put(path, docChildren);
-                } else {
-                    docChildrenCache.invalidate(path);
                 }
             }
         }



Mime
View raw message