db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r569014 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/buffer/ReplicationLogBuffer.java
Date Thu, 23 Aug 2007 14:34:37 GMT
Author: kahatlen
Date: Thu Aug 23 07:34:36 2007
New Revision: 569014

URL: http://svn.apache.org/viewvc?rev=569014&view=rev
Log:
DERBY-2926: Replication: Add a log buffer for log records that should
be shipped to the slave

Simplified code for reallocation of output buffer and prevented
reallocation when the buffer already had the correct size.

Contributed by Jørgen Løland.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/buffer/ReplicationLogBuffer.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/buffer/ReplicationLogBuffer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/buffer/ReplicationLogBuffer.java?rev=569014&r1=569013&r2=569014&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/buffer/ReplicationLogBuffer.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/buffer/ReplicationLogBuffer.java
Thu Aug 23 07:34:36 2007
@@ -223,18 +223,16 @@
                     LogBufferElement current =
                         (LogBufferElement)dirtyBuffers.removeFirst();
 
-                    if (outBufferData.length < current.size()) {
-                        // resize outBufferData if it has too few bytes
-                        outBufferData = new byte[current.size()];
-                    } else if(outBufferData.length != defaultBufferSize) {
-                        // the buffer should be resized to default if it has
-                        // previously been increased
-                        int newSize = defaultBufferSize;
-                        if (current.size() > newSize) {
-                            // can not be smaller than current LogBufferElement
-                            newSize = current.size();
-                        }
-                        outBufferData = new byte[newSize];
+                    // The outBufferData byte[] should have the
+                    // default size or the size of the current
+                    // LogBufferElement if that is bigger than the
+                    // default size.
+                    int requiredOutBufferSize = Math.max(defaultBufferSize,
+                                                         current.size());
+                    if (outBufferData.length != requiredOutBufferSize) {
+                        // The current buffer has a different size
+                        // than what we need it to be, so we resize.
+                        outBufferData = new byte[requiredOutBufferSize];
                     }
 
                     // set the outBuffer data



Mime
View raw message