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;
}
Aggregations