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

MVStore: support for concurrent reads and writes is now enabled by default.

上级 337f0a4f
......@@ -59,7 +59,7 @@ public class TestMultiThread extends TestBase implements Runnable {
testConcurrentAlter();
testConcurrentAnalyze();
testConcurrentInsertUpdateSelect();
testMetadataWith();
testLockModeWithMultiThreaded();
}
private void testConcurrentLobAdd() throws Exception {
......@@ -246,15 +246,17 @@ public class TestMultiThread extends TestBase implements Runnable {
}
}
private void testMetadataWith() throws Exception {
private void testLockModeWithMultiThreaded() throws Exception {
// currently the combination of LOCK_MODE=0 and MULTI_THREADED
// is not supported. also see code in
deleteDb("concurrentAnalyze");
final String url = getURL("concurrentAnalyze;MULTI_THREADED=1", true);
// is not supported
deleteDb("lockMode");
final String url = getURL("lockMode;MULTI_THREADED=1", true);
Connection conn = getConnection(url);
DatabaseMetaData dmd = conn.getMetaData();
assertFalse(dmd.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED));
DatabaseMetaData meta = conn.getMetaData();
assertFalse(meta.supportsTransactionIsolationLevel(
Connection.TRANSACTION_READ_UNCOMMITTED));
conn.close();
deleteDb("concurrentAnalyze");
deleteDb("lockMode");
}
}
......@@ -859,9 +859,10 @@ public class TestSpatial extends TestBase {
try {
Statement stat = conn.createStatement();
stat.execute("drop table if exists pt_cloud;\n" +
"CREATE TABLE PT_CLOUD AS SELECT CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom from" +
"CREATE TABLE PT_CLOUD AS " +
" SELECT CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom from" +
" system_range(1e6,1e6+10) A,system_range(6e6,6e6+10) B;\n" +
"create spatial index ptindex on pt_cloud(the_geom);");
"create spatial index pt_index on pt_cloud(the_geom);");
// Wait some time
try {
Thread.sleep(1000);
......@@ -869,9 +870,10 @@ public class TestSpatial extends TestBase {
throw new SQLException(ex);
}
stat.execute("drop table if exists pt_cloud;\n" +
"CREATE TABLE PT_CLOUD AS SELECT CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom from" +
"CREATE TABLE PT_CLOUD AS " +
" SELECT CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom from" +
" system_range(1e6,1e6+50) A,system_range(6e6,6e6+50) B;\n" +
"create spatial index ptindex on pt_cloud(the_geom);\n" +
"create spatial index pt_index on pt_cloud(the_geom);\n" +
"shutdown compact;");
} finally {
// Close the database
......
......@@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.h2.mvstore.DataUtils;
import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVMapConcurrent;
import org.h2.mvstore.MVStore;
import org.h2.store.fs.FileChannelInputStream;
import org.h2.store.fs.FileUtils;
......@@ -186,8 +185,7 @@ public class TestConcurrent extends TestMVStore {
final MVStore s = new MVStore.Builder().
autoCommitDisabled().open();
s.setVersionsToKeep(10);
final MVMapConcurrent<Integer, Integer> m = s.openMap("data",
new MVMapConcurrent.Builder<Integer, Integer>());
final MVMap<Integer, Integer> m = s.openMap("data");
m.put(1, 1);
Task task = new Task() {
@Override
......@@ -374,8 +372,7 @@ public class TestConcurrent extends TestMVStore {
*/
private void testConcurrentMap() throws InterruptedException {
final MVStore s = openStore(null);
final MVMap<Integer, Integer> m = s.openMap("data",
new MVMapConcurrent.Builder<Integer, Integer>());
final MVMap<Integer, Integer> m = s.openMap("data");
final int size = 20;
final Random rand = new Random(1);
Task task = new Task() {
......
......@@ -56,7 +56,7 @@ public class TestMVRTree extends TestMVStore {
testRandom();
testRandomFind();
}
private void testRemoveAll() {
String fileName = getBaseDir() + "/testRemoveAll.h3";
FileUtils.delete(fileName);
......@@ -73,7 +73,7 @@ public class TestMVRTree extends TestMVStore {
}
s.commit();
map.clear();
s.close();
s.close();
}
private void testRandomInsert() {
......
......@@ -1278,10 +1278,13 @@ public class TestMVStore extends TestBase {
FileUtils.delete(fileName);
MVStore s;
s = openStore(fileName);
s.setVersionsToKeep(100);
s.setAutoCommitDelay(0);
s.setRetentionTime(Integer.MAX_VALUE);
MVMap<String, String> m;
m = s.openMap("data");
MVMap<String, String> m = s.openMap("data");
s.commit();
long first = s.getCurrentVersion();
m.put("0", "test");
s.commit();
m.put("1", "Hello");
m.put("2", "World");
......@@ -1351,10 +1354,12 @@ public class TestMVStore extends TestBase {
long len = FileUtils.size(fileName);
s = openStore(fileName);
s.setRetentionTime(0);
// remove 50%
// remove 75%
m = s.openMap("data");
for (int i = 0; i < 10; i += 2) {
m.remove(i);
for (int i = 0; i < 10; i++) {
if (i % 4 != 0) {
m.remove(i);
}
}
s.commit();
assertTrue(s.compact(100, 50 * 1024));
......
......@@ -146,18 +146,22 @@ public class TestMVStoreBenchmark extends TestBase {
if (!config.big) {
return;
}
// -mx12g -agentlib:hprof=heap=sites,depth=8
// int size = 1000;
int size = 1000000;
long hash = 0, tree = 0, mv = 0;
for (int i = 0; i < 5; i++) {
Map<Integer, String> map;
MVStore store = MVStore.open(null);
map = store.openMap("test");
mv = testPerformance(map, size);
map = new HashMap<Integer, String>(size);
// map = new ConcurrentHashMap<Integer, String>(size);
hash = testPerformance(map, size);
map = new TreeMap<Integer, String>();
// map = new ConcurrentSkipListMap<Integer, String>();
tree = testPerformance(map, size);
MVStore store = MVStore.open(null);
map = store.openMap("test");
mv = testPerformance(map, size);
if (hash < tree && mv < tree) {
if (hash < tree && mv < tree * 1.5) {
break;
}
}
......
......@@ -11,7 +11,6 @@ import java.util.Random;
import java.util.TreeMap;
import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVMapConcurrent;
import org.h2.mvstore.MVStore;
import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase;
......@@ -22,7 +21,6 @@ import org.h2.test.TestBase;
public class TestRandomMapOps extends TestBase {
private String fileName;
private boolean concurrent;
private int seed;
private int op;
......@@ -39,9 +37,6 @@ public class TestRandomMapOps extends TestBase {
@Override
public void test() throws Exception {
concurrent = false;
testMap("memFS:randomOps.h3");
concurrent = true;
testMap("memFS:randomOps.h3");
}
......@@ -82,11 +77,7 @@ public class TestRandomMapOps extends TestBase {
MVStore s;
s = openStore(fileName);
MVMap<Integer, byte[]> m;
if (concurrent) {
m = s.openMap("data", new MVMapConcurrent.Builder<Integer, byte[]>());
} else {
m = s.openMap("data");
}
m = s.openMap("data");
Random r = new Random(seed);
op = 0;
TreeMap<Integer, byte[]> map = new TreeMap<Integer, byte[]>();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论