jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1002709 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence: bundle/ pool/ util/
Date Wed, 29 Sep 2010 16:07:11 GMT
Author: jukka
Date: Wed Sep 29 16:07:11 2010
New Revision: 1002709

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

Make the use of DataOutputStream in writeBundle() an implementation detail that's not exposed
in the method signature.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleBinding.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=1002709&r1=1002708&r2=1002709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
Wed Sep 29 16:07:11 2010
@@ -19,8 +19,6 @@ package org.apache.jackrabbit.core.persi
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
 import java.io.File;
 import java.io.FilterInputStream;
 import java.io.IOException;
@@ -1194,10 +1192,9 @@ public class BundleDbPersistenceManager 
      */
     protected synchronized void storeBundle(NodePropBundle bundle) throws ItemStateException
{
         try {
-            ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
-            DataOutputStream dout = new DataOutputStream(out);
-            binding.writeBundle(dout, bundle);
-            dout.close();
+            ByteArrayOutputStream out =
+                new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+            binding.writeBundle(out, bundle);
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
             Object[] params = createParams(bundle.getId(), out.toByteArray(), true);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java?rev=1002709&r1=1002708&r2=1002709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
Wed Sep 29 16:07:11 2010
@@ -37,7 +37,6 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
 
-import java.io.DataOutputStream;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -320,9 +319,11 @@ public class BundleFsPersistenceManager 
                 itemFs.createFolder(dir);
             }
             OutputStream out = itemFs.getOutputStream(fileName);
-            DataOutputStream dout = new DataOutputStream(out);
-            binding.writeBundle(dout, bundle);
-            dout.close();
+            try {
+                binding.writeBundle(out, bundle);
+            } finally {
+                out.close();
+            }
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
             BundleFsPersistenceManager.log.error(msg, e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java?rev=1002709&r1=1002708&r2=1002709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
Wed Sep 29 16:07:11 2010
@@ -27,7 +27,6 @@ import org.apache.jackrabbit.core.state.
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -109,10 +108,9 @@ public class Oracle9PersistenceManager e
             throws ItemStateException {
         Blob blob = null;
         try {
-            ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
-            DataOutputStream dout = new DataOutputStream(out);
-            binding.writeBundle(dout, bundle);
-            dout.close();
+            ByteArrayOutputStream out =
+                new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+            binding.writeBundle(out, bundle);
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
             blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java?rev=1002709&r1=1002708&r2=1002709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
Wed Sep 29 16:07:11 2010
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.core.persi
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
 import java.io.File;
 import java.io.FilterInputStream;
 import java.io.IOException;
@@ -1119,10 +1118,9 @@ public class BundleDbPersistenceManager 
      */
     protected synchronized void storeBundle(NodePropBundle bundle) throws ItemStateException
{
         try {
-            ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
-            DataOutputStream dout = new DataOutputStream(out);
-            binding.writeBundle(dout, bundle);
-            dout.close();
+            ByteArrayOutputStream out =
+                new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
+            binding.writeBundle(out, bundle);
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
             Object[] params = createParams(bundle.getId(), out.toByteArray(), true);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java?rev=1002709&r1=1002708&r2=1002709&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleFsPersistenceManager.java
Wed Sep 29 16:07:11 2010
@@ -37,7 +37,6 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
 
-import java.io.DataOutputStream;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -319,9 +318,11 @@ public class BundleFsPersistenceManager 
                 itemFs.createFolder(dir);
             }
             OutputStream out = itemFs.getOutputStream(fileName);
-            DataOutputStream dout = new DataOutputStream(out);
-            binding.writeBundle(dout, bundle);
-            dout.close();
+            try {
+                binding.writeBundle(out, bundle);
+            } finally {
+                out.close();
+            }
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
             BundleFsPersistenceManager.log.error(msg, e);

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=1002709&r1=1002708&r2=1002709&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 16:07:11 2010
@@ -20,6 +20,7 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.id.NodeId;
@@ -160,7 +161,7 @@ public class BundleBinding {
      * @param bundle the bundle to serialize
      * @throws IOException if an I/O error occurs.
      */
-    public void writeBundle(DataOutputStream out, NodePropBundle bundle)
+    public void writeBundle(OutputStream out, NodePropBundle bundle)
             throws IOException {
         new BundleWriter(this, out).writeBundle(bundle);
     }



Mime
View raw message