Search in sources :

Example 16 with Index

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;
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) Index(org.hsqldb_voltpatches.index.Index)

Example 17 with Index

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);
}
Also used : HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) Index(org.hsqldb_voltpatches.index.Index)

Example 18 with Index

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;
}
Also used : Index(org.hsqldb_voltpatches.index.Index)

Example 19 with Index

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;
}
Also used : Index(org.hsqldb_voltpatches.index.Index)

Example 20 with Index

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;
}
Also used : Index(org.hsqldb_voltpatches.index.Index)

Aggregations

Index (org.hsqldb_voltpatches.index.Index)29 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)6 RowIterator (org.hsqldb_voltpatches.navigator.RowIterator)4 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)3 IndexAVL (org.hsqldb_voltpatches.index.IndexAVL)2 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)2 HashMap (java.util.HashMap)1 HSQLParseException (org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)1 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)1 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)1 Type (org.hsqldb_voltpatches.types.Type)1