提交 2d968c4c authored 作者: Thomas Mueller's avatar Thomas Mueller

A persistent multi-version map: rename built-in data type classes

上级 16d007fa
...@@ -25,13 +25,13 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> { ...@@ -25,13 +25,13 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
/** /**
* The spatial key type. * The spatial key type.
*/ */
final SpatialType keyType; final SpatialDataType keyType;
private boolean quadraticSplit; private boolean quadraticSplit;
public MVRTreeMap(int dimensions, DataType valueType) { public MVRTreeMap(int dimensions, DataType valueType) {
super(new SpatialType(dimensions), valueType); super(new SpatialDataType(dimensions), valueType);
this.keyType = (SpatialType) getKeyType(); this.keyType = (SpatialDataType) getKeyType();
} }
/** /**
......
...@@ -110,7 +110,7 @@ import org.h2.test.store.TestConcurrent; ...@@ -110,7 +110,7 @@ import org.h2.test.store.TestConcurrent;
import org.h2.test.store.TestDataUtils; import org.h2.test.store.TestDataUtils;
import org.h2.test.store.TestMVStore; import org.h2.test.store.TestMVStore;
import org.h2.test.store.TestMVRTree; import org.h2.test.store.TestMVRTree;
import org.h2.test.store.TestObjectType; import org.h2.test.store.TestObjectDataType;
import org.h2.test.store.TestStreamStore; import org.h2.test.store.TestStreamStore;
import org.h2.test.synth.TestBtreeIndex; import org.h2.test.synth.TestBtreeIndex;
import org.h2.test.synth.TestCrashAPI; import org.h2.test.synth.TestCrashAPI;
...@@ -682,7 +682,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -682,7 +682,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new TestDataUtils().runTest(this); new TestDataUtils().runTest(this);
new TestMVRTree().runTest(this); new TestMVRTree().runTest(this);
new TestMVStore().runTest(this); new TestMVStore().runTest(this);
new TestObjectType().runTest(this); new TestObjectDataType().runTest(this);
new TestStreamStore().runTest(this); new TestStreamStore().runTest(this);
// unit // unit
......
...@@ -21,20 +21,14 @@ public class SampleTypeFactory implements DataTypeFactory { ...@@ -21,20 +21,14 @@ public class SampleTypeFactory implements DataTypeFactory {
@Override @Override
public DataType buildDataType(String s) { public DataType buildDataType(String s) {
// if ("org.h2.test.store.int".equals(s)) { if (s.startsWith(RowDataType.PREFIX)) {
// return new IntegerType(); return RowDataType.fromString(s, this);
// } else
if (s.startsWith(RowType.PREFIX)) {
return RowType.fromString(s, this);
} }
return parent.buildDataType(s); return parent.buildDataType(s);
} }
@Override @Override
public String getDataType(Class<?> objectClass) { public String getDataType(Class<?> objectClass) {
// if (objectClass == Integer.class) {
// return "org.h2.test.store.int";
// }
return parent.getDataType(objectClass); return parent.getDataType(objectClass);
} }
......
...@@ -17,7 +17,7 @@ import java.util.Random; ...@@ -17,7 +17,7 @@ import java.util.Random;
import org.h2.mvstore.MVMap; import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVStore; import org.h2.mvstore.MVStore;
import org.h2.mvstore.MVStoreBuilder; import org.h2.mvstore.MVStoreBuilder;
import org.h2.mvstore.type.ObjectTypeFactory; import org.h2.mvstore.type.ObjectDataTypeFactory;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.Task; import org.h2.util.Task;
...@@ -133,7 +133,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -133,7 +133,7 @@ public class TestConcurrent extends TestMVStore {
private void testConcurrentIterate() { private void testConcurrentIterate() {
MVStore s = MVStoreBuilder.inMemory(). MVStore s = MVStoreBuilder.inMemory().
with(new ObjectTypeFactory()).open(); with(new ObjectDataTypeFactory()).open();
s.setPageSize(3); s.setPageSize(3);
final MVMap<Integer, Integer> map = s.openMap("test"); final MVMap<Integer, Integer> map = s.openMap("test");
final int len = 10; final int len = 10;
......
...@@ -23,8 +23,8 @@ import javax.imageio.stream.FileImageOutputStream; ...@@ -23,8 +23,8 @@ import javax.imageio.stream.FileImageOutputStream;
import org.h2.mvstore.MVStore; import org.h2.mvstore.MVStore;
import org.h2.mvstore.rtree.MVRTreeMap; import org.h2.mvstore.rtree.MVRTreeMap;
import org.h2.mvstore.rtree.SpatialKey; import org.h2.mvstore.rtree.SpatialKey;
import org.h2.mvstore.type.ObjectType; import org.h2.mvstore.type.ObjectDataType;
import org.h2.mvstore.type.StringType; import org.h2.mvstore.type.StringDataType;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.New; import org.h2.util.New;
...@@ -56,7 +56,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -56,7 +56,7 @@ public class TestMVRTree extends TestMVStore {
// create an R-tree map // create an R-tree map
// the key has 2 dimensions, the value is a string // the key has 2 dimensions, the value is a string
MVRTreeMap<String> r = MVRTreeMap.create(2, new ObjectType()); MVRTreeMap<String> r = MVRTreeMap.create(2, new ObjectDataType());
// open the map // open the map
r = s.openMap("data", r); r = s.openMap("data", r);
...@@ -84,7 +84,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -84,7 +84,7 @@ public class TestMVRTree extends TestMVStore {
MVStore s; MVStore s;
s = openStore(fileName); s = openStore(fileName);
// s.setMaxPageSize(50); // s.setMaxPageSize(50);
MVRTreeMap<String> r = MVRTreeMap.create(2, StringType.INSTANCE); MVRTreeMap<String> r = MVRTreeMap.create(2, StringDataType.INSTANCE);
r = s.openMap("data", r); r = s.openMap("data", r);
// r.setQuadraticSplit(true); // r.setQuadraticSplit(true);
Random rand = new Random(1); Random rand = new Random(1);
...@@ -109,7 +109,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -109,7 +109,7 @@ public class TestMVRTree extends TestMVStore {
s.store(); s.store();
s.close(); s.close();
s = openStore(fileName); s = openStore(fileName);
r = MVRTreeMap.create(2, StringType.INSTANCE); r = MVRTreeMap.create(2, StringDataType.INSTANCE);
r = s.openMap("data", r); r = s.openMap("data", r);
// t = System.currentTimeMillis(); // t = System.currentTimeMillis();
rand = new Random(1); rand = new Random(1);
...@@ -148,7 +148,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -148,7 +148,7 @@ public class TestMVRTree extends TestMVStore {
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
s = openStore(fileName); s = openStore(fileName);
MVRTreeMap<String> r = MVRTreeMap.create(2, StringType.INSTANCE); MVRTreeMap<String> r = MVRTreeMap.create(2, StringDataType.INSTANCE);
r = s.openMap("data", r); r = s.openMap("data", r);
add(r, "Bern", key(0, 46.57, 7.27, 124381)); add(r, "Bern", key(0, 46.57, 7.27, 124381));
add(r, "Basel", key(1, 47.34, 7.36, 170903)); add(r, "Basel", key(1, 47.34, 7.36, 170903));
...@@ -268,7 +268,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -268,7 +268,7 @@ public class TestMVRTree extends TestMVStore {
String fileName = getBaseDir() + "/testRandom.h3"; String fileName = getBaseDir() + "/testRandom.h3";
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVRTreeMap<String> m = MVRTreeMap.create(2, StringType.INSTANCE); MVRTreeMap<String> m = MVRTreeMap.create(2, StringDataType.INSTANCE);
m = s.openMap("data", m); m = s.openMap("data", m);
HashMap<SpatialKey, String> map = new HashMap<SpatialKey, String>(); HashMap<SpatialKey, String> map = new HashMap<SpatialKey, String>();
Random rand = new Random(1); Random rand = new Random(1);
......
...@@ -18,9 +18,9 @@ import org.h2.mvstore.MVMap; ...@@ -18,9 +18,9 @@ import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVStore; import org.h2.mvstore.MVStore;
import org.h2.mvstore.MVStoreBuilder; import org.h2.mvstore.MVStoreBuilder;
import org.h2.mvstore.type.DataType; import org.h2.mvstore.type.DataType;
import org.h2.mvstore.type.ObjectType; import org.h2.mvstore.type.ObjectDataType;
import org.h2.mvstore.type.ObjectTypeFactory; import org.h2.mvstore.type.ObjectDataTypeFactory;
import org.h2.mvstore.type.StringType; import org.h2.mvstore.type.StringDataType;
import org.h2.store.fs.FilePath; import org.h2.store.fs.FilePath;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
...@@ -93,7 +93,8 @@ public class TestMVStore extends TestBase { ...@@ -93,7 +93,8 @@ public class TestMVStore extends TestBase {
MVStore s; MVStore s;
MVMap<Integer, String> map; MVMap<Integer, String> map;
s = MVStoreBuilder.fileBased(fileName). s = MVStoreBuilder.fileBased(fileName).
with(new ObjectTypeFactory()).open(); compressData().
with(new ObjectDataTypeFactory()).open();
map = s.openMap("test"); map = s.openMap("test");
// add 10 MB of data // add 10 MB of data
for (int i = 0; i < 1024; i++) { for (int i = 0; i < 1024; i++) {
...@@ -107,7 +108,7 @@ public class TestMVStore extends TestBase { ...@@ -107,7 +108,7 @@ public class TestMVStore extends TestBase {
for (int cacheSize = 0; cacheSize <= 6; cacheSize += 4) { for (int cacheSize = 0; cacheSize <= 6; cacheSize += 4) {
s = MVStoreBuilder.fileBased(fileName). s = MVStoreBuilder.fileBased(fileName).
cacheSizeMB(1 + 3 * cacheSize). cacheSizeMB(1 + 3 * cacheSize).
with(new ObjectTypeFactory()).open(); with(new ObjectDataTypeFactory()).open();
map = s.openMap("test"); map = s.openMap("test");
for (int i = 0; i < 1024; i += 128) { for (int i = 0; i < 1024; i += 128) {
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
...@@ -329,7 +330,7 @@ public class TestMVStore extends TestBase { ...@@ -329,7 +330,7 @@ public class TestMVStore extends TestBase {
MVStore s; MVStore s;
Map<Integer, Integer> map; Map<Integer, Integer> map;
s = MVStoreBuilder.inMemory(). s = MVStoreBuilder.inMemory().
with(new ObjectTypeFactory()).open(); with(new ObjectDataTypeFactory()).open();
map = s.openMap("test"); map = s.openMap("test");
int len = 100; int len = 100;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
...@@ -355,7 +356,7 @@ public class TestMVStore extends TestBase { ...@@ -355,7 +356,7 @@ public class TestMVStore extends TestBase {
MVStore s; MVStore s;
Map<Object, Object> map; Map<Object, Object> map;
s = MVStoreBuilder.fileBased(fileName). s = MVStoreBuilder.fileBased(fileName).
with(new ObjectTypeFactory()).open(); with(new ObjectDataTypeFactory()).open();
map = s.openMap("test"); map = s.openMap("test");
map.put(1, "Hello"); map.put(1, "Hello");
map.put("2", 200); map.put("2", 200);
...@@ -363,7 +364,7 @@ public class TestMVStore extends TestBase { ...@@ -363,7 +364,7 @@ public class TestMVStore extends TestBase {
s.store(); s.store();
s.close(); s.close();
s = MVStoreBuilder.fileBased(fileName). s = MVStoreBuilder.fileBased(fileName).
with(new ObjectTypeFactory()).open(); with(new ObjectDataTypeFactory()).open();
map = s.openMap("test"); map = s.openMap("test");
assertEquals("Hello", map.get(1).toString()); assertEquals("Hello", map.get(1).toString());
assertEquals(200, ((Integer) map.get("2")).intValue()); assertEquals(200, ((Integer) map.get("2")).intValue());
...@@ -791,11 +792,11 @@ public class TestMVStore extends TestBase { ...@@ -791,11 +792,11 @@ public class TestMVStore extends TestBase {
// s.setCompressor(null); // s.setCompressor(null);
s.setPageSize(40); s.setPageSize(40);
MVMap<Integer, Object[]> m = new MVMap<Integer, Object[]>( MVMap<Integer, Object[]> m = new MVMap<Integer, Object[]>(
new ObjectType(), new ObjectDataType(),
new RowType(new DataType[] { new RowDataType(new DataType[] {
new ObjectType(), new ObjectDataType(),
StringType.INSTANCE, StringDataType.INSTANCE,
StringType.INSTANCE StringDataType.INSTANCE
}) })
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论