Author: mreutegg
Date: Wed Sep 18 15:16:07 2013
New Revision: 1524447
URL: http://svn.apache.org/r1524447
Log:
OAK-1023: Optimize many child nodes access
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=1524447&r1=1524446&r2=1524447&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 15:16:07 2013
@@ -571,7 +571,9 @@ public class MongoMK implements MicroKer
// as the starting point
Iterable<NodeDocument> docs;
Children c = new Children();
- int rawLimit = limit;
+ // retrieve one more than requested to check if there
+ // are potentially more than 'limit' nodes
+ int rawLimit = (int) Math.min(((long) limit) + 1, Integer.MAX_VALUE);
Set<Revision> validRevisions = new HashSet<Revision>();
do {
c.children.clear();
@@ -857,18 +859,13 @@ public class MongoMK implements MicroKer
n.append(json, includeId);
int max;
if (maxChildNodes == -1) {
- max = MANY_CHILDREN_THRESHOLD;
+ max = Integer.MAX_VALUE;
maxChildNodes = Integer.MAX_VALUE;
} else {
// use long to avoid overflows
- long m = maxChildNodes + 1L + offset;
+ long m = ((long) maxChildNodes) + 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++) {
if (maxChildNodes-- <= 0) {