提交 0442a328 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVTableEngine: in-memory operation

上级 b22ed608
...@@ -1832,9 +1832,9 @@ public class Database implements DataHandler { ...@@ -1832,9 +1832,9 @@ public class Database implements DataHandler {
} }
if (mvStore != null) { if (mvStore != null) {
mvStore.prepareCommit(session, transaction); mvStore.prepareCommit(session, transaction);
pageStore.flushLog();
return; return;
} }
pageStore.flushLog();
pageStore.prepareCommit(session, transaction); pageStore.prepareCommit(session, transaction);
} }
......
...@@ -893,7 +893,8 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -893,7 +893,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
} }
// create a new instance // create a new instance
// because another thread might iterate over it // because another thread might iterate over it
ArrayList<Page> list = new ArrayList<Page>(); int size = oldRoots.size() - i;
ArrayList<Page> list = new ArrayList<Page>(size);
list.addAll(oldRoots.subList(i, oldRoots.size())); list.addAll(oldRoots.subList(i, oldRoots.size()));
oldRoots = list; oldRoots = list;
} }
......
...@@ -19,6 +19,7 @@ import org.h2.engine.Database; ...@@ -19,6 +19,7 @@ import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.mvstore.DataUtils; import org.h2.mvstore.DataUtils;
import org.h2.mvstore.FileStore;
import org.h2.mvstore.MVStore; import org.h2.mvstore.MVStore;
import org.h2.mvstore.db.TransactionStore.Transaction; import org.h2.mvstore.db.TransactionStore.Transaction;
import org.h2.store.InDoubtTransaction; import org.h2.store.InDoubtTransaction;
...@@ -167,7 +168,8 @@ public class MVTableEngine implements TableEngine { ...@@ -167,7 +168,8 @@ public class MVTableEngine implements TableEngine {
* Store all pending changes. * Store all pending changes.
*/ */
public void store() { public void store() {
if (store.getFileStore().isReadOnly()) { FileStore s = store.getFileStore();
if (s == null || s.isReadOnly()) {
return; return;
} }
store.commit(); store.commit();
...@@ -210,8 +212,10 @@ public class MVTableEngine implements TableEngine { ...@@ -210,8 +212,10 @@ public class MVTableEngine implements TableEngine {
Transaction t = session.getTransaction(); Transaction t = session.getTransaction();
t.setName(transactionName); t.setName(transactionName);
t.prepare(); t.prepare();
if (store.getFileStore() != null) {
store.store(); store.store();
} }
}
public ArrayList<InDoubtTransaction> getInDoubtTransactions() { public ArrayList<InDoubtTransaction> getInDoubtTransactions() {
List<Transaction> list = transactionStore.getOpenTransactions(); List<Transaction> list = transactionStore.getOpenTransactions();
...@@ -307,7 +311,9 @@ public class MVTableEngine implements TableEngine { ...@@ -307,7 +311,9 @@ public class MVTableEngine implements TableEngine {
} else { } else {
transaction.rollback(); transaction.rollback();
} }
if (store.getFileStore() != null) {
store.store(); store.store();
}
this.state = state; this.state = state;
} }
......
...@@ -190,10 +190,12 @@ public class TransactionStore { ...@@ -190,10 +190,12 @@ public class TransactionStore {
private void commitIfNeeded() { private void commitIfNeeded() {
if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) { if (store.getUnsavedPageCount() > MAX_UNSAVED_PAGES) {
if (store.getFileStore() != null) {
store.commit(); store.commit();
store.store(); store.store();
} }
} }
}
/** /**
* Store a transaction. * Store a transaction.
...@@ -352,6 +354,9 @@ public class TransactionStore { ...@@ -352,6 +354,9 @@ public class TransactionStore {
firstOpenTransaction = -1; firstOpenTransaction = -1;
} }
if (store.getWriteDelay() == 0) { if (store.getWriteDelay() == 0) {
if (store.getFileStore() == null) {
return;
}
store.commit(); store.commit();
} }
// to avoid having to store the transaction log, // to avoid having to store the transaction log,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论