Search in sources :

Example 6 with FormatableArrayHolder

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

the class ColumnInfo method readExternal.

// Formatable methods
/**
 * Read this object from a stream of stored objects.
 *
 * @param in read this.
 *
 * @exception IOException					thrown on error
 * @exception ClassNotFoundException		thrown on error
 */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    FormatableLongHolder flh;
    FormatableHashtable fh = (FormatableHashtable) in.readObject();
    name = (String) fh.get("name");
    dataType = (DataTypeDescriptor) fh.get("dataType");
    defaultValue = (DataValueDescriptor) fh.get("defaultValue");
    defaultInfo = (DefaultInfo) fh.get("defaultInfo");
    newDefaultUUID = (UUID) fh.get("newDefaultUUID");
    oldDefaultUUID = (UUID) fh.get("oldDefaultUUID");
    action = fh.getInt("action");
    if (fh.get("autoincStart") != null) {
        autoincStart = fh.getLong("autoincStart");
        autoincInc = fh.getLong("autoincInc");
    } else {
        autoincInc = autoincStart = 0;
    }
    FormatableArrayHolder fah = (FormatableArrayHolder) fh.get("providers");
    if (fah != null) {
        providers = fah.getArray(ProviderInfo[].class);
    }
}
Also used : FormatableHashtable(org.apache.derby.iapi.services.io.FormatableHashtable) FormatableArrayHolder(org.apache.derby.iapi.services.io.FormatableArrayHolder) FormatableLongHolder(org.apache.derby.iapi.services.io.FormatableLongHolder)

Example 7 with FormatableArrayHolder

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

the class ExpressionClassBuilder method getColumnOrdering.

// /////////////////////////////////////////////////////////////////////
// 
// COLUMN ORDERING
// 
// /////////////////////////////////////////////////////////////////////
/**
 *		These utility methods buffers compilation from the IndexColumnOrder
 *		class.
 *
 *		They create an ordering based on their parameter, stuff that into
 *		the prepared statement, and then return the entry # for
 *		use in the generated code.
 *
 *		We could write another utility method to generate code to
 *		turn an entry # back into an object, but so far no-one needs it.
 *
 *		WARNING: this is a crafty method that ASSUMES that
 *		you want every column in the list ordered, and that every
 *		column in the list is the entire actual result colunm.
 *		It is only useful for DISTINCT in select.
 */
FormatableArrayHolder getColumnOrdering(ResultColumnList rclist) {
    IndexColumnOrder[] ordering;
    int numCols = (rclist == null) ? 0 : rclist.size();
    // skip the columns which are not exclusively part of the insert list
    // ie columns with default and autoincrement. These columns will not
    // be part of ordering.
    int numRealCols = 0;
    for (int i = 0; i < numCols; i++) {
        if (!(rclist.getResultColumn(i + 1).isGeneratedForUnmatchedColumnInInsert()))
            numRealCols++;
    }
    ordering = new IndexColumnOrder[numRealCols];
    for (int i = 0, j = 0; i < numCols; i++) {
        if (!(rclist.getResultColumn(i + 1).isGeneratedForUnmatchedColumnInInsert())) {
            ordering[j] = new IndexColumnOrder(i);
            j++;
        }
    }
    return new FormatableArrayHolder(ordering);
}
Also used : FormatableArrayHolder(org.apache.derby.iapi.services.io.FormatableArrayHolder) IndexColumnOrder(org.apache.derby.impl.sql.execute.IndexColumnOrder)

Example 8 with FormatableArrayHolder

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

the class ExpressionClassBuilder method addColumnToOrdering.

/**
 * Add a column to the existing Ordering list.  Takes
 * a column id and only adds it if it isn't in the list.
 *
 * @return the ColumnOrdering array
 */
FormatableArrayHolder addColumnToOrdering(FormatableArrayHolder orderingHolder, int columnNum) {
    /*
		** We don't expect a lot of order by columns, so
		** linear search.
		*/
    ColumnOrdering[] ordering = orderingHolder.getArray(ColumnOrdering[].class);
    int length = ordering.length;
    for (int i = 0; i < length; i++) {
        if (ordering[i].getColumnId() == columnNum)
            return orderingHolder;
    }
    /*
		** Didn't find it.  Allocate a bigger array
		** and add it to the end
		*/
    IndexColumnOrder[] newOrdering = new IndexColumnOrder[length + 1];
    System.arraycopy(ordering, 0, newOrdering, 0, length);
    newOrdering[length] = new IndexColumnOrder(columnNum);
    return new FormatableArrayHolder(newOrdering);
}
Also used : FormatableArrayHolder(org.apache.derby.iapi.services.io.FormatableArrayHolder) ColumnOrdering(org.apache.derby.iapi.store.access.ColumnOrdering) IndexColumnOrder(org.apache.derby.impl.sql.execute.IndexColumnOrder)

Aggregations

FormatableArrayHolder (org.apache.derby.iapi.services.io.FormatableArrayHolder)8 FormatableIntHolder (org.apache.derby.iapi.services.io.FormatableIntHolder)3 FormatableHashtable (org.apache.derby.iapi.services.io.FormatableHashtable)2 ColumnOrdering (org.apache.derby.iapi.store.access.ColumnOrdering)2 IndexColumnOrder (org.apache.derby.impl.sql.execute.IndexColumnOrder)2 ReferencedColumnsDescriptorImpl (org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl)1 MethodBuilder (org.apache.derby.iapi.services.compiler.MethodBuilder)1 FormatableLongHolder (org.apache.derby.iapi.services.io.FormatableLongHolder)1 CostEstimate (org.apache.derby.iapi.sql.compile.CostEstimate)1 JoinStrategy (org.apache.derby.iapi.sql.compile.JoinStrategy)1 OptimizablePredicate (org.apache.derby.iapi.sql.compile.OptimizablePredicate)1 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)1 StaticCompiledOpenConglomInfo (org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo)1