提交 224cefae authored 作者: Thomas Mueller's avatar Thomas Mueller

MVTableEngine

上级 d50a6d4b
......@@ -18,7 +18,10 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>To compile user defined functions, the javax.tools.JavaCompiler is now used if available,
<ul><li>To use the MVStore storage engine (which is still work in progress), append
";mv_store=true" to the database URL. Using the MVTableEngine when creating the table
is no longer recommended.
</li><li>To compile user defined functions, the javax.tools.JavaCompiler is now used if available,
and no temporary files are created. This should solve problems when
multiple H2 database concurrently compile the same user defined functions.
To disable, system the system property "h2.javaSystemCompiler" to false.
......
......@@ -41,7 +41,7 @@ MVStore
<a href="#encryption">- Encrypted Files</a><br />
<a href="#tools">- Tools</a><br />
<a href="#exceptionHandling">- Exception Handling</a><br />
<a href="#tableEngine">- Table Engine for H2</a><br />
<a href="#storageEngine">- Storage Engine for H2</a><br />
<a href="#differences">
Similar Projects and Differences to Other Storage Engines</a><br />
......@@ -461,7 +461,7 @@ The following exceptions can occur:
</li><li><code>ConcurrentModificationException</code> if the object is modified concurrently.
</li></ul>
<h3 id="tableEngine">Table Engine for H2</h3>
<h3 id="storageEngine">Storage Engine for H2</h3>
<p>
The plan is to use the MVStore as the default storage engine for the H2 database
in the future (supporting SQL, JDBC, transactions, MVCC, and so on).
......
......@@ -879,7 +879,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
* Forget those old versions that are no longer needed.
*/
void removeUnusedOldVersions() {
long oldest = store.getRetainVersion();
long oldest = store.getRetainOrStoreVersion();
if (oldest == -1) {
return;
}
......
......@@ -47,6 +47,8 @@ TestMVStoreDataLoss
MVTableEngine:
- use StreamStore
- when the MVStore was enabled before, use it again
(probably by checking existence of the mvstore file)
TransactionStore:
......@@ -1528,6 +1530,21 @@ public class MVStore {
return v;
}
/**
* Get the oldest version to retain in memory, which is the manually set
* retain version, or the current store version (whatever is older).
*
* @return the version
*/
long getRetainOrStoreVersion() {
long v = retainVersion;
long storeVersion = currentStoreVersion;
if (storeVersion > -1) {
v = Math.min(v, storeVersion);
}
return v;
}
/**
* Check whether all data can be read from this version. This requires that
* all chunks referenced by this version are still available (not
......
......@@ -374,10 +374,9 @@ public class TestMVTableEngine extends TestBase {
Connection conn;
Statement stat;
ResultSet rs;
conn = getConnection("mvstore");
conn = getConnection("mvstore;MV_STORE=TRUE");
stat = conn.createStatement();
stat.execute("create table test(id int) " +
"engine \"org.h2.mvstore.db.MVTableEngine\"");
stat.execute("create table test(id int)");
stat.execute("set write_delay 0");
stat.execute("insert into test values(1)");
stat.execute("shutdown immediately");
......@@ -386,8 +385,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) {
// ignore
}
conn = getConnection("mvstore");
conn = getConnection("mvstore;MV_STORE=TRUE");
stat = conn.createStatement();
rs = stat.executeQuery("select * from test");
assertTrue(rs.next());
......@@ -399,11 +397,10 @@ public class TestMVTableEngine extends TestBase {
Connection conn;
Statement stat;
ResultSet rs;
conn = getConnection("mvstore");
conn = getConnection("mvstore;MV_STORE=TRUE");
for (int i = 0; i < 2; i++) {
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar) "
+ "engine \"org.h2.mvstore.db.MVTableEngine\"");
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("create index on test(name)");
conn.setAutoCommit(false);
stat.execute("insert into test values(1, 'Hello')");
......@@ -433,12 +430,11 @@ public class TestMVTableEngine extends TestBase {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
conn = getConnection("mvstore");
conn = getConnection("mvstore;MV_STORE=TRUE");
stat = conn.createStatement();
stat.execute("create table test(id int, name varchar) "
+ "engine \"org.h2.mvstore.db.MVTableEngine\"");
stat.execute("create table test(id int, name varchar)");
conn.close();
conn = getConnection("mvstore");
conn = getConnection("mvstore;MV_STORE=TRUE");
stat = conn.createStatement();
stat.execute("drop table test");
conn.close();
......@@ -446,8 +442,7 @@ public class TestMVTableEngine extends TestBase {
private void testBlob() throws SQLException, IOException {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn;
Statement stat;
conn = getConnection(dbName);
......@@ -474,8 +469,7 @@ public class TestMVTableEngine extends TestBase {
private void testEncryption() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn;
Statement stat;
String url = getURL(dbName + ";CIPHER=AES", true);
......@@ -495,8 +489,7 @@ public class TestMVTableEngine extends TestBase {
private void testExclusiveLock() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn, conn2;
Statement stat, stat2;
conn = getConnection(dbName);
......@@ -519,8 +512,7 @@ public class TestMVTableEngine extends TestBase {
private void testReadOnly() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn;
Statement stat;
conn = getConnection(dbName);
......@@ -537,8 +529,7 @@ public class TestMVTableEngine extends TestBase {
private void testReuseDiskSpace() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn;
Statement stat;
long maxSize = 0;
......@@ -563,8 +554,7 @@ public class TestMVTableEngine extends TestBase {
private void testDataTypes() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn = getConnection(dbName);
Statement stat = conn.createStatement();
......@@ -713,8 +703,7 @@ public class TestMVTableEngine extends TestBase {
private void testLocking() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn = getConnection(dbName);
Statement stat = conn.createStatement();
stat.execute("set lock_timeout 1000");
......@@ -750,12 +739,9 @@ public class TestMVTableEngine extends TestBase {
private void testSimple() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
String dbName = "mvstore" +
";MV_STORE=TRUE";
String dbName = "mvstore;MV_STORE=TRUE";
Connection conn = getConnection(dbName);
Statement stat = conn.createStatement();
// create table test(id int, name varchar)
// engine "org.h2.mvstore.db.MVStoreTableEngine"
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("insert into test values(1, 'Hello'), (2, 'World')");
ResultSet rs = stat.executeQuery("select *, _rowid_ from test");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论