jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1363996 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/TreeImpl.java plugins/memory/MemoryNodeStateBuilder.java spi/state/NodeStateBuilder.java
Date Fri, 20 Jul 2012 22:33:55 GMT
Author: jukka
Date: Fri Jul 20 22:33:55 2012
New Revision: 1363996

URL: http://svn.apache.org/viewvc?rev=1363996&view=rev
Log:
OAK-175: MemoryNodeStateBuilder inefficient for large child node lists

Make the current child node count accessible through NodeStateBuilder

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1363996&r1=1363995&r2=1363996&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Fri Jul 20 22:33:55 2012
@@ -218,7 +218,7 @@ public class TreeImpl implements Tree, P
 
     @Override
     public long getChildrenCount() {
-        return getNodeState().getChildNodeCount();
+        return getNodeStateBuilder().getChildNodeCount();
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java?rev=1363996&r1=1363995&r2=1363996&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStateBuilder.java
Fri Jul 20 22:33:55 2012
@@ -25,10 +25,8 @@ import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -106,6 +104,21 @@ public class MemoryNodeStateBuilder impl
     }
 
     @Override
+    public long getChildNodeCount() {
+        long count = base.getChildNodeCount();
+        for (Map.Entry<String, NodeStateBuilder> entry : builders.entrySet()) {
+            NodeState before = base.getChildNode(entry.getKey());
+            NodeStateBuilder after = entry.getValue();
+            if (before == null && after != null) {
+                count++;
+            } else if (before != null && after == null) {
+                count--;
+            }
+        }
+        return count;
+    }
+
+    @Override
     public void setNode(String name, NodeState nodeState) {
         if (nodeState == null) {
             removeNode(name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateBuilder.java?rev=1363996&r1=1363995&r2=1363996&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateBuilder.java
Fri Jul 20 22:33:55 2012
@@ -38,6 +38,13 @@ public interface NodeStateBuilder {
     NodeState getNodeState();
 
     /**
+     * Returns the current number of child nodes.
+     *
+     * @return number of child nodes
+     */
+    long getChildNodeCount();
+
+    /**
      * Add a sub-tree
      *
      * @param name  name child node containing the sub-tree



Mime
View raw message