jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1234021 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model: AbstractNode.java ChildNodeEntriesBasic.java ChildNodeEntriesBucket.java ChildNodeEntriesInlined.java ChildNodeEntriesTree.java
Date Fri, 20 Jan 2012 17:33:32 GMT
Author: stefan
Date: Fri Jan 20 17:33:32 2012
New Revision: 1234021

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

Added:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBucket.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
      - copied, changed from r1228255, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBasic.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
Removed:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBasic.java
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java?rev=1234021&r1=1234020&r2=1234021&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java
Fri Jan 20 17:33:32 2012
@@ -37,21 +37,21 @@ public abstract class AbstractNode imple
 
     protected HashMap<String, String> properties;
 
-    protected ChildNodeEntriesBasic childEntries;
+    protected ChildNodeEntriesInlined childEntries;
 
     protected AbstractNode() {
         this.properties = new HashMap<String, String>();
-        this.childEntries = new ChildNodeEntriesBasic();
+        this.childEntries = new ChildNodeEntriesInlined();
     }
 
     protected AbstractNode(Node other) {
         if (other instanceof AbstractNode) {
             AbstractNode srcNode = (AbstractNode) other;
             this.properties = (HashMap<String, String>) srcNode.properties.clone();
-            this.childEntries = (ChildNodeEntriesBasic) srcNode.childEntries.clone();
+            this.childEntries = (ChildNodeEntriesInlined) srcNode.childEntries.clone();
         } else {
             this.properties = new HashMap<String, String>(other.getProperties());
-            this.childEntries = new ChildNodeEntriesBasic();
+            this.childEntries = new ChildNodeEntriesInlined();
             for (Iterator<ChildNodeEntry> it = other.getChildNodeEntries(); it.hasNext();
) {
                 ChildNodeEntry cne = it.next();
                 this.childEntries.add(cne);
@@ -157,7 +157,7 @@ public abstract class AbstractNode imple
         // compare child node entries
 
         if (other instanceof AbstractNode) {
-            ChildNodeEntriesBasic otherEntries = ((AbstractNode) other).childEntries;
+            ChildNodeEntriesInlined otherEntries = ((AbstractNode) other).childEntries;
             for (Iterator<ChildNodeEntry> it = childEntries.getAdded(otherEntries);
it.hasNext(); ) {
                 handler.childNodeAdded(it.next());
             }

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBucket.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBucket.java?rev=1234021&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBucket.java
(added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBucket.java
Fri Jan 20 17:33:32 2012
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.mk.model;
+
+import java.util.Iterator;
+
+/**
+ * todo implement using HashMap (insertion order not required)
+ */
+public class ChildNodeEntriesBucket implements ChildNodeEntries {
+    public int getCount() {
+        return 0;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public ChildNodeEntry get(String name) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public Iterator<String> getNames(int offset, int count) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public Iterator<ChildNodeEntry> getEntries(int offset, int count) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public ChildNodeEntry add(ChildNodeEntry entry) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public ChildNodeEntry remove(String name) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public ChildNodeEntry rename(String oldName, String newName) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public ChildNodeEntry moveAfter(String name, String sibling) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public ChildNodeEntry moveBefore(String name, String sibling) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public Iterator<ChildNodeEntry> getAdded(ChildNodeEntries other) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public Iterator<ChildNodeEntry> getRemoved(ChildNodeEntries other) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    public Iterator<ChildNodeEntry> getModified(ChildNodeEntries other) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+}

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
(from r1228255, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBasic.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBasic.java&r1=1228255&r2=1234021&rev=1234021&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesBasic.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesInlined.java
Fri Jan 20 17:33:32 2012
@@ -27,13 +27,13 @@ import java.util.Map;
 /**
  *
  */
-public class ChildNodeEntriesBasic implements ChildNodeEntries {
+public class ChildNodeEntriesInlined implements ChildNodeEntries {
 
     protected static final Iterator<ChildNodeEntry> EMPTY_ITER = new EmptyIterator<ChildNodeEntry>();
     
     protected LinkedHashMap<String, ChildNodeEntry> entries;
     
-    ChildNodeEntriesBasic() {
+    ChildNodeEntriesInlined() {
         entries = new LinkedHashMap<String, ChildNodeEntry>();
     }
 
@@ -41,17 +41,17 @@ public class ChildNodeEntriesBasic imple
 
     @Override
     public boolean equals(Object obj) {
-        if (obj instanceof ChildNodeEntriesBasic) {
-            return entries.equals(((ChildNodeEntriesBasic) obj).entries);
+        if (obj instanceof ChildNodeEntriesInlined) {
+            return entries.equals(((ChildNodeEntriesInlined) obj).entries);
         }
         return false;
     }
 
     @Override
     protected Object clone()  {
-        ChildNodeEntriesBasic clone = null;
+        ChildNodeEntriesInlined clone = null;
         try {
-            clone = (ChildNodeEntriesBasic) super.clone();
+            clone = (ChildNodeEntriesInlined) super.clone();
         } catch (CloneNotSupportedException e) {
             // can't possibly get here
         }

Added: 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=1234021&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
(added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/ChildNodeEntriesTree.java
Fri Jan 20 17:33:32 2012
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.mk.model;
+
+import org.apache.jackrabbit.mk.util.EmptyIterator;
+import org.apache.jackrabbit.mk.util.RangeIterator;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ */
+public class ChildNodeEntriesTree implements ChildNodeEntries {
+
+    protected static final Iterator<ChildNodeEntry> EMPTY_ITER = new EmptyIterator<ChildNodeEntry>();
+
+    protected int count;
+
+    protected IndexEntry[] index = new IndexEntry[1024];  // 2^10
+
+    ChildNodeEntriesTree() {
+    }
+
+    //------------------------------------------------------------< overrides >
+
+    @Override
+    public boolean equals(Object obj) {
+        // todo implement
+        return super.equals(obj);
+    }
+
+    @Override
+    protected Object clone() {
+        ChildNodeEntriesTree clone = null;
+        try {
+            clone = (ChildNodeEntriesTree) super.clone();
+        } catch (CloneNotSupportedException e) {
+            // can't possibly get here
+        }
+        // todo properly initialize all fields
+        return clone;
+    }
+
+    //-------------------------------------------------------------< read ops >
+
+    public int getCount() {
+        return count;
+    }
+
+    public ChildNodeEntry get(String name) {
+        IndexEntry entry = index[keyToIndex(name)];
+        if (entry == null) {
+            return null;
+        }
+        if (entry instanceof ChildNodeEntry) {
+            return (ChildNodeEntry) entry;
+        } else {
+            BucketInfo bi = (BucketInfo) entry;
+            ChildNodeEntries entries = retrieveBucket(bi.id);
+            return entries == null ? null : entries.get(name);
+        }
+    }
+
+    public Iterator<String> getNames(int offset, int cnt) {
+        if (offset < 0 || cnt < -1) {
+            throw new IllegalArgumentException();
+        }
+
+        if (offset >= count) {
+            return new EmptyIterator<String>();
+        }
+
+        int n = 0;
+        if (cnt == -1 || (offset + cnt) > count) {
+            cnt = count - offset;
+        }
+        ArrayList<String> names = new ArrayList<String>(cnt);
+        for (IndexEntry e : index) {
+            if (e != null) {
+                if (n + e.getSize() > offset) {
+                    if (e instanceof NodeInfo) {
+                        names.add(((NodeInfo) e).getName());
+                    } else {
+                        BucketInfo bi = (BucketInfo) e;
+                        ChildNodeEntriesBucket bucket = retrieveBucket(bi.id);
+                        // todo implement
+                    }
+                }
+                n += e.getSize();
+            }
+        }
+        
+        return names.iterator();
+    }
+
+    public Iterator<ChildNodeEntry> getEntries(int offset, int cnt) {
+        if (offset < 0 || cnt < -1) {
+            throw new IllegalArgumentException();
+        }
+
+        // todo implement
+        return null;
+    }
+
+    //------------------------------------------------------------< write ops >
+
+    public ChildNodeEntry add(ChildNodeEntry entry) {
+        // todo implement
+        return null;
+    }
+
+    public ChildNodeEntry remove(String name) {
+        // todo implement
+        return null;
+    }
+
+    public ChildNodeEntry rename(String oldName, String newName) {
+        // todo implement
+        return null;
+    }
+
+    public ChildNodeEntry moveAfter(String name, String sibling) {
+        // not supported, silently ignore
+        // todo implement
+        return null;
+    }
+
+    public ChildNodeEntry moveBefore(String name, String sibling) {
+        // not supported, silently ignore
+        // todo implement
+        return null;
+    }
+
+    //-------------------------------------------------------------< diff ops >
+
+    public Iterator<ChildNodeEntry> getAdded(final ChildNodeEntries other) {
+        if (equals(other)) {
+            return EMPTY_ITER;
+        }
+
+        // todo implement
+        return null;
+    }
+
+    public Iterator<ChildNodeEntry> getRemoved(final ChildNodeEntries other) {
+        if (equals(other)) {
+            return EMPTY_ITER;
+        }
+
+        // todo implement
+        return null;
+    }
+
+    public Iterator<ChildNodeEntry> getModified(final ChildNodeEntries other) {
+        if (equals(other)) {
+            return EMPTY_ITER;
+        }
+
+        // todo implement
+        return null;
+    }
+
+    //-------------------------------------------------------< implementation >
+    
+    protected int keyToIndex(String key) {
+        int hash = key.hashCode();
+        // todo rehash? ensure optimal distribution of hash WRT to index.length
+        return (hash & 0x7FFFFFFF) % index.length;
+    }
+
+    protected ChildNodeEntriesBucket retrieveBucket(String id) {
+        // todo implement
+        return null;
+    }
+
+    //--------------------------------------------------------< inner classes >
+
+    protected static interface IndexEntry {
+        // number of entries
+        int getSize();
+    }
+
+    protected static class BucketInfo implements IndexEntry {
+        // bucket id
+        String id;
+
+        // number of bucket entries
+        int size;
+
+        public int getSize() {
+            return size;
+        }
+    }
+
+    protected static class NodeInfo extends ChildNodeEntry implements IndexEntry {
+
+        public NodeInfo(String name, String id) {
+            super(name, id);
+        }
+
+        public int getSize() {
+            return 1;
+        }
+    }
+}



Mime
View raw message