jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1416572 - /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesActionNew.java
Date Mon, 03 Dec 2012 16:09:42 GMT
Author: meteatamel
Date: Mon Dec  3 16:09:41 2012
New Revision: 1416572

URL: http://svn.apache.org/viewvc?rev=1416572&view=rev
Log:
OAK-489 - FetchNodesAction need to limit the versions of a node

FetchNodesAction now limits the versions of a node, at least when depth is zero.

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesActionNew.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesActionNew.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesActionNew.java?rev=1416572&r1=1416571&r2=1416572&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesActionNew.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesActionNew.java
Mon Dec  3 16:09:41 2012
@@ -165,20 +165,27 @@ public class FetchNodesActionNew extends
     }
 
     private Map<String, MongoNode> getMostRecentValidNodes(DBCursor dbCursor) {
-        Map<String, MongoNode> nodeMongos = new HashMap<String, MongoNode>();
+        int numberOfNodesToFetch = -1;
+        if (paths.size() > 1) {
+            numberOfNodesToFetch = paths.size();
+        } else if (depth == 0) {
+            numberOfNodesToFetch = 1;
+        }
+
+        Map<String, MongoNode> nodes = new HashMap<String, MongoNode>();
         Map<Long, MongoCommit> commits = new HashMap<Long, MongoCommit>();
 
-        while (dbCursor.hasNext()) {
-            MongoNode nodeMongo = (MongoNode) dbCursor.next();
-            String path = nodeMongo.getPath();
+        while (dbCursor.hasNext() && (numberOfNodesToFetch == -1 || nodes.size()
< numberOfNodesToFetch)) {
+            MongoNode node = (MongoNode)dbCursor.next();
+            String path = node.getPath();
             // Assuming that revision ids are ordered and nodes are fetched in
             // sorted order, first check if the path is already in the map.
-            if (nodeMongos.containsKey(path)) {
+            if (nodes.containsKey(path)) {
                 LOG.debug("Converted nodes @{} with path {} was not put into map"
                         + " because a newer version is available", revisionId, path);
                 continue;
             } else {
-                long revisionId = nodeMongo.getRevisionId();
+                long revisionId = node.getRevisionId();
                 LOG.debug("Converting node {} ({})", path, revisionId);
 
                 if (!commits.containsKey(revisionId)) {
@@ -193,7 +200,7 @@ public class FetchNodesActionNew extends
                         continue;
                     }
                 }
-                nodeMongos.put(path, nodeMongo);
+                nodes.put(path, node);
                 LOG.debug("Converted node @{} with path {} was put into map", revisionId,
path);
             }
 
@@ -217,6 +224,6 @@ public class FetchNodesActionNew extends
             */
         }
         dbCursor.close();
-        return nodeMongos;
+        return nodes;
     }
 }
\ No newline at end of file



Mime
View raw message