Search in sources :

Example 11 with Storable

use of org.apache.derby.iapi.services.io.Storable in project derby by apache.

the class TemplateRow method allocate_objects.

/* Private/Protected methods of This class: */
/**
 * Allocate new objects to array based on format id's and column_list.
 * <p>
 *
 * @param num_cols_to_allocate  The number of columns to allocate for array.
 * @param column_list           description of partial set of columns to
 *                              built as described in RowUtil.  If null do
 *                              all the columns.
 * @param format_ids            An array of format ids representing every
 *                              column in the table.  column_list describes
 *                              which of these columns to populate into the
 *                              columns array.
 *
 * @exception  StandardException  Standard exception policy.
 */
private static DataValueDescriptor[] allocate_objects(Transaction rawtran, int num_cols_to_allocate, FormatableBitSet column_list, int[] format_ids, int[] collation_ids) throws StandardException {
    DataValueDescriptor[] ret_row = new DataValueDescriptor[num_cols_to_allocate];
    int num_cols = (column_list == null ? format_ids.length : column_list.size());
    DataValueFactory dvf = rawtran.getDataValueFactory();
    for (int i = 0; i < num_cols; i++) {
        // does caller want this column?
        if ((column_list != null) && (!column_list.get(i))) {
        // no - column should be skipped.
        } else {
            // yes - create the column
            // get empty instance of object identified by the format id.
            ret_row[i] = dvf.getNull(format_ids[i], collation_ids[i]);
            if (SanityManager.DEBUG) {
                DataValueDescriptor o = ret_row[i];
                if (o == null) {
                    SanityManager.THROWASSERT("obj from DataValueFactory.newNull(" + format_ids[i] + ", " + collation_ids[i] + ") null." + ";src column position = " + i + ";dest column position = " + i + ";num_cols = " + num_cols + ";format_ids.length = " + format_ids.length);
                }
                if (!(o instanceof Storable))
                    SanityManager.THROWASSERT("object:(" + o.getClass() + "):(" + o + ") not an instanceof Storable");
            }
        }
    }
    return (ret_row);
}
Also used : DataValueFactory(org.apache.derby.iapi.types.DataValueFactory) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) Storable(org.apache.derby.iapi.services.io.Storable) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Aggregations

Storable (org.apache.derby.iapi.services.io.Storable)11 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)3 StreamStorable (org.apache.derby.iapi.services.io.StreamStorable)2 BufferedInputStream (java.io.BufferedInputStream)1 EOFException (java.io.EOFException)1 Externalizable (java.io.Externalizable)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvalidClassException (java.io.InvalidClassException)1 List (java.util.List)1 DynamicByteArrayOutputStream (org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream)1 FormatIdInputStream (org.apache.derby.iapi.services.io.FormatIdInputStream)1 FormatIdOutputStream (org.apache.derby.iapi.services.io.FormatIdOutputStream)1 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)1 LimitInputStream (org.apache.derby.iapi.services.io.LimitInputStream)1 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)1 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)1 KeyHasher (org.apache.derby.iapi.store.access.KeyHasher)1 Qualifier (org.apache.derby.iapi.store.access.Qualifier)1 DataValueFactory (org.apache.derby.iapi.types.DataValueFactory)1