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

MVStore: use a different free space algorithm (pluggable now)

上级 065aa507
...@@ -952,7 +952,8 @@ public class MVStore { ...@@ -952,7 +952,8 @@ public class MVStore {
// free up the space of unused chunks now // free up the space of unused chunks now
for (Chunk x : removedChunks) { for (Chunk x : removedChunks) {
freeSpace.free(x.start, x.length); int len = MathUtils.roundUpInt(x.length, BLOCK_SIZE) + BLOCK_SIZE;
freeSpace.free(x.start, len);
} }
c.start = filePos; c.start = filePos;
...@@ -1617,7 +1618,8 @@ public class MVStore { ...@@ -1617,7 +1618,8 @@ public class MVStore {
loadFromFile = true; loadFromFile = true;
do { do {
last = chunks.remove(lastChunkId); last = chunks.remove(lastChunkId);
freeSpace.free(last.start, last.length); int len = MathUtils.roundUpInt(last.length, BLOCK_SIZE) + BLOCK_SIZE;
freeSpace.free(last.start, len);
lastChunkId--; lastChunkId--;
} while (last.version > version && chunks.size() > 0); } while (last.version > version && chunks.size() > 0);
rootChunkStart = last.start; rootChunkStart = last.start;
......
...@@ -72,6 +72,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -72,6 +72,8 @@ public class TestMVTableEngine extends TestBase {
Connection conn; Connection conn;
Statement stat; Statement stat;
long maxSize = 0; long maxSize = 0;
// TODO does not shrink for 45 seconds;
// need an option to configure that
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
conn = getConnection(dbName); conn = getConnection(dbName);
stat = conn.createStatement(); stat = conn.createStatement();
......
...@@ -45,7 +45,7 @@ public class TestTransactionStore extends TestBase { ...@@ -45,7 +45,7 @@ public class TestTransactionStore extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
FileUtils.createDirectories(getBaseDir()); FileUtils.createDirectories(getBaseDir());
// testStopWhileCommitting(); testStopWhileCommitting();
testGetModifiedMaps(); testGetModifiedMaps();
testKeyIterator(); testKeyIterator();
testMultiStatement(); testMultiStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论