提交 47e6588f authored 作者: Thomas Mueller's avatar Thomas Mueller

Various bugs in the MVStore storage and have been fixed.

上级 809d44cf
...@@ -18,10 +18,11 @@ Change Log ...@@ -18,10 +18,11 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>The method org.h2.expression.Function.getCost could throw a NullPointException. <ul><li>Various bugs in the MVStore storage and have been fixed.
</li><li>The method org.h2.expression.Function.getCost could throw a NullPointException.
</li><li>Storing LOBs in separate files (outside of the database) is no longer supported for new databases. </li><li>Storing LOBs in separate files (outside of the database) is no longer supported for new databases.
</li><li>Lucene 2 is no longer supported. </li><li>Lucene 2 is no longer supported.
</li><li>Fix bug in calculating default MIN and MAX values for SEQUENCE </li><li>Fix bug in calculating default MIN and MAX values for SEQUENCE.
</li></ul> </li></ul>
<h2>Version 1.3.175 (2014-01-18)</h2> <h2>Version 1.3.175 (2014-01-18)</h2>
......
...@@ -1477,7 +1477,8 @@ public class MVStore { ...@@ -1477,7 +1477,8 @@ public class MVStore {
// This could result in a cache miss if the operation is rolled back, // This could result in a cache miss if the operation is rolled back,
// but we don't optimize for rollback. // but we don't optimize for rollback.
// We could also keep the page in the cache, as somebody could read it. // We could also keep the page in the cache, as somebody
// could still read it (reading the old version).
if (cache != null) { if (cache != null) {
cache.remove(pos); cache.remove(pos);
} }
......
...@@ -255,30 +255,31 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> { ...@@ -255,30 +255,31 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
* @param p the page * @param p the page
* @param writeVersion the write version * @param writeVersion the write version
* @param key the key * @param key the key
* @param value the value * @param value the new value
* @return the old value * @return the old value (never null)
*/ */
private Object set(Page p, long writeVersion, Object key, Object value) { private Object set(Page p, long writeVersion, Object key, Object value) {
if (!p.isLeaf()) { if (p.isLeaf()) {
for (int i = 0; i < p.getKeyCount(); i++) {
if (keyType.equals(p.getKey(i), key)) {
return p.setValue(i, value);
}
}
} else {
for (int i = 0; i < p.getKeyCount(); i++) { for (int i = 0; i < p.getKeyCount(); i++) {
if (contains(p, i, key)) { if (contains(p, i, key)) {
Page c = copyOnWrite(p.getChildPage(i), writeVersion); Page c = p.getChildPage(i);
if (get(c, key) != null) {
c = copyOnWrite(c, writeVersion);
Object result = set(c, writeVersion, key, value); Object result = set(c, writeVersion, key, value);
if (result != null) {
p.setChild(i, c); p.setChild(i, c);
p.setCounts(i, c); p.setCounts(i, c);
return result; return result;
} }
} }
} }
} else {
for (int i = 0; i < p.getKeyCount(); i++) {
if (keyType.equals(p.getKey(i), key)) {
return p.setValue(i, value);
}
}
} }
return null; throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL, "Not found: {0}", key);
} }
private void add(Page p, long writeVersion, Object key, Object value) { private void add(Page p, long writeVersion, Object key, Object value) {
......
...@@ -47,6 +47,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -47,6 +47,7 @@ public class TestMVRTree extends TestMVStore {
FileUtils.deleteRecursive(getBaseDir(), true); FileUtils.deleteRecursive(getBaseDir(), true);
FileUtils.createDirectories(getBaseDir()); FileUtils.createDirectories(getBaseDir());
testRandomInsert();
testSpatialKey(); testSpatialKey();
testExample(); testExample();
testMany(); testMany();
...@@ -55,6 +56,29 @@ public class TestMVRTree extends TestMVStore { ...@@ -55,6 +56,29 @@ public class TestMVRTree extends TestMVStore {
testRandomFind(); testRandomFind();
} }
private void testRandomInsert() {
String fileName = getBaseDir() + "/testMany.h3";
FileUtils.delete(fileName);
MVStore s;
s = new MVStore.Builder().fileName(fileName).
pageSplitSize(100).open();
MVRTreeMap<String> map = s.openMap("data",
new MVRTreeMap.Builder<String>());
Random r = new Random(1);
for (int i = 0; i < 1000; i++) {
if (i % 100 == 0) {
r.setSeed(1);
}
float x = r.nextFloat() * 50, y = r.nextFloat() * 50;
SpatialKey k = new SpatialKey(i % 100, x, x + 2, y, y + 1);
map.put(k, "i:" + i);
if (i % 10 == 0) {
s.commit();
}
}
s.close();
}
private void testSpatialKey() { private void testSpatialKey() {
SpatialKey a0 = new SpatialKey(0, 1, 2, 3, 4); SpatialKey a0 = new SpatialKey(0, 1, 2, 3, 4);
SpatialKey a1 = new SpatialKey(0, 1, 2, 3, 4); SpatialKey a1 = new SpatialKey(0, 1, 2, 3, 4);
......
...@@ -47,6 +47,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -47,6 +47,8 @@ public class TestMVTableEngine extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
testGarbageCollectionForLOB();
testSpatial();
testCount(); testCount();
testMinMaxWithNull(); testMinMaxWithNull();
testTimeout(); testTimeout();
...@@ -72,6 +74,31 @@ public class TestMVTableEngine extends TestBase { ...@@ -72,6 +74,31 @@ public class TestMVTableEngine extends TestBase {
testSimple(); testSimple();
} }
private void testGarbageCollectionForLOB() throws SQLException {
// TODO Auto-generated method stub
}
private void testSpatial() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("call rand(1)");
stat.execute("create table coords as select rand()*50 x, " +
"rand()*50 y from system_range(1, 5000)");
stat.execute("create table geoms(id identity, the_geom geometry)");
stat.execute("create spatial index on geoms(the_geom)");
stat.execute("insert into geoms(the_geom) select 'polygon(('||" +
"(1+x)||' '||(1+y)||', '||(2+x)||' '||(2+y)||', "+
"'||(3+x)||' '||(1+y)||', '||(1+x)||' '||(1+y)||'))' from coords;");
conn.close();
}
private void testCount() throws Exception { private void testCount() throws Exception {
if (config.memory) { if (config.memory) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论