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

MVStore table engine (improved performance)

上级 2d4e670d
...@@ -63,6 +63,8 @@ public class TransactionStore { ...@@ -63,6 +63,8 @@ public class TransactionStore {
private long lastTransactionId; private long lastTransactionId;
private long firstOpenTransaction = -1;
/** /**
* Create a new transaction store. * Create a new transaction store.
* *
...@@ -108,6 +110,10 @@ public class TransactionStore { ...@@ -108,6 +110,10 @@ public class TransactionStore {
if (lastKey != null && lastKey.longValue() > lastTransactionId) { if (lastKey != null && lastKey.longValue() > lastTransactionId) {
throw DataUtils.newIllegalStateException("Last transaction not stored"); throw DataUtils.newIllegalStateException("Last transaction not stored");
} }
if (undoLog.size() > 0) {
long[] key = undoLog.firstKey();
firstOpenTransaction = key[0];
}
} }
/** /**
...@@ -199,6 +205,9 @@ public class TransactionStore { ...@@ -199,6 +205,9 @@ public class TransactionStore {
long[] undoKey = { t.getId(), logId }; long[] undoKey = { t.getId(), logId };
Object[] log = new Object[] { opType, mapId, key, oldValue }; Object[] log = new Object[] { opType, mapId, key, oldValue };
undoLog.put(undoKey, log); undoLog.put(undoKey, log);
if (firstOpenTransaction == -1 || t.getId() < firstOpenTransaction) {
firstOpenTransaction = t.getId();
}
} }
/** /**
...@@ -249,10 +258,19 @@ public class TransactionStore { ...@@ -249,10 +258,19 @@ public class TransactionStore {
} }
boolean isTransactionOpen(long transactionId) { boolean isTransactionOpen(long transactionId) {
int todoSlow;
// if (transactionId < firstOpenTransaction) { // if (transactionId < firstOpenTransaction) {
// return false; // return false;
// } // }
if (firstOpenTransaction == -1) {
if (undoLog.size() == 0) {
return false;
}
long[] key = undoLog.firstKey();
firstOpenTransaction = key[0];
}
if (firstOpenTransaction == transactionId) {
return true;
}
long[] key = { transactionId, -1 }; long[] key = { transactionId, -1 };
key = undoLog.higherKey(key); key = undoLog.higherKey(key);
return key != null && key[0] == transactionId; return key != null && key[0] == transactionId;
...@@ -263,6 +281,9 @@ public class TransactionStore { ...@@ -263,6 +281,9 @@ public class TransactionStore {
preparedTransactions.remove(t.getId()); preparedTransactions.remove(t.getId());
} }
t.setStatus(Transaction.STATUS_CLOSED); t.setStatus(Transaction.STATUS_CLOSED);
if (t.getId() == firstOpenTransaction) {
firstOpenTransaction = -1;
}
} }
/** /**
......
...@@ -95,10 +95,10 @@ int tes; ...@@ -95,10 +95,10 @@ int tes;
// fast size // fast size
// 10 / 800000 // 10 / 800000
// 1265 mvstore;LOCK_MODE=0 before // 1272 mvstore;LOCK_MODE=0 before
// 1434 mvstore;LOCK_MODE=0 after // 1449 mvstore;LOCK_MODE=0 after
// 1126 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 before // 1076 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 before
// 1136 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 after // 1086 mvstore;DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine;LOCK_MODE=0;LOG=0 after
// 100 / 800000 // 100 / 800000
// 2010 mvstore;LOCK_MODE=0 before // 2010 mvstore;LOCK_MODE=0 before
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论