jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1333068 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/kernel/ main/java/org/apache/jackrabbit/oak/plugins/type/ main/java/org/apache/jackrabbit/oak/spi/state/ test/ja...
Date Wed, 02 May 2012 14:48:10 GMT
Author: mduerig
Date: Wed May  2 14:48:10 2012
New Revision: 1333068

URL: http://svn.apache.org/viewvc?rev=1333068&view=rev
Log:
OAK-81: Remove offset and count parameters from NodeState.getChildNodeEntries()

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    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/kernel/EmptyNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Wed May  2 14:48:10 2012
@@ -29,13 +29,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.PagedIterator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
@@ -210,7 +207,7 @@ public class RootImpl implements Root {
                 for (PropertyState property : state.getProperties()) {
                     setProperty(property, child);
                 }
-                for (ChildNodeEntry entry : childNodeEntries(state)) {
+                for (ChildNodeEntry entry : state.getChildNodeEntries()) {
                     addChild(entry.getName(), entry.getNodeState(), child);
                 }
             }
@@ -224,22 +221,6 @@ public class RootImpl implements Root {
                 }
             }
 
-            @SuppressWarnings("unchecked")
-            private Iterable<? extends ChildNodeEntry> childNodeEntries(final NodeState
nodeState) {
-                return new Iterable() {  // Java's type system is too weak to express the
exact type here
-                    @Override
-                    public Iterator<? extends ChildNodeEntry> iterator() {
-                        return Iterators.flatten(
-                            new PagedIterator<ChildNodeEntry>(1024) {
-                                @Override
-                                protected Iterator<? extends ChildNodeEntry> getPage(long
pos, int size) {
-                                    return nodeState.getChildNodeEntries(pos, size).iterator();
-                                }
-                            });
-                    }
-                };
-            }
-
         });
     }
 

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=1333068&r1=1333067&r2=1333068&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
Wed May  2 14:48:10 2012
@@ -28,13 +28,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.util.Function1;
 import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.PagedIterator;
 
 import java.util.Iterator;
 import java.util.List;
 
-import static org.apache.jackrabbit.oak.util.Iterators.flatten;
-
 /**
  * Implementation of tree based on {@link NodeStateBuilder}s. Each subtree
  * has an associated node state builder which is used for building the new
@@ -310,14 +307,8 @@ public class TreeImpl implements Tree {
         return new Iterable<Tree>() {
             @Override
             public Iterator<Tree> iterator() {
-
-                Iterator<? extends ChildNodeEntry> childEntries = flatten(
-                    new PagedIterator<ChildNodeEntry>(1024) {
-                        @Override
-                        protected Iterator<? extends ChildNodeEntry> getPage(long pos,
int size) {
-                            return getNodeState().getChildNodeEntries(pos, size).iterator();
-                        }
-                    });
+                Iterator<? extends ChildNodeEntry> childEntries =
+                        getNodeState().getChildNodeEntries().iterator();
 
                 return Iterators.map(childEntries, new Function1<ChildNodeEntry, Tree>()
{
                     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/EmptyNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/EmptyNodeState.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/EmptyNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/EmptyNodeState.java
Wed May  2 14:48:10 2012
@@ -66,7 +66,7 @@ public class EmptyNodeState extends Abst
     }
 
     @Override
-    public Iterable<? extends ChildNodeEntry> getChildNodeEntries(long offset, int
count) {
+    public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
         return new Iterable<ChildNodeEntry>() {
             @Override
             public Iterator<ChildNodeEntry> iterator() {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
Wed May  2 14:48:10 2012
@@ -27,12 +27,15 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeState;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.util.Iterators;
+import org.apache.jackrabbit.oak.util.PagedIterator;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 /**
  * Basic {@link NodeState} implementation based on the {@link MicroKernel}
@@ -146,8 +149,36 @@ class KernelNodeState extends AbstractNo
         return child;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
-    public Iterable<? extends ChildNodeEntry> getChildNodeEntries(
+    public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
+        return new Iterable() {  // Java's type system is too weak to express the exact type
here
+            @Override
+            public Iterator<? extends ChildNodeEntry> iterator() {
+                return Iterators.flatten(
+                    new PagedIterator<ChildNodeEntry>(MAX_CHILD_NODE_NAMES) {
+                        @Override
+                        protected Iterator<? extends ChildNodeEntry> getPage(long pos,
int size) {
+                            return getChildNodeEntries(pos, size);
+                        }
+                    });
+            }
+        };
+    }
+
+    //------------------------------------------------------------< internal >---
+
+    String getRevision() {
+        return revision;
+    }
+
+    String getPath() {
+        return path;
+    }
+
+    //------------------------------------------------------------< private >---
+
+    private Iterator<? extends ChildNodeEntry> getChildNodeEntries(
             long offset, int count) {
         init();
         boolean all;
@@ -165,7 +196,7 @@ class KernelNodeState extends AbstractNo
         List<ChildNodeEntry> entries = new ArrayList<ChildNodeEntry>();
 
         if (offset < childNodes.size()) {
-            Iterator<Map.Entry<String, NodeState>> iterator =
+            Iterator<Entry<String, NodeState>> iterator =
                     childNodes.entrySet().iterator();
             while (offset > 0) {
                 iterator.next();
@@ -203,17 +234,7 @@ class KernelNodeState extends AbstractNo
             reader.read(JsopTokenizer.END);
         }
 
-        return entries;
-    }
-
-    //------------------------------------------------------------< internal >---
-
-    String getRevision() {
-        return revision;
-    }
-
-    String getPath() {
-        return path;
+        return entries.iterator();
     }
 
     private String getChildPath(String name) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Wed May  2 14:48:10 2012
@@ -332,7 +332,7 @@ public class KernelNodeStore extends Abs
                 jsop.append("^\"").append(targetPath).append("\":").append(value);
             }
 
-            for (ChildNodeEntry child : nodeState.getChildNodeEntries(0, -1)) {
+            for (ChildNodeEntry child : nodeState.getChildNodeEntries()) {
                 String targetPath = PathUtils.concat(path, child.getName());
                 buildJsop(targetPath, child.getNodeState());
             }
@@ -489,28 +489,15 @@ public class KernelNodeStore extends Abs
             }
 
             @Override
-            public Iterable<? extends ChildNodeEntry> getChildNodeEntries(final long
offset, final int count) {
-                if (offset >= getChildNodeCount()) {
-                    return new Iterable<ChildNodeEntry>() {
-                        @Override
-                        public Iterator<ChildNodeEntry> iterator() {
-                            return Iterators.empty();
-                        }
-                    };
-                }
-                else if (count == -1 || offset + count > getChildNodeCount()) {
-                    return new Iterable<ChildNodeEntry>() {
-                        @Override
-                        public Iterator<ChildNodeEntry> iterator() {
-                            return Iterators.chain(
-                                    parent.getChildNodeEntries(offset, count).iterator(),
-                                    Iterators.singleton(new KernelChildNodeEntry(childName,
node)));
-                        }
-                    };
-                }
-                else {
-                    return parent.getChildNodeEntries(offset, count);
-                }
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
+                return new Iterable<ChildNodeEntry>() {
+                    @Override
+                    public Iterator<ChildNodeEntry> iterator() {
+                        return Iterators.chain(
+                            parent.getChildNodeEntries().iterator(),
+                            Iterators.singleton(new KernelChildNodeEntry(childName, node)));
+                    }
+                };
             }
 
         }
@@ -563,19 +550,19 @@ public class KernelNodeStore extends Abs
             }
 
             @Override
-            public Iterable<? extends ChildNodeEntry> getChildNodeEntries(final long
offset, final int count) {
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
                 return new Iterable<ChildNodeEntry>() {
                     @Override
                     public Iterator<ChildNodeEntry> iterator() {
-                        return Iterators.map(parent.getChildNodeEntries(offset, count).iterator(),
-                                new Function1<ChildNodeEntry, ChildNodeEntry>() {
-                                    @Override
-                                    public ChildNodeEntry apply(ChildNodeEntry cne) {
-                                        return childName.equals(cne.getName())
-                                                ? new KernelChildNodeEntry(childName, node)
-                                                : cne;
-                                    }
-                                });
+                        return Iterators.map(parent.getChildNodeEntries().iterator(),
+                            new Function1<ChildNodeEntry, ChildNodeEntry>() {
+                                @Override
+                                public ChildNodeEntry apply(ChildNodeEntry cne) {
+                                    return childName.equals(cne.getName())
+                                            ? new KernelChildNodeEntry(childName, node)
+                                            : cne;
+                                }
+                            });
                     }
                 };
             }
@@ -626,17 +613,17 @@ public class KernelNodeStore extends Abs
             }
 
             @Override
-            public Iterable<? extends ChildNodeEntry> getChildNodeEntries(final long
offset, final int count) {
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
                 return new Iterable<ChildNodeEntry>() {
                     @Override
                     public Iterator<ChildNodeEntry> iterator() {
-                        return Iterators.filter(parent.getChildNodeEntries(offset, count).iterator(),
// FIXME offsetting doesn't compose with filtering
-                                new Predicate<ChildNodeEntry>() {
-                                    @Override
-                                    public boolean evaluate(ChildNodeEntry cne) {
-                                        return !childName.equals(cne.getName());
-                                    }
+                        return Iterators.filter(parent.getChildNodeEntries().iterator(),
+                            new Predicate<ChildNodeEntry>() {
+                                @Override
+                                public boolean evaluate(ChildNodeEntry cne) {
+                                    return !childName.equals(cne.getName());
                                 }
+                            }
                         );
                     }
                 };
@@ -697,8 +684,8 @@ public class KernelNodeStore extends Abs
             }
 
             @Override
-            public Iterable<? extends ChildNodeEntry> getChildNodeEntries(long offset,
int count) {
-                return parent.getChildNodeEntries(offset, count);
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
+                return parent.getChildNodeEntries();
             }
         }
 
@@ -739,14 +726,14 @@ public class KernelNodeStore extends Abs
                     @Override
                     public Iterator<PropertyState> iterator() {
                         return Iterators.map(parent.getProperties().iterator(),
-                                new Function1<PropertyState, PropertyState>() {
-                                    @Override
-                                    public PropertyState apply(PropertyState state) {
-                                        return property.getName().equals(state.getName())
-                                                ? property
-                                                : state;
-                                    }
+                            new Function1<PropertyState, PropertyState>() {
+                                @Override
+                                public PropertyState apply(PropertyState state) {
+                                    return property.getName().equals(state.getName())
+                                            ? property
+                                            : state;
                                 }
+                            }
                         );
                     }
                 };
@@ -763,8 +750,8 @@ public class KernelNodeStore extends Abs
             }
 
             @Override
-            public Iterable<? extends ChildNodeEntry> getChildNodeEntries(long offset,
int count) {
-                return parent.getChildNodeEntries(offset, count);
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
+                return parent.getChildNodeEntries();
             }
         }
 
@@ -805,12 +792,12 @@ public class KernelNodeStore extends Abs
                     @Override
                     public Iterator<PropertyState> iterator() {
                         return Iterators.filter(parent.getProperties().iterator(),
-                                new Predicate<PropertyState>() {
-                                    @Override
-                                    public boolean evaluate(PropertyState prop) {
-                                        return !propertyName.equals(prop.getName());
-                                    }
+                            new Predicate<PropertyState>() {
+                                @Override
+                                public boolean evaluate(PropertyState prop) {
+                                    return !propertyName.equals(prop.getName());
                                 }
+                            }
                         );
                     }
                 };
@@ -827,8 +814,8 @@ public class KernelNodeStore extends Abs
             }
 
             @Override
-            public Iterable<? extends ChildNodeEntry> getChildNodeEntries(long offset,
int count) {
-                return parent.getChildNodeEntries(offset, count);
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
+                return parent.getChildNodeEntries();
             }
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidatorProvider.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/TypeValidatorProvider.java
Wed May  2 14:48:10 2012
@@ -16,14 +16,14 @@
  */
 package org.apache.jackrabbit.oak.plugins.type;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import java.util.HashSet;
+import java.util.Set;
+
 public class TypeValidatorProvider implements ValidatorProvider {
 
     @Override
@@ -93,7 +93,7 @@ public class TypeValidatorProvider imple
         if (system != null) {
             NodeState registry = system.getChildNode("jcr:nodeTypes");
             if (registry != null) {
-                for (ChildNodeEntry child : registry.getChildNodeEntries(0, -1)) {
+                for (ChildNodeEntry child : registry.getChildNodeEntries()) {
                     types.add(child.getName());
                 }
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
Wed May  2 14:48:10 2012
@@ -28,7 +28,7 @@ import org.apache.jackrabbit.oak.api.Pro
  * the {@link #getProperty(String)} and {@link #getPropertyCount()} methods
  * based on {@link #getProperties()}. The {@link #getChildNode(String)} and
  * {@link #getChildNodeCount()} methods are similarly implemented based on
- * {@link #getChildNodeEntries(long, int)}. Subclasses should normally
+ * {@link #getChildNodeEntries()}. Subclasses should normally
  * override these method with a more efficient alternatives.
  */
 public abstract class AbstractNodeState implements NodeState {
@@ -55,7 +55,7 @@ public abstract class AbstractNodeState 
 
     @Override
     public NodeState getChildNode(String name) {
-        for (ChildNodeEntry entry : getChildNodeEntries(0, -1)) {
+        for (ChildNodeEntry entry : getChildNodeEntries()) {
             if (name.equals(entry.getName())) {
                 return entry.getNodeState();
             }
@@ -67,7 +67,7 @@ public abstract class AbstractNodeState 
     @SuppressWarnings("unused")
     public long getChildNodeCount() {
         long count = 0;
-        for (ChildNodeEntry entry : getChildNodeEntries(0, -1)) {
+        for (ChildNodeEntry entry : getChildNodeEntries()) {
             count++;
         }
         return count;
@@ -105,7 +105,7 @@ public abstract class AbstractNodeState 
         }
 
         long childNodeCount = 0;
-        for (ChildNodeEntry entry : getChildNodeEntries(0, -1)) {
+        for (ChildNodeEntry entry : getChildNodeEntries()) {
             if (!entry.getNodeState().equals(other.getChildNode(entry.getName()))) {
                 return false;
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java
Wed May  2 14:48:10 2012
@@ -73,7 +73,7 @@ public abstract class AbstractNodeStore 
             NodeState before, NodeState after, NodeStateDiff diff) {
         Set<String> beforeChildNodes = new HashSet<String>();
 
-        for (ChildNodeEntry beforeCNE : before.getChildNodeEntries(0, -1)) {
+        for (ChildNodeEntry beforeCNE : before.getChildNodeEntries()) {
             String name = beforeCNE.getName();
             NodeState beforeChild = beforeCNE.getNodeState();
             NodeState afterChild = after.getChildNode(name);
@@ -87,7 +87,7 @@ public abstract class AbstractNodeStore 
             }
         }
 
-        for (ChildNodeEntry afterChild : after.getChildNodeEntries(0, -1)) {
+        for (ChildNodeEntry afterChild : after.getChildNodeEntries()) {
             String name = afterChild.getName();
             if (!beforeChildNodes.contains(name)) {
                 diff.childNodeAdded(name, afterChild.getNodeState());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
Wed May  2 14:48:10 2012
@@ -144,18 +144,12 @@ public interface NodeState {
     long getChildNodeCount();
 
     /**
-     * Returns an iterable of the child node entries starting from the
-     * given offset. Multiple iterations are guaranteed to return the
-     * child nodes in the same order, but the specific order used is
-     * implementation-dependent and may change across different states
-     * of the same node. An empty iterable is returned if the given
-     * offset is greater than the offset of the last child node entry.
-     *
-     * @param offset zero-based offset of the first entry to return
-     * @param count  maximum number of entries to return,
-     *               or -1 for all remaining entries
-     * @return requested child node entries in some stable order
+     * Returns an iterable of the child node entries of this instance.
+     * Multiple iterations are guaranteed to return the child nodes in
+     * the same order, but the specific order used is implementation
+     * dependent and may change across different states of the same node.
+     * @return  child node entries in some stable order
      */
-    Iterable<? extends ChildNodeEntry> getChildNodeEntries(long offset, int count);
+    Iterable<? extends ChildNodeEntry> getChildNodeEntries();
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
Wed May  2 14:48:10 2012
@@ -31,7 +31,6 @@ import java.util.Collections;
 import java.util.List;
 
 import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 
@@ -73,8 +72,7 @@ public class KernelNodeStateTest extends
         Collections.sort(names);
         Collections.sort(values);
         assertEquals(Arrays.asList("a", "b", "c"), names);
-        assertEquals(Arrays.asList(
-                Long.valueOf(1), Long.valueOf(2), Long.valueOf(3)), values);
+        assertEquals(Arrays.asList(1L, 2L, 3L), values);
     }
 
     @Test
@@ -93,43 +91,11 @@ public class KernelNodeStateTest extends
     @Test
     public void testGetChildNodeEntries() {
         List<String> names = new ArrayList<String>();
-        for (ChildNodeEntry entry : state.getChildNodeEntries(0, -1)) {
+        for (ChildNodeEntry entry : state.getChildNodeEntries()) {
             names.add(entry.getName());
         }
         Collections.sort(names);
         assertEquals(Arrays.asList("x", "y", "z"), names);
     }
 
-    @Test
-    public void testGetChildNodeEntriesWithOffset() {
-        List<String> names = new ArrayList<String>();
-        for (ChildNodeEntry entry : state.getChildNodeEntries(0, 1)) {
-            names.add(entry.getName());
-        }
-
-        for (ChildNodeEntry entry : state.getChildNodeEntries(1, -1)) {
-            names.add(entry.getName());
-        }
-        Collections.sort(names);
-        assertEquals(Arrays.asList("x", "y", "z"), names);
-
-        // Offset beyond the range
-        assertFalse(state.getChildNodeEntries(3, -1).iterator().hasNext());
-    }
-
-    @Test
-    public void testGetChildNodeEntriesWithCount() {
-        List<String> names = new ArrayList<String>();
-        for (ChildNodeEntry entry : state.getChildNodeEntries(0, 2)) {
-            names.add(entry.getName());
-        }
-        for (ChildNodeEntry entry : state.getChildNodeEntries(2, -1)) {
-            names.add(entry.getName());
-        }
-        Collections.sort(names);
-        assertEquals(Arrays.asList("x", "y", "z"), names);
-
-        // Zero count
-        assertFalse(state.getChildNodeEntries(0, 0).iterator().hasNext());
-    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java?rev=1333068&r1=1333067&r2=1333068&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
Wed May  2 14:48:10 2012
@@ -25,19 +25,17 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.junit.Test;
 
 import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 
 public class LargeKernelNodeStateTest extends AbstractOakTest {
-
-    private final int N = KernelNodeState.MAX_CHILD_NODE_NAMES;
+    private static final int N = KernelNodeState.MAX_CHILD_NODE_NAMES;
 
     @Override
     protected NodeState createInitialState(MicroKernel microKernel) {
         StringBuilder jsop = new StringBuilder("+\"test\":{\"a\":1");
         for (int i = 0; i <= N; i++) {
-            jsop.append(",\"x" + i + "\":{}");
+            jsop.append(",\"x").append(i).append("\":{}");
         }
         jsop.append('}');
         microKernel.commit("/", jsop.toString(), null, "test data");
@@ -61,36 +59,10 @@ public class LargeKernelNodeStateTest ex
     @SuppressWarnings("unused")
     public void testGetChildNodeEntries() {
         long count = 0;
-        for (ChildNodeEntry entry : state.getChildNodeEntries(0, -1)) {
-            count++;
-        }
-        assertEquals(N + 1, count);
-    }
-
-    @Test
-    @SuppressWarnings("unused")
-    public void testGetChildNodeEntriesWithOffset() {
-        long count = 0;
-        for (ChildNodeEntry entry : state.getChildNodeEntries(N, -1)) {
-            count++;
-        }
-        assertEquals(1, count);
-
-        // Offset beyond the range
-        assertFalse(state.getChildNodeEntries(N + 1, -1).iterator().hasNext());
-    }
-
-    @Test
-    @SuppressWarnings("unused")
-    public void testGetChildNodeEntriesWithCount() {
-        long count = 0;
-        for (ChildNodeEntry entry : state.getChildNodeEntries(0, N + 1)) {
+        for (ChildNodeEntry entry : state.getChildNodeEntries()) {
             count++;
         }
         assertEquals(N + 1, count);
-
-        // Zero count
-        assertFalse(state.getChildNodeEntries(0, 0).iterator().hasNext());
     }
 
 }



Mime
View raw message