private Index loadIndex(String bagName, IndexDefinition indexDefinition) throws JasDBStorageException {
try {
KeyInfo keyInfo = new KeyInfoImpl(indexDefinition.getHeaderDescriptor(), indexDefinition.getValueDescriptor());
File indexFile = createIndexFile(bagName, indexDefinition.getIndexName(), false);
switch(IndexTypes.getTypeFor(indexDefinition.getIndexType())) {
case BTREE:
LOG.debug("Loaded BTree Index for key: {}", indexDefinition.getIndexName());
Index btreeIndex = new BTreeIndex(indexFile, keyInfo);
return configureIndex(IndexTypes.BTREE, btreeIndex);
default:
throw new JasDBStorageException("Reading from this index type: " + indexDefinition.getIndexName() +
" is not supported");
}
} catch(ConfigurationException e) {
throw new JasDBStorageException("Unable to load index, invalid configuration", e);
}
}