Search in sources :

Example 61 with ConglomerateDescriptor

use of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor in project derby by apache.

the class DropTableNode method bindStatement.

/**
 * Bind this LockTableNode.  This means looking up the table,
 * verifying it exists and getting the heap conglomerate number.
 *
 * @exception StandardException		Thrown on error
 */
@Override
public void bindStatement() throws StandardException {
    CompilerContext cc = getCompilerContext();
    td = getTableDescriptor();
    conglomerateNumber = td.getHeapConglomerateId();
    /* Get the base conglomerate descriptor */
    ConglomerateDescriptor cd = td.getConglomerateDescriptor(conglomerateNumber);
    /* Statement is dependent on the TableDescriptor and ConglomerateDescriptor */
    cc.createDependency(td);
    cc.createDependency(cd);
}
Also used : CompilerContext(org.apache.derby.iapi.sql.compile.CompilerContext) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)

Example 62 with ConglomerateDescriptor

use of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor in project derby by apache.

the class DataDictionaryImpl method getConglomerateDescriptors.

/**
 * Get an array of ConglomerateDescriptors given the UUID.  If it is a
 * heap conglomerate or an index conglomerate not shared by a duplicate
 * index, the size of the return array is 1. If the uuid argument is null, then
 * this method retrieves descriptors for all of the conglomerates in the database.
 *
 * @param uuid	The UUID
 *
 * @return An array of ConglomerateDescriptors for the conglomerate.
 *				returns size 0 array if no such conglomerate.
 *
 * @exception StandardException		Thrown on failure
 */
public ConglomerateDescriptor[] getConglomerateDescriptors(UUID uuid) throws StandardException {
    DataValueDescriptor UUIDStringOrderable;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    List<ConglomerateDescriptor> cdl = newSList();
    if (uuid != null) {
        /* Use UUIDStringOrderable in both start and stop positions for scan */
        UUIDStringOrderable = getIDValueAsCHAR(uuid);
        /* Set up the start/stop position for the scan */
        ExecIndexRow keyRow = exFactory.getIndexableRow(1);
        keyRow.setColumn(1, UUIDStringOrderable);
        getDescriptorViaIndex(SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, cdl, ConglomerateDescriptor.class, false);
    } else {
        getDescriptorViaHeap(null, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, cdl, ConglomerateDescriptor.class);
    }
    return cdl.toArray(new ConglomerateDescriptor[cdl.size()]);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 63 with ConglomerateDescriptor

use of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor in project derby by apache.

the class DataDictionaryImpl method hashAllConglomerateDescriptorsByNumber.

/**
 * Get all of the ConglomerateDescriptors in the database and
 * hash them by conglomerate number.
 * This is useful as a performance optimization for the locking VTIs.
 * NOTE:  This method will scan SYS.SYSCONGLOMERATES at READ UNCOMMITTED.
 *
 * @param tc		TransactionController for the transaction
 *
 * @return	A Hashtable with all of the ConglomerateDescriptors
 *		in the database hashed by conglomerate number.
 *
 * @exception StandardException		Thrown on failure
 */
public Hashtable<Long, ConglomerateDescriptor> hashAllConglomerateDescriptorsByNumber(TransactionController tc) throws StandardException {
    Hashtable<Long, ConglomerateDescriptor> ht = new Hashtable<Long, ConglomerateDescriptor>();
    ConglomerateDescriptor cd = null;
    ScanController scanController;
    ExecRow outRow;
    TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    SYSCONGLOMERATESRowFactory rf = (SYSCONGLOMERATESRowFactory) ti.getCatalogRowFactory();
    outRow = rf.makeEmptyRow();
    scanController = tc.openScan(// conglomerate to open
    ti.getHeapConglomerate(), // don't hold open across commit
    false, // for read
    0, // scans whole table.
    TransactionController.MODE_RECORD, TransactionController.ISOLATION_READ_UNCOMMITTED, // all fields as objects
    (FormatableBitSet) null, // keyRow.getRowArray(),   // start position - first row
    (DataValueDescriptor[]) null, // startSearchOperation
    ScanController.GE, (ScanQualifier[][]) null, // keyRow.getRowArray(),   // stop position - through last row
    (DataValueDescriptor[]) null, // stopSearchOperation
    ScanController.GT);
    // fetch() may find the row deleted or purged from the table.
    while (scanController.fetchNext(outRow.getRowArray())) {
        cd = (ConglomerateDescriptor) rf.buildDescriptor(outRow, (TupleDescriptor) null, this);
        Long hashKey = cd.getConglomerateNumber();
        ht.put(hashKey, cd);
    }
    scanController.close();
    return ht;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) Hashtable(java.util.Hashtable) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)

Example 64 with ConglomerateDescriptor

use of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor in project derby by apache.

the class SYSCONGLOMERATESRowFactory method buildDescriptor.

// /////////////////////////////////////////////////////////////////////////
// 
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
// 
// /////////////////////////////////////////////////////////////////////////
/**
 * @param row a SYSCOLUMNS row
 * @param parentTupleDescriptor	Null for this kind of descriptor.
 * @param dd dataDictionary
 *
 * @return	a conglomerate descriptor equivalent to a SYSCONGOMERATES row
 *
 * @exception   StandardException thrown on failure
 */
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
    if (SanityManager.DEBUG)
        SanityManager.ASSERT(row.nColumns() == SYSCONGLOMERATES_COLUMN_COUNT, "Wrong number of columns for a SYSCONGLOMERATES row");
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    long conglomerateNumber;
    String name;
    boolean isConstraint;
    boolean isIndex;
    IndexRowGenerator indexRowGenerator;
    DataValueDescriptor col;
    ConglomerateDescriptor conglomerateDesc;
    String conglomUUIDString;
    UUID conglomUUID;
    String schemaUUIDString;
    UUID schemaUUID;
    String tableUUIDString;
    UUID tableUUID;
    /* 1st column is SCHEMAID (UUID - char(36)) */
    col = row.getColumn(1);
    schemaUUIDString = col.getString();
    schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);
    /* 2nd column is TABLEID (UUID - char(36)) */
    col = row.getColumn(2);
    tableUUIDString = col.getString();
    tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
    /* 3nd column is CONGLOMERATENUMBER (long) */
    col = row.getColumn(3);
    conglomerateNumber = col.getLong();
    /* 4rd column is CONGLOMERATENAME (varchar(128)) */
    col = row.getColumn(4);
    name = col.getString();
    /* 5th column is ISINDEX (boolean) */
    col = row.getColumn(5);
    isIndex = col.getBoolean();
    /* 6th column is DESCRIPTOR */
    col = row.getColumn(6);
    indexRowGenerator = new IndexRowGenerator((IndexDescriptor) col.getObject());
    /* 7th column is ISCONSTRAINT (boolean) */
    col = row.getColumn(7);
    isConstraint = col.getBoolean();
    /* 8th column is CONGLOMERATEID (UUID - char(36)) */
    col = row.getColumn(8);
    conglomUUIDString = col.getString();
    conglomUUID = getUUIDFactory().recreateUUID(conglomUUIDString);
    /* now build and return the descriptor */
    conglomerateDesc = ddg.newConglomerateDescriptor(conglomerateNumber, name, isIndex, indexRowGenerator, isConstraint, conglomUUID, tableUUID, schemaUUID);
    return conglomerateDesc;
}
Also used : DataDescriptorGenerator(org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator) IndexRowGenerator(org.apache.derby.iapi.sql.dictionary.IndexRowGenerator) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) IndexDescriptor(org.apache.derby.catalog.IndexDescriptor) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)

Example 65 with ConglomerateDescriptor

use of org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor 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

ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)66 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)19 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)17 TransactionController (org.apache.derby.iapi.store.access.TransactionController)13 Properties (java.util.Properties)12 UUID (org.apache.derby.catalog.UUID)12 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)12 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)12 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)11 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)11 IndexRowGenerator (org.apache.derby.iapi.sql.dictionary.IndexRowGenerator)10 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)10 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)8 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)8 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)8 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)7 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)7 RowLocation (org.apache.derby.iapi.types.RowLocation)6 ArrayList (java.util.ArrayList)5 IndexDescriptor (org.apache.derby.catalog.IndexDescriptor)5