提交 0aff2147 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVTableEngine

上级 4b6e796a
...@@ -128,6 +128,7 @@ public class TransactionStore { ...@@ -128,6 +128,7 @@ public class TransactionStore {
// no entry // no entry
} else if (last[0] == id) { } else if (last[0] == id) {
Transaction t = new Transaction(this, id, status, name, last[1]); Transaction t = new Transaction(this, id, status, name, last[1]);
t.setStored(true);
openTransactionMap.put(id, t); openTransactionMap.put(id, t);
} }
} }
...@@ -168,10 +169,11 @@ public class TransactionStore { ...@@ -168,10 +169,11 @@ public class TransactionStore {
if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) { if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) {
store.commit(); store.commit();
} }
long transactionId = t.getId(); if (t.isStored()) {
if (openTransactions.containsKey(transactionId)) {
return; return;
} }
t.setStored(true);
long transactionId = t.getId();
Object[] v = { t.getStatus(), null }; Object[] v = { t.getStatus(), null };
openTransactions.put(transactionId, v); openTransactions.put(transactionId, v);
openTransactionMap.put(transactionId, t); openTransactionMap.put(transactionId, t);
...@@ -347,6 +349,8 @@ public class TransactionStore { ...@@ -347,6 +349,8 @@ public class TransactionStore {
private int status; private int status;
private String name; private String name;
private boolean stored;
Transaction(TransactionStore store, long transactionId, int status, String name, long logId) { Transaction(TransactionStore store, long transactionId, int status, String name, long logId) {
this.store = store; this.store = store;
...@@ -357,6 +361,14 @@ public class TransactionStore { ...@@ -357,6 +361,14 @@ public class TransactionStore {
this.logId = logId; this.logId = logId;
} }
boolean isStored() {
return stored;
}
void setStored(boolean stored) {
this.stored = stored;
}
/** /**
* Get the transaction id. * Get the transaction id.
* *
...@@ -1047,7 +1059,7 @@ public class TransactionStore { ...@@ -1047,7 +1059,7 @@ public class TransactionStore {
buff.put((byte) 0); buff.put((byte) 0);
} else { } else {
buff.put((byte) 1); buff.put((byte) 1);
t.write(buff, o); buff = t.write(buff, o);
} }
} }
return buff; return buff;
......
...@@ -35,7 +35,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -35,7 +35,7 @@ public class TestMVTableEngine extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
// testSpeed(); //testSpeed();
testExclusiveLock(); testExclusiveLock();
testEncryption(); testEncryption();
testReadOnly(); testReadOnly();
...@@ -71,6 +71,11 @@ int tes; ...@@ -71,6 +71,11 @@ int tes;
String url = getURL(dbName, true); String url = getURL(dbName, true);
String user = getUser(); String user = getUser();
String password = getPassword(); String password = getPassword();
//Profiler prof = new Profiler();
//prof.sumClasses=true;
//prof.startCollecting();
conn = DriverManager.getConnection(url, user, password); conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement(); stat = conn.createStatement();
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
...@@ -82,39 +87,39 @@ int tes; ...@@ -82,39 +87,39 @@ int tes;
.prepareStatement("insert into test values(?, ?)"); .prepareStatement("insert into test values(?, ?)");
// -mx4g // -mx4g
// fast size
// 10000 / 8000 // 10000 / 8000
// 1229 mvstore;LOCK_MODE=0 // 1278 mvstore;LOCK_MODE=0 before
// 1455 mvstore;LOCK_MODE=0 // 1524 mvstore;LOCK_MODE=0 after
// 19 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 790 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 659 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 834 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
// 1000 / 80000 // 1000 / 80000
// 1383 mvstore;LOCK_MODE=0 // 1753 mvstore;LOCK_MODE=0 before
// 1618 mvstore;LOCK_MODE=0 // 1998 mvstore;LOCK_MODE=0 after
// 244 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 810 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 965 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 818 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
// 100 / 800000 // 100 / 800000
// 2061 mvstore;LOCK_MODE=0 // 2270 mvstore;LOCK_MODE=0 before
// 2281 mvstore;LOCK_MODE=0 // 2841 mvstore;LOCK_MODE=0 after
// 1414 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 2107 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 2647 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 2116 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
// 10 / 8000000 // 10 / 800000
// 11453 mvstore;LOCK_MODE=0 // 1312 mvstore;LOCK_MODE=0 before
// 11720 mvstore;LOCK_MODE=0 // 1500 mvstore;LOCK_MODE=0 after
// 13605 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 1541 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 before
// 25172 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 // 1551 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0 after
prep.setString(2, new String(new char[10]).replace((char) 0, 'x')); prep.setString(2, new String(new char[10]).replace((char) 0, 'x'));
for (int i = 0; i < 800000; i++) { for (int i = 0; i < 80000; i++) {
prep.setInt(1, i); prep.setInt(1, i);
prep.execute(); prep.execute();
} }
System.out.println((System.currentTimeMillis() - time) + " " + dbName + " before"); System.out.println((System.currentTimeMillis() - time) + " " + dbName + " before");
//Profiler prof = new Profiler().startCollecting();
conn.close(); conn.close();
//System.out.println(prof.getTop(10)); //System.out.println(prof.getTop(10));
System.out.println((System.currentTimeMillis() - time) + " " + dbName + " after"); System.out.println((System.currentTimeMillis() - time) + " " + dbName + " after");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论