use of org.h2.mvstore.OffHeapStore in project h2database by h2database.
the class TestMVStore method testProvidedFileStoreNotOpenedAndClosed.
private void testProvidedFileStoreNotOpenedAndClosed() {
final AtomicInteger openClose = new AtomicInteger();
FileStore fileStore = new OffHeapStore() {
@Override
public void open(String fileName, boolean readOnly, char[] encryptionKey) {
openClose.incrementAndGet();
super.open(fileName, readOnly, encryptionKey);
}
@Override
public void close() {
openClose.incrementAndGet();
super.close();
}
};
MVStore store = new MVStore.Builder().fileStore(fileStore).open();
store.close();
assertEquals(0, openClose.get());
}
use of org.h2.mvstore.OffHeapStore in project h2database by h2database.
the class TestMVStore method testOffHeapStorage.
private void testOffHeapStorage() throws Exception {
OffHeapStore offHeap = new OffHeapStore();
MVStore s = new MVStore.Builder().fileStore(offHeap).open();
int count = 1000;
Map<Integer, String> map = s.openMap("data");
for (int i = 0; i < count; i++) {
map.put(i, "Hello " + i);
s.commit();
}
assertTrue(offHeap.getWriteCount() > count);
s.close();
s = new MVStore.Builder().fileStore(offHeap).open();
map = s.openMap("data");
for (int i = 0; i < count; i++) {
assertEquals("Hello " + i, map.get(i));
}
s.close();
}
Aggregations