jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1241023 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
Date Mon, 06 Feb 2012 14:40:40 GMT
Author: stefan
Date: Mon Feb  6 14:40:40 2012
New Revision: 1241023

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

Modified:
    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/ChildNodeEntriesTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java?rev=1241023&r1=1241022&r2=1241023&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
Mon Feb  6 14:40:40 2012
@@ -390,10 +390,10 @@ public class ChildNodeEntriesTree implem
                 if (! (ie1 == null ? ie2 == null : ie1.equals(ie2))) {
                     // index entries aren't equal
                     if (ie2 == null) {
-                        // other index entry in null => this must be non-null
+                        // other index entry is null => this must be non-null
                         if (ie1 instanceof NodeInfo) {
                             removed.add((ChildNodeEntry) ie1);
-                        } else if (ie2 instanceof BucketInfo) {
+                        } else if (ie1 instanceof BucketInfo) {
                             BucketInfo bi = (BucketInfo) ie1;
                             ChildNodeEntriesBucket bucket = retrieveBucket(bi.getId());
                             for (Iterator<ChildNodeEntry> it = bucket.getEntries(0,
-1);
@@ -568,13 +568,15 @@ public class ChildNodeEntriesTree implem
                 // serialize index array entry
                 IndexEntry entry = index[pos];
                 if (entry == null) {
-                    // null entry
-                    return new Binding.KeyValuePair(Integer.toString(pos), ""); 
+                    // null entry: ""
+                    return new Binding.KeyValuePair(Integer.toString(pos), "");
                 } else if (entry instanceof NodeInfo) {
                     NodeInfo ni = (NodeInfo) entry;
+                    // "n<id>:<name>"
                     return new Binding.KeyValuePair(Integer.toString(pos), "n" + ni.getId()
+ ":" + ni.getName());
                 } else {
                     BucketInfo bi = (BucketInfo) entry;
+                    // "b<id>:<count>"
                     return new Binding.KeyValuePair(Integer.toString(pos), "b" + bi.getId()
+ ":" + bi.getSize());
                 }
             }
@@ -597,15 +599,22 @@ public class ChildNodeEntriesTree implem
             // deserialize index array entry
             assert(pos == Integer.parseInt(kvp.getKey()));
             if (kvp.getValue().length() == 0) {
+                // ""
                 newInstance.index[pos] = null;
             } else if (kvp.getValue().charAt(0) == 'n') {
-                // todo opimize parsing
-                String parts[] = kvp.getValue().substring(1).split(":");
-                newInstance.index[pos] = new NodeInfo(parts[1], parts[0]);
+                // "n<id>:<name>"
+                String value = kvp.getValue().substring(1);
+                int i = value.indexOf(':');
+                String id = value.substring(0, i);
+                String name = value.substring(i + 1);
+                newInstance.index[pos] = new NodeInfo(name, id);
             } else {
-                // todo opimize parsing
-                String parts[] = kvp.getValue().substring(1).split(":");
-                newInstance.index[pos] = new BucketInfo(parts[0], Integer.parseInt(parts[1]));
+                // "b<id>:<count>"
+                String value = kvp.getValue().substring(1);
+                int i = value.indexOf(':');
+                String id = value.substring(0, i);
+                int count = Integer.parseInt(value.substring(i + 1));
+                newInstance.index[pos] = new BucketInfo(id, count);
             }
         }
         return newInstance;



Mime
View raw message