db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r903150 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/store/access/ iapi/types/ impl/sql/execute/
Date Tue, 26 Jan 2010 09:58:50 GMT
Author: kristwaa
Date: Tue Jan 26 09:58:50 2010
New Revision: 903150

URL: http://svn.apache.org/viewvc?rev=903150&view=rev
Log:
DERBY-4520: Refactor and extend data type cloning facilities 
Renamed cloneObject to cloneHolder.
Restructured SQLBinary.cloneHolder (behavior unchanged).
Brushed up some comments.

Patch file: derby-4520-4a-cloneObject_renamed_cloneHolder.diff


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java?rev=903150&r1=903149&r2=903150&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
Tue Jan 26 09:58:50 2010
@@ -373,12 +373,13 @@
     {
         DataValueDescriptor[] new_row = new DataValueDescriptor[old_row.length];
         // History: We used to *not* materialize streams when getting a clone
-        //          here (i.e. used cloneObject, not getClone). We still do.
+        //          here (i.e. used cloneObject, not getClone).
+        //          We still don't materialize, just clone the holder.
         // DERBY-802
         for (int i = 0; i < old_row.length; i++)
         {
             if( old_row[i] != null)
-                new_row[i] = old_row[i].cloneObject();
+                new_row[i] = old_row[i].cloneHolder();
         }
 
         return(new_row);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java?rev=903150&r1=903149&r2=903150&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java Tue Jan 26 09:58:50
2010
@@ -602,8 +602,7 @@
      *
      * @return A shallow clone.
      */
-    public DataValueDescriptor cloneObject()
-	{
+    public DataValueDescriptor cloneHolder() {
 		return getClone();
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java?rev=903150&r1=903149&r2=903150&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java Tue
Jan 26 09:58:50 2010
@@ -293,7 +293,7 @@
      *
      * @return A clone of this descriptor, which shares the internal state.
      */
-    public DataValueDescriptor cloneObject();
+    public DataValueDescriptor cloneHolder();
 
 	/**
 	 * Clone this DataValueDescriptor. Results in a new object

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=903150&r1=903149&r2=903150&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 Tue Jan 26
09:58:50 2010
@@ -614,18 +614,23 @@
      *
      *  Beetle 4896
      */
-    public final DataValueDescriptor cloneObject() {
-        if ( _blobValue != null )
-        {
-            SQLBinary self = (SQLBinary) getNewNull();
-            self.setValue(_blobValue);
+    public final DataValueDescriptor cloneHolder() {
+        if (stream == null && _blobValue == null) {
+            return getClone();
+        } else {
+            // Cast to SQLBinary to avoid having to catch StandardException.
+            SQLBinary self = (SQLBinary)getNewNull();
+            if (stream != null) {
+                // Just reference the same stream in the cloned holder.
+                self.setValue(stream, streamValueLength);
+            } else if (_blobValue != null) {
+                // Just reference the same BLOB value in the cloned holder.
+                self.setValue(_blobValue);
+            } else {
+                throw new IllegalStateException("unknown BLOB value repr");
+            }
             return self;
         }
-		if (stream == null) { return getClone(); }
-        
-		SQLBinary self = (SQLBinary) getNewNull();
-		self.setValue(stream, streamValueLength);
-		return self;
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=903150&r1=903149&r2=903150&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Tue Jan 26 09:58:50
2010
@@ -1319,10 +1319,9 @@
      *  difference of this method from getClone is this method does not 
      *  objectify a stream.
      */
-    public DataValueDescriptor cloneObject()
-    {
+    public DataValueDescriptor cloneHolder() {
         if ((stream == null) && (_clobValue == null)) {  return getClone(); }
-        
+
         SQLChar self = (SQLChar) getNewNull();
         self.copyState(this);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java?rev=903150&r1=903149&r2=903150&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java
Tue Jan 26 09:58:50 2010
@@ -169,18 +169,25 @@
 		lastArraySlot = -1;
 	}
 
-	/* Avoid materializing a stream just because it goes through a temp table.  It is OK to
-	 * have a stream in the temp table (in memory or spilled to disk).  The assumption is
-	 * that one stream does not appear in two rows.  For "update", one stream can be in two
-	 * rows and the materialization is done in UpdateResultSet.  Note to future users of this
-	 * class who may insert a stream into this temp holder: (1) As mentioned above, one
-	 * un-materialized stream can't appear in two rows; you need to objectify it first otherwise.
-	 * (2) If you need to retrieve a un-materialized stream more than once from the temp holder,
-	 * you need to either materialize the stream the first time, or, if there's a memory constraint,
-	 * in the first time create a RememberBytesInputStream with the byte holder being
-	 * BackingStoreByteHolder, finish it, and reset it after usage.
-	 * beetle 4896.
-	 */
+    /* Avoid materializing a stream just because it goes through a temp table.
+     * It is OK to have a stream in the temp table (in memory or spilled to
+     * disk). The assumption is that one stream does not appear in two rows.
+     * For "update", one stream can be in two rows and the materialization is
+     * done in UpdateResultSet. Note to future users of this class who may
+     * insert a stream into this temp holder:
+     *   (1) As mentioned above, one un-materialized stream can't appear in two
+     *       rows; you need to objectify it first otherwise.
+     *   (2) If you need to retrieve an un-materialized stream more than once
+     *       from the temp holder, you need to either materialize the stream
+     *       the first time, or, if there's a memory constraint, in the first
+     *       time create a RememberBytesInputStream with the byte holder being
+     *       BackingStoreByteHolder, finish it, and reset it after usage.
+     *       A third option is to create a stream clone, but this requires that
+     *       the container handles are kept open until the streams have been
+     *       drained.
+     *
+     * Beetle 4896.
+     */
 	private ExecRow cloneRow(ExecRow inputRow)
 	{
 		DataValueDescriptor[] cols = inputRow.getRowArray();
@@ -191,7 +198,7 @@
 			if (cols[i] != null)
 			{
 				/* Rows are 1-based, cols[] is 0-based */
-                cloned.setColumn(i + 1, cols[i].cloneObject());
+                cloned.setColumn(i + 1, cols[i].cloneHolder());
 			}
 		}
 		if (inputRow instanceof IndexValueRow)



Mime
View raw message