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);
}
}
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);
}
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);
}
Aggregations