db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r902050 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/store/access/ engine/org/apache/derby/iapi/types/ engine/org/apache/derby/impl/sql/execute/ engine/org/apache/derby/impl/store/access/sort/ testing/org/apache/derbyTesting...
Date Fri, 22 Jan 2010 10:31:28 GMT
Author: kristwaa
Date: Fri Jan 22 10:31:27 2010
New Revision: 902050

URL: http://svn.apache.org/viewvc?rev=902050&view=rev
Log:
DERBY-4520 (partial): Refactor and extend data type cloning facilities
Moved the method cloneObject into DataValueDescriptor, removed the
CloneableObject interface.
Changed cloneObject return type from Object to DataValueDescriptor.
Removed some unused imports.
Rewrote a few comments.

Patch file: derby-4520-2a-remove_CloneableObject_iface.diff


Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CloneableObject.java
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/BasicSortObserver.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TemporaryRowHolderImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_AccessRow.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=902050&r1=902049&r2=902050&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
Fri Jan 22 10:31:27 2010
@@ -21,13 +21,8 @@
 
 package org.apache.derby.iapi.store.access;
 
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.services.io.Storable;
-
 import org.apache.derby.iapi.error.StandardException; 
 
-import org.apache.derby.iapi.types.CloneableObject;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
 import org.apache.derby.iapi.services.cache.ClassSize;
@@ -354,8 +349,9 @@
     {
         DataValueDescriptor[] new_row = new DataValueDescriptor[old_row.length];
 
-		// the only difference between getClone and cloneObject is cloneObject does
-		// not objectify a stream.  We use getClone here.  Beetle 4896.
+        // History: We used to materialize streams when getting a clone
+        //          here (i.e. used getClone, not cloneObject). We still do.
+        // Beetle 4896.
         for (int i = 0; i < old_row.length; i++)
         {
             if( old_row[i] != null)
@@ -376,13 +372,13 @@
         throws StandardException
     {
         DataValueDescriptor[] new_row = new DataValueDescriptor[old_row.length];
-        // the only difference between getClone and cloneObject is cloneObject does
-        // not objectify a stream.  We use cloneObject here.  DERBY-802
+        // History: We used to *not* materialize streams when getting a clone
+        //          here (i.e. used cloneObject, not getClone). We still do.
+        // DERBY-802
         for (int i = 0; i < old_row.length; i++)
         {
             if( old_row[i] != null)
-                new_row[i] = (DataValueDescriptor) 
-                    ((CloneableObject) old_row[i]).cloneObject();
+                new_row[i] = old_row[i].cloneObject();
         }
 
         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=902050&r1=902049&r2=902050&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 Fri Jan 22 10:31:27
2010
@@ -24,7 +24,6 @@
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.BooleanDataValue;
-import org.apache.derby.iapi.types.CloneableObject;
 import org.apache.derby.iapi.types.Orderable;
 
 import org.apache.derby.iapi.reference.SQLState;
@@ -35,7 +34,6 @@
 import org.apache.derby.iapi.services.i18n.LocaleFinder;
 
 import java.io.InputStream;
-import java.lang.Comparable;
 import java.sql.Date;
 import java.sql.Time;
 import java.sql.Timestamp;
@@ -65,7 +63,7 @@
  *
  */
 public abstract class DataType
-	implements DataValueDescriptor, CloneableObject, Comparable
+    implements DataValueDescriptor, Comparable
 {
 	/*
 	 * DataValueDescriptor Interface
@@ -593,12 +591,18 @@
 		throwLangSetMismatch(theValue);
 	}
 
-	/**
-	 * From CloneableObject
-	 *
-	 * @return clone of me as an Object
-	 */
-	public Object cloneObject()
+    /**
+     * Default implementation of shallow cloning, which forwards to the deep
+     * clone method.
+     * <p>
+     * For many of the data types, a shallow clone will be the same as a deep
+     * clone. The data types requiring special handling of shallow clones have
+     * to override this method (for instance types whose value can be
+     * represented as a stream).
+     *
+     * @return A shallow clone.
+     */
+    public DataValueDescriptor cloneObject()
 	{
 		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=902050&r1=902049&r2=902050&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 Fri
Jan 22 10:31:27 2010
@@ -284,6 +284,17 @@
 	 */
 	InputStream	getStream() throws StandardException;
 
+    /**
+     * Get a shallow copy of this <code>DataValueDescriptor</code>.
+     * <p>
+     * This is used by the sorter to clone columns. It should be cloning the
+     * column holder but not its value. The only difference between this method
+     * and <code>getClone</code> is this one does not objectify a stream.
+     *
+     * @return A clone of this descriptor, which shares the internal state.
+     */
+    public DataValueDescriptor cloneObject();
+
 	/**
 	 * Clone this DataValueDescriptor. Results in a new object
 	 * that has the same value as this but can be modified independently.

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=902050&r1=902049&r2=902050&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 Fri Jan 22
10:31:27 2010
@@ -608,17 +608,13 @@
 		return SQLBinary.compare(getBytes(), other.getBytes());
 	}
 
-	/*
-	 * CloneableObject interface
-	 */
-
-	/** From CloneableObject
-	 *	Shallow clone a StreamStorable without objectifying.  This is used to avoid
-	 *	unnecessary objectifying of a stream object.  The only difference of this method
-	 *  from getClone is this method does not objectify a stream.  beetle 4896
-	 */
-	public final Object cloneObject()
-	{
+    /**
+     * Shallow clone a StreamStorable without objectifying.
+     * This is used to avoid unnecessary objectifying of a stream object.
+     *
+     *  Beetle 4896
+     */
+    public final DataValueDescriptor cloneObject() {
         if ( _blobValue != null )
         {
             SQLBinary self = (SQLBinary) getNewNull();

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=902050&r1=902049&r2=902050&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 Fri Jan 22 10:31:27
2010
@@ -1313,13 +1313,13 @@
      * CloneableObject interface
      */
 
-    /** From CloneableObject
+    /**
      *  Shallow clone a StreamStorable without objectifying.  This is used to 
      *  avoid unnecessary objectifying of a stream object.  The only 
      *  difference of this method from getClone is this method does not 
      *  objectify a stream.
      */
-    public Object cloneObject()
+    public DataValueDescriptor cloneObject()
     {
         if ((stream == null) && (_clobValue == null)) {  return getClone(); }
         

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicSortObserver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicSortObserver.java?rev=902050&r1=902049&r2=902050&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicSortObserver.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BasicSortObserver.java
Fri Jan 22 10:31:27 2010
@@ -22,11 +22,6 @@
 package org.apache.derby.impl.sql.execute;
 
 import org.apache.derby.iapi.store.access.SortObserver;
-import org.apache.derby.iapi.services.io.Storable;
-
-import org.apache.derby.iapi.types.CloneableObject;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.error.StandardException;
 
@@ -166,8 +161,9 @@
 		DataValueDescriptor[] newArray = new DataValueDescriptor[origArray.length];
 		for (int i = 0; i < origArray.length; i++)
 		{
-			// the only difference between getClone and cloneObject is cloneObject does
-			// not objectify a stream.  We use getClone here.  Beetle 4896.
+            // History: We used to materialize streams when getting a clone
+            //          here (i.e. used getClone, not cloneObject). We still do.
+            // Beetle 4896.
 			newArray[i] = origArray[i].getClone();
 		}
 

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=902050&r1=902049&r2=902050&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
Fri Jan 22 10:31:27 2010
@@ -25,22 +25,18 @@
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.sql.execute.CursorResultSet;
 import org.apache.derby.iapi.sql.execute.ExecRow;
-import org.apache.derby.iapi.sql.execute.ExecutionFactory;
 import org.apache.derby.iapi.sql.execute.TemporaryRowHolder;
 import org.apache.derby.iapi.sql.Activation;
-import org.apache.derby.iapi.sql.ResultDescription;
 import org.apache.derby.iapi.store.access.ConglomerateController;
 import org.apache.derby.iapi.store.access.ScanController;
 import org.apache.derby.iapi.store.access.TransactionController;
 
-import org.apache.derby.iapi.types.CloneableObject;
 import org.apache.derby.iapi.types.RowLocation;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.SQLRef;
 import org.apache.derby.iapi.types.SQLLongint;
 
 
-import org.apache.derby.iapi.services.io.FormatableBitSet;
 import java.util.Properties;
 
 /**
@@ -195,7 +191,7 @@
 			if (cols[i] != null)
 			{
 				/* Rows are 1-based, cols[] is 0-based */
-				cloned.setColumn(i + 1, (DataValueDescriptor)((CloneableObject) cols[i]).cloneObject());
+                cloned.setColumn(i + 1, cols[i].cloneObject());
 			}
 		}
 		if (inputRow instanceof IndexValueRow)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java?rev=902050&r1=902049&r2=902050&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
Fri Jan 22 10:31:27 2010
@@ -30,7 +30,6 @@
 import org.apache.derby.iapi.store.access.conglomerate.ScanControllerRowSource;
 import org.apache.derby.iapi.store.access.conglomerate.Sort;
 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
-import org.apache.derby.iapi.types.CloneableObject;
 import org.apache.derby.iapi.store.access.ColumnOrdering;
 import org.apache.derby.iapi.store.access.RowUtil;
 import org.apache.derby.iapi.store.access.ScanController;
@@ -459,13 +458,6 @@
 						"col[" + colid + "]  is null");
 				}
 						
-                if (!(col1 instanceof CloneableObject))
-				{
-					SanityManager.THROWASSERT(
-						"col[" + colid + "] (" +col1.getClass().getName()+
-						") is not a CloneableObject.");
-				}
-
                 if (col1.getClass() != col2.getClass())
                 {
                     SanityManager.THROWASSERT(

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_AccessRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_AccessRow.java?rev=902050&r1=902049&r2=902050&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_AccessRow.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_AccessRow.java
Fri Jan 22 10:31:27 2010
@@ -27,8 +27,6 @@
 
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
-import org.apache.derby.iapi.types.CloneableObject;
-
 import org.apache.derby.iapi.types.SQLInteger;
 
 import org.apache.derby.iapi.error.StandardException;



Mime
View raw message