You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2010/06/17 17:22:49 UTC

svn commit: r955634 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java

Author: kristwaa
Date: Thu Jun 17 15:22:49 2010
New Revision: 955634

URL: http://svn.apache.org/viewvc?rev=955634&view=rev
Log:
DERBY-4686: SQLBinary.writeBlob is inefficient, reading one byte at a time from the source BLOB

Reduce buffer size if the BLOB value is smaller than the default buffer size.

Patch contributed by Yun Lee (yun dot lee dot bj at gmail dot com).

Patch file: DERBY-4686-2.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java?rev=955634&r1=955633&r2=955634&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java Thu Jun 17 15:22:49 2010
@@ -374,7 +374,7 @@ abstract class SQLBinary
             
             int bytesRead = 0;
             int numOfBytes = 0;
-            byte[] buffer = new byte[LEN_OF_BUFFER_TO_WRITE_BLOB];
+            byte[] buffer = new byte[Math.min(len, LEN_OF_BUFFER_TO_WRITE_BLOB)];
             
             while(bytesRead < len) {
                 numOfBytes = is.read(buffer);