use of org.hsqldb_voltpatches.index.Index in project voltdb by VoltDB.
the class TableWorks method addIndex.
/**
* Because of the way indexes and column data are held in memory and on
* disk, it is necessary to recreate the table when an index is added to a
* non-empty cached table.
*
* <p> With empty tables, Index objects are simply added
*
* <p> With MEOMRY and TEXT tables, a new index is built up and nodes for
* earch row are interlinked (fredt@users)
*
* @param col int[]
* @param name HsqlName
* @param unique boolean
* @return new index
*/
Index addIndex(int[] col, HsqlName name, boolean unique) {
Index newindex;
if (table.isEmpty(session) || table.isIndexingMutable()) {
PersistentStore store = session.sessionData.getRowStore(table);
newindex = table.createIndex(store, name, col, null, null, unique, false, false);
} else {
newindex = table.createIndexStructure(name, col, null, null, unique, false, false);
Table tn = table.moveDefinition(session, table.tableType, null, null, newindex, -1, 0, emptySet, emptySet);
// for all sessions move the data
tn.moveData(session, table, -1, 0);
database.persistentStoreCollection.releaseStore(table);
table = tn;
setNewTableInSchema(table);
updateConstraints(table, emptySet);
}
database.schemaManager.addSchemaObject(newindex);
database.schemaManager.recompileDependentObjects(table);
return newindex;
}
use of org.hsqldb_voltpatches.index.Index in project voltdb by VoltDB.
the class TableWorks method addUniqueConstraint.
/**
* A unique constraint relies on a unique indexe on the table. It can cover
* a single column or multiple columns.
*
* <p> All unique constraint names are generated by Database.java as unique
* within the database. Duplicate constraints (more than one unique
* constriant on the same set of columns) are not allowed. (fredt@users)
*
* @param cols int[]
* @param name HsqlName
*/
// A VoltDB extension to support the assume unique attribute
void addUniqueConstraint(int[] cols, HsqlName name, boolean isAutogeneratedName, boolean assumeUnique) {
database.schemaManager.checkSchemaObjectNotExists(name);
if (table.getUniqueConstraintForColumns(cols) != null) {
throw Error.error(ErrorCode.X_42522);
}
// create an autonamed index
HsqlName indexname = database.nameManager.newAutoName("IDX", name.name, table.getSchemaName(), table.getName(), SchemaObject.INDEX);
Index index = table.createIndexStructure(indexname, cols, null, null, true, true, false);
Constraint constraint = new Constraint(name, isAutogeneratedName, table, index, Constraint.UNIQUE);
// A VoltDB extension to support the assume unique attribute
constraint = constraint.setAssumeUnique(assumeUnique);
// End of VoltDB extension
Table tn = table.moveDefinition(session, table.tableType, null, constraint, index, -1, 0, emptySet, emptySet);
tn.moveData(session, table, -1, 0);
database.persistentStoreCollection.releaseStore(table);
table = tn;
database.schemaManager.addSchemaObject(constraint);
setNewTableInSchema(table);
updateConstraints(table, emptySet);
database.schemaManager.recompileDependentObjects(table);
}
use of org.hsqldb_voltpatches.index.Index in project voltdb by VoltDB.
the class RowStoreAVLMemory method setAccessor.
public void setAccessor(Index key, CachedObject accessor) {
Index index = (Index) key;
accessorList[index.getPosition()] = accessor;
}
use of org.hsqldb_voltpatches.index.Index in project voltdb by VoltDB.
the class RowStoreAVLHybrid method setAccessor.
public void setAccessor(Index key, CachedObject accessor) {
Index index = (Index) key;
accessorList[index.getPosition()] = accessor;
}
use of org.hsqldb_voltpatches.index.Index in project voltdb by VoltDB.
the class RowStoreAVLDisk method setAccessor.
public void setAccessor(Index key, CachedObject accessor) {
Index index = (Index) key;
accessorList[index.getPosition()] = accessor;
}
Aggregations