jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1002601 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence: bundle/AbstractBundlePersistenceManager.java pool/AbstractBundlePersistenceManager.java util/BundleBinding.java util/NodePropBundle.java
Date Wed, 29 Sep 2010 13:07:46 GMT
Author: jukka
Date: Wed Sep 29 13:07:45 2010
New Revision: 1002601

URL: http://svn.apache.org/viewvc?rev=1002601&view=rev
Log:
JCR-2762: Optimize bundle serialization

Remove the direct reference from NodePropBundle to BundleBinding to make it easier to later
refactor the BundleBinding class.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=1002601&r1=1002600&r2=1002601&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Wed Sep 29 13:07:45 2010
@@ -447,7 +447,7 @@ public abstract class AbstractBundlePers
             } else {
                 throw new NoSuchItemStateException(id.toString());
             }
-            bundle.addProperty(state);
+            bundle.addProperty(state, getBinding().getBlobStore());
         }
         return state;
     }
@@ -533,7 +533,7 @@ public abstract class AbstractBundlePers
         HashMap<ItemId, NodePropBundle> modified = new HashMap<ItemId, NodePropBundle>();
         for (ItemState state : changeLog.addedStates()) {
             if (state.isNode()) {
-                NodePropBundle bundle = new NodePropBundle(getBinding(), (NodeState) state);
+                NodePropBundle bundle = new NodePropBundle((NodeState) state);
                 modified.put(state.getId(), bundle);
             }
         }
@@ -567,7 +567,8 @@ public abstract class AbstractBundlePers
                     }
                     modified.put(nodeId, bundle);
                 }
-                bundle.addProperty((PropertyState) state);
+                bundle.addProperty(
+                        (PropertyState) state, getBinding().getBlobStore());
             }
         }
         // add removed properties
@@ -592,7 +593,8 @@ public abstract class AbstractBundlePers
                         }
                         modified.put(nodeId, bundle);
                     }
-                    bundle.removeProperty(id.getName());
+                    bundle.removeProperty(
+                            id.getName(), getBinding().getBlobStore());
                 }
             }
         }
@@ -617,7 +619,8 @@ public abstract class AbstractBundlePers
                     }
                     modified.put(nodeId, bundle);
                 }
-                bundle.addProperty((PropertyState) state);
+                bundle.addProperty(
+                        (PropertyState) state, getBinding().getBlobStore());
             }
         }
 
@@ -669,7 +672,7 @@ public abstract class AbstractBundlePers
      */
     private void deleteBundle(NodePropBundle bundle) throws ItemStateException {
         destroyBundle(bundle);
-        bundle.removeAllProperties();
+        bundle.removeAllProperties(getBinding().getBlobStore());
         bundles.remove(bundle.getId());
         missing.put(bundle.getId());
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java?rev=1002601&r1=1002600&r2=1002601&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/AbstractBundlePersistenceManager.java
Wed Sep 29 13:07:45 2010
@@ -445,7 +445,7 @@ public abstract class AbstractBundlePers
             } else {
                 throw new NoSuchItemStateException(id.toString());
             }
-            bundle.addProperty(state);
+            bundle.addProperty(state, getBinding().getBlobStore());
         }
         return state;
     }
@@ -531,7 +531,7 @@ public abstract class AbstractBundlePers
         HashMap<ItemId, NodePropBundle> modified = new HashMap<ItemId, NodePropBundle>();
         for (ItemState state : changeLog.addedStates()) {
             if (state.isNode()) {
-                NodePropBundle bundle = new NodePropBundle(getBinding(), (NodeState) state);
+                NodePropBundle bundle = new NodePropBundle((NodeState) state);
                 modified.put(state.getId(), bundle);
             }
         }
@@ -565,7 +565,8 @@ public abstract class AbstractBundlePers
                     }
                     modified.put(nodeId, bundle);
                 }
-                bundle.addProperty((PropertyState) state);
+                bundle.addProperty(
+                        (PropertyState) state, getBinding().getBlobStore());
             }
         }
         // add removed properties
@@ -590,7 +591,8 @@ public abstract class AbstractBundlePers
                         }
                         modified.put(nodeId, bundle);
                     }
-                    bundle.removeProperty(id.getName());
+                    bundle.removeProperty(
+                            id.getName(), getBinding().getBlobStore());
                 }
             }
         }
@@ -615,7 +617,8 @@ public abstract class AbstractBundlePers
                     }
                     modified.put(nodeId, bundle);
                 }
-                bundle.addProperty((PropertyState) state);
+                bundle.addProperty(
+                        (PropertyState) state, getBinding().getBlobStore());
             }
         }
 
@@ -667,7 +670,7 @@ public abstract class AbstractBundlePers
      */
     private void deleteBundle(NodePropBundle bundle) throws ItemStateException {
         destroyBundle(bundle);
-        bundle.removeAllProperties();
+        bundle.removeAllProperties(getBinding().getBlobStore());
         bundles.remove(bundle.getId());
         missing.put(bundle.getId());
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleBinding.java?rev=1002601&r1=1002600&r2=1002601&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleBinding.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleBinding.java
Wed Sep 29 13:07:45 2010
@@ -76,8 +76,7 @@ public class BundleBinding extends ItemS
      */
     public NodePropBundle readBundle(DataInputStream in, NodeId id)
             throws IOException {
-
-        NodePropBundle bundle = new NodePropBundle(this, id);
+        NodePropBundle bundle = new NodePropBundle(id);
 
         // read version and primary type...special handling
         int index = in.readInt();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java?rev=1002601&r1=1002600&r2=1002601&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
Wed Sep 29 13:07:45 2010
@@ -18,7 +18,7 @@ package org.apache.jackrabbit.core.persi
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
@@ -48,11 +48,6 @@ public class NodePropBundle {
     private static Logger log = LoggerFactory.getLogger(NodePropBundle.class);
 
     /**
-     * the bundle binding that handles this bundle
-     */
-    private final BundleBinding binding;
-
-    /**
      * the node id
      */
     private final NodeId id;
@@ -110,21 +105,20 @@ public class NodePropBundle {
 
     /**
      * Creates a "new" bundle with the given id
-     * @param binding the bundle binding
+     *
      * @param id the node id
      */
-    public NodePropBundle(BundleBinding binding, NodeId id) {
-        this.binding = binding;
+    public NodePropBundle(NodeId id) {
         this.id = id;
     }
 
     /**
      * Creates a bundle from the given state
-     * @param binding the bundle binding
+     *
      * @param state the node state
      */
-    public NodePropBundle(BundleBinding binding, NodeState state) {
-        this(binding, (NodeId) state.getId());
+    public NodePropBundle(NodeState state) {
+        this(state.getNodeId());
         update(state);
     }
 
@@ -332,12 +326,16 @@ public class NodePropBundle {
 
     /**
      * Creates a property entry from the given state and adds it.
+     *
      * @param state the property state
+     * @param blobStore BLOB store from where to delete previous property value
      */
-    public void addProperty(PropertyState state) {
-        PropertyEntry old = properties.put(state.getName(), new PropertyEntry(state));
+    @SuppressWarnings("deprecation")
+    public void addProperty(PropertyState state, BLOBStore blobStore) {
+        PropertyEntry old =
+            properties.put(state.getName(), new PropertyEntry(state));
         if (old != null) {
-            old.destroy(binding.getBlobStore());
+            old.destroy(blobStore);
         }
     }
 
@@ -381,24 +379,27 @@ public class NodePropBundle {
 
     /**
      * Removes all property entries
+     *
+     * @param blobStore BLOB store from where to delete property values
      */
-    public void removeAllProperties() {
-        Iterator<Name> iter = properties.keySet().iterator();
-        while (iter.hasNext()) {
-            Name name = (Name) iter.next();
-            removeProperty(name);
-            iter = properties.keySet().iterator();
+    @SuppressWarnings("deprecation")
+    public void removeAllProperties(BLOBStore blobStore) {
+        for (Name name : new HashSet<Name>(properties.keySet())) {
+            removeProperty(name, blobStore);
         }
     }
 
     /**
      * Removes the proprty with the given name from this bundle.
+     *
      * @param name the name of the property
+     * @param blobStore BLOB store from where to delete the property value
      */
-    public void removeProperty(Name name) {
-        PropertyEntry pe = (PropertyEntry) properties.remove(name);
+    @SuppressWarnings("deprecation")
+    public void removeProperty(Name name, BLOBStore blobStore) {
+        PropertyEntry pe = properties.remove(name);
         if (pe != null) {
-            pe.destroy(binding.getBlobStore());
+            pe.destroy(blobStore);
         }
     }
     
@@ -665,20 +666,21 @@ public class NodePropBundle {
          * Destroys this property state and deletes temporary blob file values.
          * @param blobStore the blobstore that will destroy the blobs
          */
+        @SuppressWarnings("deprecation")
         private void destroy(BLOBStore blobStore) {
             // delete blobs if needed
-            if (blobIds != null) {
-                for (int i = 0; i < blobIds.length; i++) {
-                    if (blobIds[i] != null) {
-                        try {
-                            blobStore.remove(blobIds[i]);
-                            log.debug("removed blob {}", blobIds[i]);
-                        } catch (Exception e) {
-                            log.error("Ingoring error while removing blob {}", blobIds[i],
e);
-                        }
+            for (int i = 0; blobIds != null && i < blobIds.length; i++) {
+                if (blobIds[i] != null) {
+                    try {
+                        blobStore.remove(blobIds[i]);
+                        log.debug("removed blob {}", blobIds[i]);
+                    } catch (Exception e) {
+                        log.error("Ignoring error while removing blob " + blobIds[i], e);
                     }
                 }
             }
         }
+
     }
+
 }



Mime
View raw message