Search in sources :

Example 6 with IndexDescriptor

use of org.apache.derby.catalog.IndexDescriptor in project derby by apache.

the class SYSCONGLOMERATESRowFactory method makeRow.

/**
 * Make a SYSCONGLOMERATES row
 *
 * @return	Row suitable for inserting into SYSCONGLOMERATES.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    ExecRow row;
    DataValueDescriptor col;
    String tabID = null;
    Long conglomNumber = null;
    String conglomName = null;
    Boolean supportsIndex = null;
    IndexRowGenerator indexRowGenerator = null;
    Boolean supportsConstraint = null;
    String conglomUUIDString = null;
    String schemaID = null;
    ConglomerateDescriptor conglomerate = (ConglomerateDescriptor) td;
    if (td != null) {
        /* Sometimes the SchemaDescriptor is non-null and sometimes it
			 * is null.  (We can't just rely on getting the schema id from 
			 * the ConglomerateDescriptor because it can be null when
			 * we are creating a new conglomerate.
			 */
        if (parent != null) {
            SchemaDescriptor sd = (SchemaDescriptor) parent;
            schemaID = sd.getUUID().toString();
        } else {
            schemaID = conglomerate.getSchemaID().toString();
        }
        tabID = conglomerate.getTableID().toString();
        conglomNumber = conglomerate.getConglomerateNumber();
        conglomName = conglomerate.getConglomerateName();
        conglomUUIDString = conglomerate.getUUID().toString();
        supportsIndex = conglomerate.isIndex();
        indexRowGenerator = conglomerate.getIndexDescriptor();
        supportsConstraint = conglomerate.isConstraint();
    }
    /* RESOLVE - It would be nice to require less knowledge about sysconglomerates
		 * and have this be more table driven.
		 */
    /* Build the row to insert */
    row = getExecutionFactory().getValueRow(SYSCONGLOMERATES_COLUMN_COUNT);
    /* 1st column is SCHEMAID (UUID - char(36)) */
    row.setColumn(1, new SQLChar(schemaID));
    /* 2nd column is TABLEID (UUID - char(36)) */
    row.setColumn(2, new SQLChar(tabID));
    /* 3rd column is CONGLOMERATENUMBER (long) */
    row.setColumn(3, new SQLLongint(conglomNumber));
    /* 4th column is CONGLOMERATENAME (varchar(128)) 
		** If null, use the tableid so we always
		** have a unique column
		*/
    row.setColumn(4, (conglomName == null) ? new SQLVarchar(tabID) : new SQLVarchar(conglomName));
    /* 5th  column is ISINDEX (boolean) */
    row.setColumn(5, new SQLBoolean(supportsIndex));
    /* 6th column is DESCRIPTOR
		*  (user type org.apache.derby.catalog.IndexDescriptor)
		*/
    row.setColumn(6, new UserType((indexRowGenerator == null ? (IndexDescriptor) null : indexRowGenerator.getIndexDescriptor())));
    /* 7th column is ISCONSTRAINT (boolean) */
    row.setColumn(7, new SQLBoolean(supportsConstraint));
    /* 8th column is CONGLOMERATEID (UUID - char(36)) */
    row.setColumn(8, new SQLChar(conglomUUIDString));
    return row;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) IndexDescriptor(org.apache.derby.catalog.IndexDescriptor) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) IndexRowGenerator(org.apache.derby.iapi.sql.dictionary.IndexRowGenerator) SQLLongint(org.apache.derby.iapi.types.SQLLongint) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean) UserType(org.apache.derby.iapi.types.UserType) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean)

Aggregations

IndexDescriptor (org.apache.derby.catalog.IndexDescriptor)6 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)5 IndexRowGenerator (org.apache.derby.iapi.sql.dictionary.IndexRowGenerator)3 ArrayList (java.util.ArrayList)2 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)2 UUID (org.apache.derby.catalog.UUID)1 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)1 AccessPath (org.apache.derby.iapi.sql.compile.AccessPath)1 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)1 IndexLister (org.apache.derby.iapi.sql.dictionary.IndexLister)1 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)1 ConstantAction (org.apache.derby.iapi.sql.execute.ConstantAction)1 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)1 SQLBoolean (org.apache.derby.iapi.types.SQLBoolean)1 SQLChar (org.apache.derby.iapi.types.SQLChar)1 SQLLongint (org.apache.derby.iapi.types.SQLLongint)1 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)1 UserType (org.apache.derby.iapi.types.UserType)1 JBitSet (org.apache.derby.iapi.util.JBitSet)1