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