/**
* Creates a DataStore instance.
*/
protected DataStore<byte[], byte[]> createDataStore(File homeDir, int initialCapacity) throws Exception {
StoreConfig config = new StoreConfig(homeDir, initialCapacity);
config.setBatchSize(10000);
config.setNumSyncBatches(100);
// Configure store segments
config.setSegmentFactory(new WriteBufferSegmentFactory());
config.setSegmentFileSizeMB(128);
config.setSegmentCompactFactor(0.67);
// Configure index segments
config.setInt(StoreParams.PARAM_INDEX_SEGMENT_FILE_SIZE_MB, 32);
config.setDouble(StoreParams.PARAM_INDEX_SEGMENT_COMPACT_FACTOR, 0.5);
// Configure index initial capacity
int indexInitialCapacity = initialCapacity / 8;
config.setInt(StoreParams.PARAM_INDEX_INITIAL_CAPACITY, indexInitialCapacity);
// Configure to reduce memory footprint
config.setDataHandler(new HashIndexDataHandler());
// Disable linear hashing
config.setHashLoadFactor(1.0);
return StoreFactory.createIndexedDataStore(config);
}