// Create bytesDB
_storeHome = new File(_homeDir, "store");
int storeInitialCapacity = config.getInitialCapacity();
StoreConfig storeConfig = new StoreConfig(_storeHome, storeInitialCapacity);
storeConfig.setIndexesCached(config.getIndexesCached());
storeConfig.setBatchSize(config.getBatchSize());
storeConfig.setNumSyncBatches(config.getNumSyncBatches());
storeConfig.setSegmentFileSizeMB(config.getSegmentFileSizeMB());
storeConfig.setSegmentFactory(config.getSegmentFactory());
storeConfig.setSegmentCompactFactor(config.getSegmentCompactFactor());
_bytesDB = new BytesDB(storeConfig);
_scn = _bytesDB.getHWMark();
// Create hash index
_indexHome = new File(_homeDir, "index");
int indexInitialCapacity =
config.getInt(StoreParams.PARAM_INDEX_INITIAL_CAPACITY,
config.getInitialCapacity());
int indexSegmentFileSizeMB =
config.getInt(StoreParams.PARAM_INDEX_SEGMENT_FILE_SIZE_MB,
StoreParams.INDEX_SEGMENT_FILE_SIZE_MB_DEFAULT);
double indexSegmentCompactFactor =
config.getDouble(StoreParams.PARAM_INDEX_SEGMENT_COMPACT_FACTOR,
config.getSegmentCompactFactor());
SegmentFactory indexSegmentFactory =
config.getClass(StoreParams.PARAM_INDEX_SEGMENT_FACTORY_CLASS, MemorySegmentFactory.class)
.asSubclass(SegmentFactory.class).newInstance();
StoreConfig indexConfig = new StoreConfig(_indexHome, indexInitialCapacity);
indexConfig.setBatchSize(config.getBatchSize());
indexConfig.setNumSyncBatches(config.getNumSyncBatches());
indexConfig.setIndexesCached(true); // indexes.dat is always cached
indexConfig.setSegmentFactory(indexSegmentFactory);
indexConfig.setSegmentFileSizeMB(indexSegmentFileSizeMB);
indexConfig.setSegmentCompactFactor(indexSegmentCompactFactor);
indexConfig.setHashLoadFactor(config.getHashLoadFactor());
indexConfig.setHashFunction(config.getHashFunction());
indexConfig.setDataHandler(config.getDataHandler());
_index = new HashIndex(indexConfig);
initIndexPersistableListener();
_logger.info("opened indexHome=" + _indexHome.getAbsolutePath() + " storeHome=" + _storeHome.getAbsolutePath());
}