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 mi...@apache.org on 2007/04/18 02:19:36 UTC

svn commit: r529815 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/store/access/RowUtil.java impl/store/access/conglomerate/OpenConglomerateScratchSpace.java impl/store/access/conglomerate/TemplateRow.java

Author: mikem
Date: Tue Apr 17 17:19:35 2007
New Revision: 529815

URL: http://svn.apache.org/viewvc?view=rev&rev=529815
Log:
DERBY-2537
This checkin changes the way store allocates new objects.  It changes all
allocations to be based off of DataValueDescriptor.getNewNull() and removes
direct use of InstanceGettor and direct use of getClass.newInstance().  This
checkin is in preparation for using the new DataFactory routines to allocate
correct collation based objects.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowUtil.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerateScratchSpace.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/TemplateRow.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowUtil.java?view=diff&rev=529815&r1=529814&r2=529815
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/RowUtil.java Tue Apr 17 17:19:35 2007
@@ -29,7 +29,6 @@
 import org.apache.derby.iapi.services.io.Storable;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
-import org.apache.derby.iapi.services.loader.InstanceGetter;
 
 import org.apache.derby.iapi.store.raw.FetchDescriptor;
 
@@ -343,10 +342,10 @@
      */
 
     /**
-     * Generate a row of InstanceGetter objects to be used to generate  "empty" rows.
+     * Generate a template row of DataValueDescriptor's
      * <p>
-     * Generate an array of InstanceGetter objects which will be used to make
-     * repeated calls to newRowFromClassInfoTemplate(), to repeatedly and
+     * Generate an array of DataValueDescriptor objects which will be used to 
+     * make calls to newRowFromClassInfoTemplate(), to repeatedly and
      * efficiently generate new rows.  This is important for certain 
      * applications like the sorter and fetchSet which generate large numbers
      * of "new" empty rows.
@@ -354,17 +353,18 @@
      *
 	 * @return The new row.
      *
-     * @param format_ids an array of format id's, one per column in row.
+     * @param column_list A bit set indicating which columns to include in row.
+     * @param format_ids  an array of format id's, one per column in row.
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-    public static InstanceGetter[] newClassInfoTemplate(
+    public static DataValueDescriptor[] newTemplate(
     FormatableBitSet column_list,
-    int[]    format_ids) 
+    int[]            format_ids) 
         throws StandardException
     {
-        int         num_cols = format_ids.length;
-        InstanceGetter[] ret_row  = new InstanceGetter[num_cols];
+        int                   num_cols = format_ids.length;
+        DataValueDescriptor[] ret_row  = new DataValueDescriptor[num_cols];
 
 		int column_listSize = 
             (column_list == null) ? 0 : column_list.getLength();
@@ -384,7 +384,8 @@
 
                 // get empty instance of object identified by the format id.
 
-                ret_row[i] = Monitor.classFromIdentifier(format_ids[i]);
+                ret_row[i] = (DataValueDescriptor) 
+                    Monitor.newInstanceFromIdentifier(format_ids[i]);
             }
         }
 
@@ -400,57 +401,38 @@
     }
 
     /**
-     * Generate an "empty" row from an array of classInfo objects.
+     * Generate an "empty" row from an array of DataValueDescriptor objects.
      * <p>
-     * Generate an array of new'd objects by using the getNewInstance()
-     * method on each of the InstanceGetter objects.  It is more
-     * efficient to allocate new objects based on this "cache'd"
-     * InstanceGetter object than to call the Monitor to generate a new class
-     * from a format id.
+     * Generate an array of new'd objects by using the getNewNull()
+     * method on each of the DataValueDescriptor objects.  
      * <p>
      *
 	 * @return The new row.
      *
-     * @param classinfo_template   An array of InstanceGetter objects each of 
-     *                             which can be used to create a new instance 
-     *                             of the appropriate type to build a new empty
-     *                             template row.
+     * @param  template            An array of DataValueDescriptor objects 
+     *                             each of which can be used to create a new 
+     *                             instance of the appropriate type to build a 
+     *                             new empty template row.
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-    public static DataValueDescriptor[] newRowFromClassInfoTemplate(
-    InstanceGetter[]    classinfo_template) 
+    public static DataValueDescriptor[] newRowFromTemplate(
+    DataValueDescriptor[]    template) 
         throws StandardException
     {
 
         DataValueDescriptor[] columns = 
-            new DataValueDescriptor[classinfo_template.length];
+            new DataValueDescriptor[template.length];
 
-        try
+        
+        for (int column_index = template.length; column_index-- > 0;)
         {
-            for (int column_index = classinfo_template.length; 
-                 column_index-- > 0;)
+            if (template[column_index] != null)
             {
-                if (classinfo_template[column_index] != null)
-                {
-                    // get empty instance of DataValueDescriptor identified by 
-                    // the format id.
-                    columns[column_index] = (DataValueDescriptor) 
-                        classinfo_template[column_index].getNewInstance();
-                }
+                // get empty instance of DataValueDescriptor identified by 
+                // the format id.
+                columns[column_index] = template[column_index].getNewNull();
             }
-        }
-        catch (InstantiationException ie)
-        {
-            newRowFromClassInfoTemplateError();
-        }
-        catch (IllegalAccessException iae)
-        {
-            newRowFromClassInfoTemplateError();
-        }
-        catch (InvocationTargetException ite)
-        {
-            newRowFromClassInfoTemplateError();
         }
 
 		return columns;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerateScratchSpace.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerateScratchSpace.java?view=diff&rev=529815&r1=529814&r2=529815
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerateScratchSpace.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerateScratchSpace.java Tue Apr 17 17:19:35 2007
@@ -54,20 +54,20 @@
      * create new rows for export from this class.  This variable is for
      * use by get_row_for_export().
      **/
-    private FormatableBitSet     row_for_export_column_list;
-    private InstanceGetter[] row_for_export_class_template;
+    private FormatableBitSet        row_for_export_column_list;
+    private DataValueDescriptor[]   row_for_export_template;
 
     /**
      * A Scratch template used for searching and qualifying rows in the 
-     * conglomerate.  This is a full template, independent of the FormatableBitSet
-     * used for access.
+     * conglomerate.  This is a full template, independent of the 
+     * FormatableBitSet used for access.
      **/
     private DataValueDescriptor[] scratch_template;
 
     /**
      * A Scratch row used for qualifying rows in the 
-     * conglomerate.  This is a row which matches the FormatableBitSet of rows being
-     * returned.
+     * conglomerate.  This is a row which matches the FormatableBitSet of rows
+     * being returned.
      **/
     private DataValueDescriptor[] scratch_row;
 
@@ -113,16 +113,14 @@
     {
         // Create a partial row class template template from the initial scan
         // parameters.
-        if (row_for_export_class_template == null)
+        if (row_for_export_template == null)
         {
-            row_for_export_class_template = 
-                RowUtil.newClassInfoTemplate(
-                    row_for_export_column_list, format_ids);
+            row_for_export_template = 
+                RowUtil.newTemplate(row_for_export_column_list, format_ids);
         }
 
         // Allocate a new row based on the class template.
-        return(
-            RowUtil.newRowFromClassInfoTemplate(row_for_export_class_template));
+        return(RowUtil.newRowFromTemplate(row_for_export_template));
     }
 
     /**
@@ -170,7 +168,8 @@
         // Create a partial row class template from the initial scan parameters.
         if (scratch_template == null)
         {
-            scratch_template = TemplateRow.newRow((FormatableBitSet) null, format_ids);
+            scratch_template = 
+                TemplateRow.newRow((FormatableBitSet) null, format_ids);
         }
 
         return(scratch_template);
@@ -184,7 +183,7 @@
     public void init(
     FormatableBitSet export_column_list)
     {
-        row_for_export_class_template = null;
+        row_for_export_template       = null;
         row_for_export_column_list    = null;
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/TemplateRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/TemplateRow.java?view=diff&rev=529815&r1=529814&r2=529815
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/TemplateRow.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/TemplateRow.java Tue Apr 17 17:19:35 2007
@@ -162,23 +162,10 @@
         DataValueDescriptor[] columns = 
             new DataValueDescriptor[template.length];
 
-        try
+        for (int i = template.length; i-- > 0 ;)
         {
-            for (int i = template.length; i-- > 0 ;)
-            {
-                // get empty instance of object identified by the format id.
-                columns[i] = 
-                    (DataValueDescriptor) template[i].getClass().newInstance();
-            }
-        }
-        catch (Throwable t)
-        {
-            // RESOLVE - Dan is investigating ways to change the monitor
-            // so that it provides the functionality required here, when
-            // that happens I will just all the monitor and let any 
-            // StandardError that come back just go on up.
-            throw(StandardException.newException(
-                    SQLState.CONGLOMERATE_TEMPLATE_CREATE_ERROR));
+            // get empty instance of object identified by the format id.
+            columns[i] = template[i].getNewNull();
         }
 
 		return columns;
@@ -329,7 +316,7 @@
      **/
 	static public boolean checkPartialColumnTypes(
     int[]                   format_ids, 
-    FormatableBitSet                 validColumns,
+    FormatableBitSet        validColumns,
     int[]                   fieldStates,
     DataValueDescriptor[]   row)
 		throws StandardException