jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1294577 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk: simple/NodeImpl.java util/Sync.java
Date Tue, 28 Feb 2012 11:02:33 GMT
Author: thomasm
Date: Tue Feb 28 11:02:32 2012
New Revision: 1294577

URL: http://svn.apache.org/viewvc?rev=1294577&view=rev
Log:
Add Node.getChildNodeCount() / getTotalChildNodeCount()

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/Sync.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java?rev=1294577&r1=1294576&r2=1294577&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
Tue Feb 28 11:02:32 2012
@@ -95,7 +95,7 @@ public class NodeImpl implements Cache.V
     private int memory;
     private long descendantCount;
     private int descendantInlineCount;
-    private boolean hasMoreChildNodes;
+    private long totalChildNodeCount;
     private byte[] hash;
     private String nodeVersion;
 
@@ -458,20 +458,17 @@ public class NodeImpl implements Cache.V
             node.setPath(path);
         }
         if (!t.matches('}')) {
-            long parsedChildCount = 0;
-            int parsedChildren = 0;
             do {
                 String key = t.readString();
                 t.read(':');
                 if (t.matches('{')) {
                     String childPath = path == null || key == null ? null : PathUtils.concat(path,
key);
                     node.addChildNode(key, false, null, parse(map, t, revId, childPath));
-                    parsedChildren++;
                 } else {
                     String value = t.readRawValue().trim();
                     if (key.length() > 0 && key.charAt(0) == ':') {
                         if (key.equals(CHILREN_COUNT)) {
-                            parsedChildCount = Long.parseLong(value);
+                            node.totalChildNodeCount = Long.parseLong(value);
                         } else if (key.equals(HASH)) {
                             value = JsopTokenizer.decodeQuoted(value);
                             node.hash = StringUtils.convertHexToBytes(value);
@@ -489,9 +486,6 @@ public class NodeImpl implements Cache.V
                 }
             } while (t.matches(','));
             t.read('}');
-            if (parsedChildCount > 0 && parsedChildren < parsedChildCount)
{
-                node.hasMoreChildNodes = true;
-            }
         }
         return node;
     }
@@ -734,8 +728,12 @@ public class NodeImpl implements Cache.V
         return false;
     }
 
-    public boolean hasMoreChildNodes() {
-        return hasMoreChildNodes;
+    public long getTotalChildNodeCount() {
+        return totalChildNodeCount;
+    }
+
+    public long getChildNodeCount() {
+        return childNodes == null ? 0 : childNodes.size();
     }
 
     public String getNodeVersion() {

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/Sync.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/Sync.java?rev=1294577&r1=1294576&r2=1294577&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/Sync.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/Sync.java Tue
Feb 28 11:02:32 2012
@@ -148,7 +148,7 @@ public class Sync {
             }
         }
         // child nodes
-        Iterator<String> it = s.hasMoreChildNodes() ?
+        Iterator<String> it = s.getTotalChildNodeCount() > s.getChildNodeCount()
?
                 getAllChildNodeNames(sourceMk, source, sourceRev, childNodesPerBatch) :
                 s.getChildNodeNames(Integer.MAX_VALUE);
         while (it.hasNext()) {
@@ -156,14 +156,15 @@ public class Sync {
             visit(PathUtils.concat(relPath, name));
         }
         if (t != null) {
-            it = t.hasMoreChildNodes() ?
+            it = t.getTotalChildNodeCount() > t.getChildNodeCount() ?
                     getAllChildNodeNames(targetMk, target, targetRev, childNodesPerBatch)
:
                     t.getChildNodeNames(Integer.MAX_VALUE);
             while (it.hasNext()) {
                 String name = it.next();
                 if (s.exists(name)) {
                     // if it exists in the source, it's already updated
-                } else if (s.hasMoreChildNodes() && sourceMk.nodeExists(PathUtils.concat(source,
name), sourceRev)) {
+                } else if (s.getTotalChildNodeCount() > s.getChildNodeCount() &&
+                        sourceMk.nodeExists(PathUtils.concat(source, name), sourceRev)) {
                     // if it exists in the source, it's already updated
                     // (in this case, there are many child nodes)
                 } else {



Mime
View raw message