提交 a14c7148 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: tool to quickly compact a store.

上级 cbab3234
...@@ -37,16 +37,16 @@ public class TestMVStoreTool extends TestBase { ...@@ -37,16 +37,16 @@ public class TestMVStoreTool extends TestBase {
private void testCompress() { private void testCompress() {
String fileName = getBaseDir() + "/testCompress.h3"; String fileName = getBaseDir() + "/testCompress.h3";
FileUtils.createDirectory(getBaseDir()); FileUtils.createDirectories(getBaseDir());
FileUtils.delete(fileName); FileUtils.delete(fileName);
// store with a very small page size, to make sure // store with a very small page size, to make sure
// there are many leaf pages // there are many leaf pages
MVStore s = new MVStore.Builder(). MVStore s = new MVStore.Builder().
pageSplitSize(100). pageSplitSize(100).
fileName(fileName).autoCommitDisabled().open(); fileName(fileName).autoCommitDisabled().open();
MVMap<Integer, Integer> map = s.openMap("data"); MVMap<Integer, String> map = s.openMap("data");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
map.put(i, i * 10); map.put(i, "Hello World " + i * 10);
if (i % 3 == 0) { if (i % 3 == 0) {
s.commit(); s.commit();
} }
...@@ -54,7 +54,7 @@ public class TestMVStoreTool extends TestBase { ...@@ -54,7 +54,7 @@ public class TestMVStoreTool extends TestBase {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
map = s.openMap("data" + i); map = s.openMap("data" + i);
for (int j = 0; j < i * i; j++) { for (int j = 0; j < i * i; j++) {
map.put(j, j * 10); map.put(j, "Hello World " + j * 10);
} }
s.commit(); s.commit();
} }
...@@ -69,8 +69,10 @@ public class TestMVStoreTool extends TestBase { ...@@ -69,8 +69,10 @@ public class TestMVStoreTool extends TestBase {
fileName(fileName + ".new.compress").readOnly().open(); fileName(fileName + ".new.compress").readOnly().open();
assertEquals(s1, s2); assertEquals(s1, s2);
assertEquals(s1, s3); assertEquals(s1, s3);
assertTrue(FileUtils.size(fileName + ".new") < FileUtils.size(fileName)); long size1 = FileUtils.size(fileName);
assertTrue(FileUtils.size(fileName + ".new.compress") < FileUtils.size(fileName + ".new")); long size2 = FileUtils.size(fileName + ".new");
long size3 = FileUtils.size(fileName + ".new.compress");
assertTrue("size1: " + size1 + " size2: " + size2 + " size3: " + size3, size2 < size1 && size3 < size2);
} }
private void assertEquals(MVStore a, MVStore b) { private void assertEquals(MVStore a, MVStore b) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论