jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1239741 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model: AbstractNode.java ChildNodeEntries.java ChildNodeEntriesInlined.java ChildNodeEntriesTree.java MutableNode.java
Date Thu, 02 Feb 2012 17:37:53 GMT
Author: stefan
Date: Thu Feb  2 17:37:53 2012
New Revision: 1239741

URL: http://svn.apache.org/viewvc?rev=1239741&view=rev
Log:
refactoring persistence logic & cleanup

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java
    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
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.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=1239741&r1=1239740&r2=1239741&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
Thu Feb  2 17:37:53 2012
@@ -52,14 +52,12 @@ public abstract class AbstractNode imple
             this.childEntries = (ChildNodeEntries) srcNode.childEntries.clone();
         } else {
             this.properties = new HashMap<String, String>(other.getProperties());
-            this.childEntries = new ChildNodeEntriesInlined();
-/*
             if (other.getChildNodeCount() <= ChildNodeEntries.CAPACITY_THRESHOLD) {
                 this.childEntries = new ChildNodeEntriesInlined();
             } else {
                 this.childEntries = new ChildNodeEntriesTree();
             }
-*/
+
             for (Iterator<ChildNodeEntry> it = other.getChildNodeEntries(0, -1); it.hasNext();
) {
                 ChildNodeEntry cne = it.next();
                 this.childEntries.add(cne);

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=1239741&r1=1239740&r2=1239741&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 Feb  2 17:37:53 2012
@@ -27,6 +27,8 @@ public interface ChildNodeEntries extend
 
     Object clone();
 
+    boolean inlined();
+
     //-------------------------------------------------------------< read ops >
 
     int getCount();

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=1239741&r1=1239740&r2=1239741&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 Feb  2 17:37:53 2012
@@ -60,16 +60,24 @@ public class ChildNodeEntriesInlined imp
         return clone;
     }
 
+    @Override
+    public boolean inlined() {
+        return true;
+    }
+
     //-------------------------------------------------------------< read ops >
 
+    @Override
     public int getCount() {
         return entries.size();
     }
 
+    @Override
     public ChildNodeEntry get(String name) {
         return entries.get(name);
     }
 
+    @Override
     public Iterator<String> getNames(int offset, int count) {
         if (offset < 0 || count < -1) {
             throw new IllegalArgumentException();
@@ -88,6 +96,7 @@ public class ChildNodeEntriesInlined imp
         }
     }
 
+    @Override
     public Iterator<ChildNodeEntry> getEntries(int offset, int count) {
         if (offset < 0 || count < -1) {
             throw new IllegalArgumentException();
@@ -107,14 +116,17 @@ public class ChildNodeEntriesInlined imp
 
     //------------------------------------------------------------< write ops >
 
+    @Override
     public ChildNodeEntry add(ChildNodeEntry entry) {
         return entries.put(entry.getName(), entry);
     }
 
+    @Override
     public ChildNodeEntry remove(String name) {
         return entries.remove(name);
     }
 
+    @Override
     public ChildNodeEntry rename(String oldName, String newName) {
         if (oldName.equals(newName)) {
             return entries.get(oldName);
@@ -137,6 +149,7 @@ public class ChildNodeEntriesInlined imp
         return oldCNE;
     }
 
+    @Override
     public ChildNodeEntry moveAfter(String name, String sibling) {
         ChildNodeEntry target = entries.remove(name);
         if (target == null) {
@@ -161,6 +174,7 @@ public class ChildNodeEntriesInlined imp
         return target;
     }
 
+    @Override
     public ChildNodeEntry moveBefore(String name, String sibling) {
         ChildNodeEntry target = entries.remove(name);
         if (target == null) {
@@ -187,6 +201,7 @@ public class ChildNodeEntriesInlined imp
 
     //-------------------------------------------------------------< diff ops >
 
+    @Override
     public Iterator<ChildNodeEntry> getAdded(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;            
@@ -200,6 +215,7 @@ public class ChildNodeEntriesInlined imp
         };
     }
 
+    @Override
     public Iterator<ChildNodeEntry> getRemoved(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;
@@ -213,6 +229,7 @@ public class ChildNodeEntriesInlined imp
         };
     }
 
+    @Override
     public Iterator<ChildNodeEntry> getModified(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;

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=1239741&r1=1239740&r2=1239741&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 Feb  2 17:37:53 2012
@@ -40,6 +40,11 @@ public class ChildNodeEntriesTree implem
     ChildNodeEntriesTree() {
     }
 
+    @Override
+    public boolean inlined() {
+        return false;
+    }
+
     //------------------------------------------------------------< overrides >
 
     @Override
@@ -69,10 +74,12 @@ public class ChildNodeEntriesTree implem
 
     //-------------------------------------------------------------< read ops >
 
+    @Override
     public int getCount() {
         return count;
     }
 
+    @Override
     public ChildNodeEntry get(String name) {
         IndexEntry entry = index[keyToIndex(name)];
         if (entry == null) {
@@ -87,6 +94,7 @@ public class ChildNodeEntriesTree implem
         }
     }
 
+    @Override
     public Iterator<String> getNames(int offset, int cnt) {
         if (offset < 0 || cnt < -1) {
             throw new IllegalArgumentException();
@@ -109,6 +117,7 @@ public class ChildNodeEntriesTree implem
         };
     }
 
+    @Override
     public Iterator<ChildNodeEntry> getEntries(int offset, int cnt) {
         if (offset < 0 || cnt < -1) {
             throw new IllegalArgumentException();
@@ -152,6 +161,7 @@ public class ChildNodeEntriesTree implem
 
     //------------------------------------------------------------< write ops >
 
+    @Override
     public ChildNodeEntry add(ChildNodeEntry entry) {
         int idx = keyToIndex(entry.getName());
         IndexEntry ie = index[idx];
@@ -196,6 +206,7 @@ public class ChildNodeEntriesTree implem
         }
     }
 
+    @Override
     public ChildNodeEntry remove(String name) {
         int idx = keyToIndex(name);
         IndexEntry ie = index[idx];
@@ -235,6 +246,7 @@ public class ChildNodeEntriesTree implem
         }
     }
 
+    @Override
     public ChildNodeEntry rename(String oldName, String newName) {
         if (oldName.equals(newName)) {
             return get(oldName);
@@ -247,11 +259,13 @@ public class ChildNodeEntriesTree implem
         return old;
     }
 
+    @Override
     public ChildNodeEntry moveAfter(String name, String sibling) {
         // not supported, silently ignore
         return get(name);
     }
 
+    @Override
     public ChildNodeEntry moveBefore(String name, String sibling) {
         // not supported, silently ignore
         return get(name);
@@ -259,6 +273,7 @@ public class ChildNodeEntriesTree implem
 
     //-------------------------------------------------------------< diff ops >
 
+    @Override
     public Iterator<ChildNodeEntry> getAdded(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;
@@ -322,6 +337,7 @@ public class ChildNodeEntriesTree implem
         }
     }
 
+    @Override
     public Iterator<ChildNodeEntry> getRemoved(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;
@@ -385,6 +401,7 @@ public class ChildNodeEntriesTree implem
         }
     }
 
+    @Override
     public Iterator<ChildNodeEntry> getModified(final ChildNodeEntries other) {
         if (equals(other)) {
             return EMPTY_ITER;

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java?rev=1239741&r1=1239740&r2=1239741&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java
Thu Feb  2 17:37:53 2012
@@ -16,10 +16,14 @@
  */
 package org.apache.jackrabbit.mk.model;
 
+import org.apache.jackrabbit.mk.store.Binding;
+import org.apache.jackrabbit.mk.store.PersistHook;
+import org.apache.jackrabbit.mk.store.RevisionStore;
+
 /**
  *
  */
-public class MutableNode extends AbstractNode {
+public class MutableNode extends AbstractNode implements PersistHook {
 
     public MutableNode() {
     }
@@ -39,4 +43,23 @@ public class MutableNode extends Abstrac
     public ChildNodeEntry rename(String oldName, String newName) {
         return childEntries.rename(oldName, newName);
     }
+
+    @Override
+    public void serialize(Binding binding) throws Exception {
+        super.serialize(binding);
+    }
+
+    //----------------------------------------------------------< PersistHook >
+
+    @Override
+    public void prePersist(RevisionStore store) throws Exception {
+        if (!childEntries.inlined()) {
+            // todo persist dirty buckets (delegate to ChildNodeEntries instance?)
+        }
+    }
+
+    @Override
+    public void postPersist(RevisionStore store) throws Exception {
+        // there's nothing to do
+    }
 }



Mime
View raw message