int count = length;
/**
* ArrayStorePartition does not change length after the store has been created.
*/
ArrayStorePartition store = StoreFactory.createArrayStorePartition(
homeDir,
start,
count,
segmentFileSizeMB,
segmentFactory);
assertEquals(length, store.length());
assertEquals(length, store.capacity());
assertEquals(start, store.getIndexStart());
store.clear();
store.close();
// Fail on smaller capacity
int smallerCapacity = length - 500;
try {
store = StoreFactory.createArrayStorePartition(
homeDir,
start,
smallerCapacity,
batchSize,
numSyncBatches,
segmentFileSizeMB,
segmentFactory);
assertFalse(true);
} catch(IOException e) {}
// Fail on larger capacity
int largerCapacity = length + 500;
try {
store = StoreFactory.createArrayStorePartition(
homeDir,
start,
largerCapacity,
batchSize,
numSyncBatches,
segmentFileSizeMB,
segmentFactory,
segmentCompactFactor);
assertFalse(true);
} catch(IOException e) {}
store = StoreFactory.createArrayStorePartition(
homeDir,
start,
count,
batchSize,
numSyncBatches,
segmentFileSizeMB,
segmentFactory,
segmentCompactFactor);
assertEquals(length, store.length());
assertEquals(length, store.capacity());
assertEquals(start, store.getIndexStart());
store.clear();
store.close();
// Use StoreConfig
StorePartitionConfig config = new StorePartitionConfig(homeDir, start, count);
config.setBatchSize(batchSize);
config.setNumSyncBatches(numSyncBatches);
config.setSegmentFileSizeMB(segmentFileSizeMB);
config.setSegmentFactory(segmentFactory);
config.setSegmentCompactFactor(segmentCompactFactor);
store = StoreFactory.createArrayStorePartition(config);
assertEquals(length, store.length());
assertEquals(length, store.capacity());
assertEquals(start, store.getIndexStart());
store.clear();
store.close();
FileUtils.deleteDirectory(homeDir);
}