Author: kristwaa
Date: Thu Nov 27 03:52:29 2008
New Revision: 721162
URL: http://svn.apache.org/viewvc?rev=721162&view=rev
Log:
DERBY-3934: Improve performance of reading modified Clobs.
Added two new methods to InternalClob;
- getUpdateCount
- isReleased
These methods can be used to detect if the contents have been changed, for instance by streams
reading from the internal Clob representation.
Patch file: derby-3934-2a-intclob_new_methods.diff
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/InternalClob.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/InternalClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/InternalClob.java?rev=721162&r1=721161&r2=721162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/InternalClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/InternalClob.java Thu Nov 27
03:52:29 2008
@@ -110,6 +110,16 @@
throws IOException, SQLException;
/**
+ * Returns the update count of the Clob.
+ * <p>
+ * The update count is increased each time a modification of the Clob
+ * content is made.
+ *
+ * @return Update count, starting at zero.
+ */
+ long getUpdateCount();
+
+ /**
* Returns a writer to write data into the Clob.
* <p>
* The semantics of the writer is the same as for {@link #insertString}.
@@ -149,6 +159,20 @@
long insertString(String str, long pos) throws IOException, SQLException;
/**
+ * Tells if the the Clob has been released.
+ * <p>
+ * Depending on the context, a Clob is released either because the internal
+ * representation has been changed, or because the Clob itself has been
+ * closed. The former can happen when a user modifies a stream that is
+ * currently represented as a store stream. The latter can happen if
+ * {@code Clob.free} has been called, or if Derby implicitly closes the
+ * Clob.
+ *
+ * @return {@code true} if released, {@code false} if not.
+ */
+ boolean isReleased();
+
+ /**
* Tells if the Clob representation is intended to be writable.
* <p>
* Note that even if this method returns <code>true</code>, it might not
be
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java?rev=721162&r1=721161&r2=721162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/StoreStreamClob.java Thu Nov
27 03:52:29 2008
@@ -250,6 +250,17 @@
}
/**
+ * Returns the update count of this Clob.
+ * <p>
+ * Always returns zero, as this Clob cannot be updated.
+ *
+ * @return Zero (read-only Clob).
+ */
+ public long getUpdateCount() {
+ return 0L;
+ }
+
+ /**
* Not supported.
*
* @see InternalClob#getWriter
@@ -270,6 +281,15 @@
}
/**
+ * Tells if this Clob has been released.
+ *
+ * @return {@code true} if released, {@code false} if not.
+ */
+ public boolean isReleased() {
+ return released;
+ }
+
+ /**
* Tells if this Clob can be modified.
*
* @return <code>false</code>, this Clob is read-only.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java?rev=721162&r1=721161&r2=721162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/TemporaryClob.java Thu Nov
27 03:52:29 2008
@@ -196,6 +196,15 @@
}
/**
+ * Returns the update count of this Clob.
+ *
+ * @return Update count.
+ */
+ public long getUpdateCount() {
+ return bytes.getUpdateCount();
+ }
+
+ /**
* Constructs and returns a <code>Writer</code> for the CLOB value.
*
* @param pos the initial position in bytes for the <code>Writer</code>
@@ -332,6 +341,15 @@
}
/**
+ * Tells if this Clob has been released.
+ *
+ * @return {@code true} if released, {@code false} if not.
+ */
+ public boolean isReleased() {
+ return released;
+ }
+
+ /**
* Tells if this Clob is intended to be writable.
*
* @return <code>true</code>
|