jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1236263 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model: ChildNodeEntries.java ChildNodeEntriesInlined.java ChildNodeEntriesTree.java
Date Thu, 26 Jan 2012 16:11:47 GMT
Author: stefan
Date: Thu Jan 26 16:11:46 2012
New Revision: 1236263

URL: http://svn.apache.org/viewvc?rev=1236263&view=rev
Log:
flat hierarchy support (WIP)

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntries.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntries.java?rev=1236263&r1=1236262&r2=1236263&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntries.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntries.java
Thu Jan 26 16:11:46 2012
@@ -47,9 +47,30 @@ public interface ChildNodeEntries extend
 
     //-------------------------------------------------------------< diff ops >
 
+    /**
+     * Returns those entries that exist in <code>other</code> but not in
+     * <code>this</code>.
+     *
+     * @param other
+     * @return
+     */
     Iterator<ChildNodeEntry> getAdded(final ChildNodeEntries other);
 
+    /**
+     * Returns those entries that exist in <code>this</code> but not in
+     * <code>other</code>.
+     *
+     * @param other
+     * @return
+     */
     Iterator<ChildNodeEntry> getRemoved(final ChildNodeEntries other);
 
+    /**
+     * Returns <code>this</code> instance's entries that have namesakes in
+     * <code>other</code> but with different <code>id</code>s.
+     *
+     * @param other
+     * @return
+     */
     Iterator<ChildNodeEntry> getModified(final ChildNodeEntries other);
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java?rev=1236263&r1=1236262&r2=1236263&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
Thu Jan 26 16:11:46 2012
@@ -213,23 +213,14 @@ public class ChildNodeEntriesInlined imp
         };
     }
 
-    public Iterator<ChildNodeEntry> getModified(ChildNodeEntries other) {
+    public Iterator<ChildNodeEntry> getModified(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;
         }
-
-        final ChildNodeEntries cnes1, cnes2;
-        if (other.getCount() < getCount()) {
-            cnes1 = other;
-            cnes2 = this;
-        } else {
-            cnes1 = this;
-            cnes2 = other;
-        }
-        return new AbstractFilteringIterator<ChildNodeEntry>(cnes1.getEntries(0, -1))
{
+        return new AbstractFilteringIterator<ChildNodeEntry>(getEntries(0, -1)) {
             @Override
             protected boolean include(ChildNodeEntry entry) {
-                ChildNodeEntry namesake = cnes2.get(entry.getName());
+                ChildNodeEntry namesake = other.get(entry.getName());
                 return (namesake != null && !namesake.getId().equals(entry.getId()));
             }
         };

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java?rev=1236263&r1=1236262&r2=1236263&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
Thu Jan 26 16:11:46 2012
@@ -385,7 +385,7 @@ public class ChildNodeEntriesTree implem
         }
     }
 
-    public Iterator<ChildNodeEntry> getModified(ChildNodeEntries other) {
+    public Iterator<ChildNodeEntry> getModified(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;
         }
@@ -396,27 +396,49 @@ public class ChildNodeEntriesTree implem
             for (int i = 0; i < index.length; i++) {
                 IndexEntry ie1 = index[i];
                 IndexEntry ie2 = otherEntries.index[i];
-                if (! (ie1 == null ? ie2 == null : ie1.equals(ie2))) {
-                    // index entries aren't equal
-
-                    // todo implement
+                if (ie1 != null && ie2 != null && !ie1.equals(ie2)) {
+                    // index entries are non-null and not equal
+                    if (ie1 instanceof NodeInfo
+                            && ie2 instanceof NodeInfo) {
+                        NodeInfo ni1 = (NodeInfo) ie1;
+                        NodeInfo ni2 = (NodeInfo) ie2;
+                        if (ni1.getName().equals(ni2.getName())
+                                && !ni1.getId().equals(ni2.getId())) {
+                            modified.add(ni1);
+                            continue;
+                        }
+                    }
+
+                    ChildNodeEntriesBucket bucket1;
+                    if (ie1 instanceof NodeInfo) {
+                        bucket1 = new ChildNodeEntriesBucket();
+                        bucket1.add((ChildNodeEntry) ie1);
+                    } else {
+                        BucketInfo bi = (BucketInfo) ie1;
+                        bucket1 = retrieveBucket(bi.getId());
+                    }
+                    ChildNodeEntriesBucket bucket2;
+                    if (ie2 instanceof NodeInfo) {
+                        bucket2 = new ChildNodeEntriesBucket();
+                        bucket2.add((ChildNodeEntry) ie2);
+                    } else {
+                        BucketInfo bi = (BucketInfo) ie2;
+                        bucket2 = retrieveBucket(bi.getId());
+                    }
+
+                    for (Iterator<ChildNodeEntry> it = bucket1.getModified(bucket2);
+                         it.hasNext(); ) {
+                        modified.add(it.next());
+                    }
                 }
             }
 
             return modified.iterator();
         } else {
-            final ChildNodeEntries cnes1, cnes2;
-            if (other.getCount() < getCount()) {
-                cnes1 = other;
-                cnes2 = this;
-            } else {
-                cnes1 = this;
-                cnes2 = other;
-            }
-            return new AbstractFilteringIterator<ChildNodeEntry>(cnes1.getEntries(0,
-1)) {
+            return new AbstractFilteringIterator<ChildNodeEntry>(getEntries(0, -1))
{
                 @Override
                 protected boolean include(ChildNodeEntry entry) {
-                    ChildNodeEntry namesake = cnes2.get(entry.getName());
+                    ChildNodeEntry namesake = other.get(entry.getName());
                     return (namesake != null && !namesake.getId().equals(entry.getId()));
                 }
             };



Mime
View raw message