ExecRow baseRow;
ExecIndexRow indexableRow;
int numColumns;
long conglomId;
RowLocation rl;
CatalogRowFactory rf = ti.getCatalogRowFactory();
IndexRowGenerator irg;
ConglomerateDescriptor conglomerateDescriptor;
initSystemIndexVariables(ddg, ti, indexNumber);
irg = ti.getIndexRowGenerator(indexNumber);
numColumns = ti.getIndexColumnCount(indexNumber);
/* Is the index unique */
isUnique = ti.isIndexUnique(indexNumber);
// create an index row template
indexableRow = irg.getIndexRowTemplate();
baseRow = rf.makeEmptyRow();
// Get a RowLocation template
cc = tc.openConglomerate(
heapConglomerateNumber, false, 0,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_REPEATABLE_READ);
rl = cc.newRowLocationTemplate();
cc.close();
// Get an index row based on the base row
irg.getIndexRow(baseRow, rl, indexableRow, (FormatableBitSet) null);
// Describe the properties of the index to the store using Properties
// RESOLVE: The following properties assume a BTREE index.
Properties indexProperties = ti.getCreateIndexProperties(indexNumber);
// Tell it the conglomerate id of the base table
indexProperties.put(
"baseConglomerateId",
Long.toString( heapConglomerateNumber ) );
// All indexes are unique because they contain the RowLocation.
// The number of uniqueness columns must include the RowLocation
// if the user did not specify a unique index.
indexProperties.put("nUniqueColumns",
Integer.toString(
isUnique ? numColumns : numColumns + 1));
// By convention, the row location column is the last column
indexProperties.put("rowLocationColumn",
Integer.toString(numColumns));
// For now, all columns are key fields, including the RowLocation
indexProperties.put("nKeyFields",
Integer.toString(numColumns + 1));
/* Create and add the conglomerate (index) */
conglomId = tc.createConglomerate(
"BTREE", // we're requesting an index conglomerate
indexableRow.getRowArray(),
null, //default sort order
null, //default collation id's for collumns in all system congloms
indexProperties, // default properties
TransactionController.IS_DEFAULT); // not temporary
conglomerateDescriptor =
ddg.newConglomerateDescriptor(conglomId,
rf.getIndexName(indexNumber),
true,
irg,
false,
rf.getCanonicalIndexUUID(indexNumber),
rf.getCanonicalTableUUID(),
sd.getUUID());
ti.setIndexConglomerate( conglomerateDescriptor );
return conglomerateDescriptor;
}