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 2008/10/22 17:18:09 UTC
svn commit: r707097 - in
/db/derby/code/trunk/java/engine/org/apache/derby/impl:
jdbc/LOBStoredProcedure.java sql/catalog/DataDictionaryImpl.java
Author: kristwaa
Date: Wed Oct 22 08:18:08 2008
New Revision: 707097
URL: http://svn.apache.org/viewvc?rev=707097&view=rev
Log:
DERBY-3769: Make LOBStoredProcedure on the server side smarter about the read buffer size.
Adjusts the maximum return size in characters for the CLOB stored procedure to 10890 (DB2_VARCHAR_MAXWIDTH / 3). This potentially results in anything from 10890 to 10890*3 bytes to be returned to the client in one round-trip, depending on the bytes per char ratio (determined by the modified UTF8 encoding).
This fix is sub-optimal for Clobs with ASCII contents, but improves performance for Clobs with contents requiring 2 or 3 bytes per char dramatically.
Patch file: derby-3769-2b-clob_buffer_size_adjustment.diff
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java?rev=707097&r1=707096&r2=707097&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java Wed Oct 22 08:18:08 2008
@@ -37,13 +37,28 @@
public class LOBStoredProcedure {
/**
- * The maximum length of the data returned from the LOB stored procedures.
+ * The maximum length of the data returned from the BLOB stored procedures.
* <p>
* This value is currently dictated by the maximum length of
* VARCHAR/VARBINARY, because these are the return types of the stored
* procedures.
*/
- public static final int MAX_RETURN_LENGTH = Limits.DB2_VARCHAR_MAXWIDTH;
+ public static final int MAX_BLOB_RETURN_LEN = Limits.DB2_VARCHAR_MAXWIDTH;
+
+ /**
+ * The maximum length of the data returned from the CLOB stored procedures.
+ * <p>
+ * This value is currently dictated by the maximum length of
+ * VARCHAR/VARBINARY, because these are the return types of the stored
+ * procedures, and the modified UTF8 encoding used for CLOB data. This
+ * threshold value could be higher (equal to {@code MAX_BLOB_RETURN_LEN}),
+ * but then the procedure fetching data from the CLOB must be rewritten to
+ * have more logic.
+ * <p>
+ * For now we use the defensive assumption that all characters are
+ * represented by three bytes.
+ */
+ public static final int MAX_CLOB_RETURN_LEN = MAX_BLOB_RETURN_LEN / 3;
/**
* Creates a new empty Clob and registers it in the HashMap in the
@@ -148,7 +163,7 @@
* the substring begins.
* @param len an integer representing the maximum length of the substring.
* The value will be reduced to the maximum allowed return length if
- * required (see {@link #MAX_RETURN_LENGTH}).
+ * required (see {@link #MAX_CLOB_RETURN_LEN}).
* @return A substring from the {@code Clob} starting at the given position,
* not longer than {@code len} characters.
* @throws SQLException
@@ -157,7 +172,7 @@
long pos, int len) throws SQLException {
// Don't read more than what we can represent as a VARCHAR.
// See DERBY-3769.
- len = Math.min(len, MAX_RETURN_LENGTH);
+ len = Math.min(len, MAX_CLOB_RETURN_LEN);
return getClobObjectCorrespondingtoLOCATOR(LOCATOR).getSubString(pos, len);
}
@@ -303,7 +318,7 @@
* needs to be retrieved.
* @param len the maximum number of bytes to read. The value will be
* reduced to the maximum allowed return length if required
- * (see {@link #MAX_RETURN_LENGTH}).
+ * (see {@link #MAX_BLOB_RETURN_LEN}).
* @param pos the position from which the bytes from the Blob need to be
* retrieved.
* @return A byte array containing the bytes read, starting from position
@@ -315,7 +330,7 @@
throws SQLException {
// Don't read more than what we can represent as a VARBINARY.
// See DERBY-3769.
- len = Math.min(len, MAX_RETURN_LENGTH);
+ len = Math.min(len, MAX_BLOB_RETURN_LEN);
return getBlobObjectCorrespondingtoLOCATOR(LOCATOR).getBytes(pos, len);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=707097&r1=707096&r2=707097&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Wed Oct 22 08:18:08 2008
@@ -11078,7 +11078,7 @@
false,
DataTypeDescriptor.getCatalogType(
Types.VARCHAR,
- LOBStoredProcedure.MAX_RETURN_LENGTH),
+ LOBStoredProcedure.MAX_CLOB_RETURN_LEN),
tc,
"org.apache.derby.impl.jdbc.LOBStoredProcedure");
}
@@ -11266,7 +11266,7 @@
false,
DataTypeDescriptor.getCatalogType(
Types.VARBINARY,
- LOBStoredProcedure.MAX_RETURN_LENGTH),
+ LOBStoredProcedure.MAX_BLOB_RETURN_LEN),
tc,
"org.apache.derby.impl.jdbc.LOBStoredProcedure");
}