Search in sources :

Example 1 with MemoryHashIndexManager

use of herddb.index.MemoryHashIndexManager in project herddb by diennea.

the class TableSpaceManager method bootIndex.

private AbstractIndexManager bootIndex(Index index, AbstractTableManager tableManager, long transaction, boolean rebuild) throws DataStorageManagerException {
    long _start = System.currentTimeMillis();
    LOGGER.log(Level.SEVERE, "bootIndex {0} {1}.{2}.{3} uuid {4}", new Object[] { nodeId, tableSpaceName, index.table, index.name, index.uuid });
    if (indexes.containsKey(index.name)) {
        throw new DataStorageManagerException("Index" + index.name + " already present in tableSpace " + tableSpaceName);
    }
    AbstractIndexManager indexManager;
    switch(index.type) {
        case Index.TYPE_HASH:
            indexManager = new MemoryHashIndexManager(index, tableManager, log, dataStorageManager, this, tableSpaceUUID, transaction);
            break;
        case Index.TYPE_BRIN:
            indexManager = new BRINIndexManager(index, dbmanager.getMemoryManager(), tableManager, log, dataStorageManager, this, tableSpaceUUID, transaction);
            break;
        default:
            throw new DataStorageManagerException("invalid index type " + index.type);
    }
    indexes.put(index.name, indexManager);
    // this must be mutable (see DROP INDEX)
    Map<String, AbstractIndexManager> newMap = new HashMap<>();
    newMap.put(index.name, indexManager);
    indexesByTable.merge(index.table, newMap, (a, b) -> {
        Map<String, AbstractIndexManager> map = new HashMap<>(a);
        map.putAll(b);
        return map;
    });
    indexManager.start(tableManager.getBootSequenceNumber());
    long _stop = System.currentTimeMillis();
    LOGGER.log(Level.SEVERE, "bootIndex {0} {1}.{2} time {3} ms", new Object[] { nodeId, tableSpaceName, index.name, (_stop - _start) + "" });
    if (rebuild) {
        indexManager.rebuild();
        LOGGER.log(Level.SEVERE, "bootIndex - rebuild {0} {1}.{2} time {3} ms", new Object[] { nodeId, tableSpaceName, index.name, (System.currentTimeMillis() - _stop) + "" });
    }
    dbmanager.getPlanner().clearCache();
    return indexManager;
}
Also used : DataStorageManagerException(herddb.storage.DataStorageManagerException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MemoryHashIndexManager(herddb.index.MemoryHashIndexManager) BRINIndexManager(herddb.index.brin.BRINIndexManager)

Aggregations

MemoryHashIndexManager (herddb.index.MemoryHashIndexManager)1 BRINIndexManager (herddb.index.brin.BRINIndexManager)1 DataStorageManagerException (herddb.storage.DataStorageManagerException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1