db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r551728 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/execute/ iapi/store/access/ impl/sql/execute/ impl/store/access/btree/ impl/store/access/conglomerate/
Date Thu, 28 Jun 2007 22:44:24 GMT
Author: djd
Date: Thu Jun 28 15:44:23 2007
New Revision: 551728

URL: http://svn.apache.org/viewvc?view=rev&rev=551728
Log:
Cleanp related to the old interface Storable. Now a row is passed around in many cases
as DataValueDescriptor[] hence its contents must be Storable, so no need for casts.
Change BackingStoreHashtable to use DataValueDescriptor[] instead of Object[] to
remove needless casts.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecRow.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregateSortObserver.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexValueRow.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ValueRow.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeForwardScan.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecRow.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecRow.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecRow.java Thu Jun
28 15:44:23 2007
@@ -21,15 +21,9 @@
 
 package org.apache.derby.iapi.sql.execute;
 
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.sql.Row;
-
-import org.apache.derby.iapi.services.io.Storable;
-
 import org.apache.derby.iapi.services.io.FormatableBitSet;
+import org.apache.derby.iapi.sql.Row;
+import org.apache.derby.iapi.types.DataValueDescriptor;
 
 /**
  * Execution sees this extension of Row that provides connectivity
@@ -93,9 +87,6 @@
 	/**
 		Set the array of objects
 	*/
-	public void setRowArray(Storable[] rowArray);
-
-	// temp overload
 	public void setRowArray(DataValueDescriptor[] rowArray);
 
 	/**

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?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- 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
Thu Jun 28 15:44:23 2007
@@ -216,8 +216,6 @@
         this.tc = tc;
         this.keepAfterCommit = keepAfterCommit;
 
-        Object[] row;
-
         // use passed in capacity and loadfactor if not -1, you must specify
         // capacity if you want to specify loadfactor.
         if (initialCapacity != -1)
@@ -266,6 +264,7 @@
         {
             boolean needsToClone = row_source.needsToClone();
 
+            DataValueDescriptor[] row;
             while ((row = getNextRowFromRowSource()) != null)
             {
                 // If we haven't initialized the hash_table yet then that's
@@ -313,10 +312,10 @@
      *
 	 * @exception  StandardException  Standard exception policy.
 	 */
-	private Object[] getNextRowFromRowSource()
+	private DataValueDescriptor[] getNextRowFromRowSource()
 		throws StandardException
 	{
-		Object[] row = row_source.getNextRowFromRowSource();
+		DataValueDescriptor[] row = row_source.getNextRowFromRowSource();
 
 		if (skipNullKeyColumns)
 		{
@@ -326,17 +325,7 @@
 				int index = 0;
 				for ( ; index < key_column_numbers.length; index++)
 				{
-					if (SanityManager.DEBUG)
-					{
-						if (! (row[key_column_numbers[index]] instanceof Storable))
-						{
-							SanityManager.THROWASSERT(
-								"row[key_column_numbers[index]] expected to be Storable, not " +
-								row[key_column_numbers[index]].getClass().getName());
-						}
-					}
-					Storable storable = (Storable) row[key_column_numbers[index]];
-					if (storable.isNull())
+					if (row[key_column_numbers[index]].isNull())
 					{
 						break;
 					}
@@ -360,17 +349,17 @@
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-    static Object[] cloneRow(Object[] old_row)
+    private static DataValueDescriptor[] cloneRow(DataValueDescriptor[] old_row)
         throws StandardException
     {
-        Object[] new_row = new DataValueDescriptor[old_row.length];
+        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.
         for (int i = 0; i < old_row.length; i++)
         {
             if( old_row[i] != null)
-                new_row[i] = ((DataValueDescriptor) old_row[i]).getClone();
+                new_row[i] = old_row[i].getClone();
         }
 
         return(new_row);
@@ -408,7 +397,7 @@
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-    private void add_row_to_hash_table(Object[] row, boolean needsToClone)
+    private void add_row_to_hash_table(DataValueDescriptor[] row, boolean needsToClone)
 		throws StandardException
     {
         if (spillToDisk(row))
@@ -458,7 +447,7 @@
         row = null;
     }
 
-    private void doSpaceAccounting( Object[] row,
+    private void doSpaceAccounting(DataValueDescriptor[] row,
                                     boolean firstDuplicate)
     {
         inmemory_rowcnt++;
@@ -479,7 +468,7 @@
      *
      * @exception  StandardException  Standard exception policy.
      */
-    private boolean spillToDisk(Object[] row) throws StandardException {
+    private boolean spillToDisk(DataValueDescriptor[] row) throws StandardException {
         // Once we have started spilling all new rows will go to disk, even if we have freed
up some
         // memory by moving duplicates to disk. This simplifies handling of duplicates and
accounting.
         if( diskHashtable == null)
@@ -493,17 +482,11 @@
                 
                 return false;
             // Want to start spilling
-            if( ! (row instanceof DataValueDescriptor[]))
-            {
-                if( SanityManager.DEBUG)
-                    SanityManager.THROWASSERT( "BackingStoreHashtable row is not DataValueDescriptor[]");
-                // Do not know how to put it on disk
-                return false;
-            }
+ 
             diskHashtable = 
                 new DiskHashtable(
                        tc,
-                       (DataValueDescriptor[]) row,
+                       row,
                        (int[]) null, //TODO-COLLATION, set non default collation if necessary.
                        key_column_numbers,
                        remove_duplicates,
@@ -522,12 +505,12 @@
                 List duplicateVec = (List) duplicateValue;
                 for( int i = duplicateVec.size() - 1; i >= 0; i--)
                 {
-                    Object[] dupRow = (Object[]) duplicateVec.get(i);
+                    DataValueDescriptor[] dupRow = (DataValueDescriptor[]) duplicateVec.get(i);
                     diskHashtable.put( key, dupRow);
                 }
             }
             else
-                diskHashtable.put( key, (Object []) duplicateValue);
+                diskHashtable.put( key, (DataValueDescriptor[]) duplicateValue);
             hash_table.remove( key);
         }
         diskHashtable.put( key, row);
@@ -542,13 +525,12 @@
      * @return A guess as to how much memory the current row will
      *  use.
      */
-    private long getEstimatedMemUsage(Object [] row)
+    private long getEstimatedMemUsage(DataValueDescriptor[] row)
     {
         long rowMem = 0;
         for( int i = 0; i < row.length; i++)
         {
-            if (row[i] instanceof DataValueDescriptor)
-                rowMem += ((DataValueDescriptor) row[i]).estimateMemoryUsage();
+            rowMem += row[i].estimateMemoryUsage();
             rowMem += ClassSize.refSize;
         }
 
@@ -720,9 +702,9 @@
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-    public boolean put(
+    public boolean putRow(
     boolean     needsToClone,
-    Object[]    row)
+    DataValueDescriptor[]    row)
 		throws StandardException
     {
 		// Are any key columns null?
@@ -731,17 +713,7 @@
 			int index = 0;
 			for ( ; index < key_column_numbers.length; index++)
 			{
-				if (SanityManager.DEBUG)
-				{
-					if (! (row[key_column_numbers[index]] instanceof Storable))
-					{
-						SanityManager.THROWASSERT(
-							"row[key_column_numbers[index]] expected to be Storable, not " +
-							row[key_column_numbers[index]].getClass().getName());
-					}
-				}
-				Storable storable = (Storable) row[key_column_numbers[index]];
-				if (storable.isNull())
+				if (row[key_column_numbers[index]].isNull())
 				{
 					return false;
 				}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregateSortObserver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregateSortObserver.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregateSortObserver.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AggregateSortObserver.java
Thu Jun 28 15:44:23 2007
@@ -21,24 +21,11 @@
 
 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.UserDataValue;
-
-import org.apache.derby.iapi.types.CloneableObject;
-
-import org.apache.derby.iapi.services.io.Storable;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
 import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.execute.ExecRow;
-
 import org.apache.derby.iapi.types.DataValueDescriptor;
-
-
-import java.util.Vector;
+import org.apache.derby.iapi.types.UserDataValue;
 
 /**
  * This sort observer performs aggregation.
@@ -128,7 +115,7 @@
 		** initialized, then initialize the entire row now.	
 		*/
 		if (aggsToInitialize.length > 0 &&
-			((Storable)returnRow[firstAggregatorColumn]).isNull())
+			returnRow[firstAggregatorColumn].isNull())
 		{
 			for (int i = 0; i < aggsToInitialize.length; i++)
 			{
@@ -182,7 +169,7 @@
 		for (int i = 0; i < aggsToProcess.length; i++)
 		{
 			GenericAggregator aggregator = aggsToProcess[i];
-			if (((Storable)insertRow[aggregator.getColumnId()]).isNull())
+			if (insertRow[aggregator.getColumnId()].isNull())
 			{
 				aggregator.accumulate(insertRow, existingRow);
 			}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
Thu Jun 28 15:44:23 2007
@@ -456,25 +456,6 @@
 
 				if (columns != null)
 				{
-					if (SanityManager.DEBUG)
-					{
-						// There used to be an assertion here that the columns
-						// array was the same size as the number of columns
-						// in the compact row. This assertion no longer holds
-						// now that we're doing sparse rows, so I deleted it.
-
-						// Columns is really a Storable[]
-						for (int i = 0; i < columns.length; i++)
-						{
-							if (columns[i] != null &&
-								! (columns[i] instanceof Storable))
-							{
-								SanityManager.THROWASSERT(
-								"columns[" + i + "] expected to be Storable, not " +
-								columns[i].getClass().getName());
-							}
-						}
-					}
 
 					// See if the entry satisfies all of the other qualifiers
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexValueRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexValueRow.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexValueRow.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexValueRow.java Thu
Jun 28 15:44:23 2007
@@ -63,10 +63,6 @@
 	{
 		valueRow.setRowArray(value);
 	}
-	public void setRowArray(Storable[] value) 
-	{
-		valueRow.setRowArray(value);
-	}
 
 	/**
 		Get a clone of the array form of the row that Access expects.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
Thu Jun 28 15:44:23 2007
@@ -989,7 +989,7 @@
 		System.arraycopy(sourceRowArray, 0, hashRowArray, extraColumns, 
 				sourceRowArray.length);
 
-		ht.put(true, hashRowArray);
+		ht.putRow(true, hashRowArray);
 
 		numToHashTable++;
 	}
@@ -1158,7 +1158,7 @@
 			hashRowArray[i].setToNull();
 		}
 
-		ht.put(true, hashRowArray);
+		ht.putRow(true, hashRowArray);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ValueRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ValueRow.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ValueRow.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ValueRow.java Thu Jun
28 15:44:23 2007
@@ -274,19 +274,6 @@
 	{
 		column = value;
 	}
-
-	public void setRowArray(Storable[] value) {
-		if (value instanceof DataValueDescriptor[]) {
-			column = (DataValueDescriptor[]) value;
-			return;
-		}
-
-		if ((column == null) || (column.length != value.length))
-			column = new DataValueDescriptor[value.length];
-
-
-		System.arraycopy(value, 0, column, 0, column.length);
-	}
 		
 	// Set the number of columns in the row to ncols, preserving
 	// the existing contents.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeForwardScan.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeForwardScan.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeForwardScan.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeForwardScan.java
Thu Jun 28 15:44:23 2007
@@ -448,7 +448,7 @@
 
                     if (hash_table != null)
                     {
-                        if (hash_table.put(false, fetch_row))
+                        if (hash_table.putRow(false, fetch_row))
                             fetch_row = null;
                     }
                     else

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java?view=diff&rev=551728&r1=551727&r2=551728
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
Thu Jun 28 15:44:23 2007
@@ -800,7 +800,7 @@
                     }
                     else
                     {
-                        if (hash_table.put(false, fetch_row))
+                        if (hash_table.putRow(false, fetch_row))
                         {
                             // The row was inserted into the hash table so we
                             // need to create a new row next time through.



Mime
View raw message