提交 56fe701d authored 作者: Thomas Mueller's avatar Thomas Mueller

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

上级 0d1713bb
......@@ -16,11 +16,11 @@ import org.h2.mvstore.type.DataType;
* can have a minimum and a maximum value of type float. For each dimension, the
* maximum value is only stored when it is not the same as the minimum.
*/
public class SpatialType implements DataType {
public class SpatialDataType implements DataType {
private final int dimensions;
public SpatialType(int dimensions) {
public SpatialDataType(int dimensions) {
if (dimensions <= 0 || dimensions > 255) {
throw new IllegalArgumentException("Dimensions: " + dimensions);
}
......@@ -33,8 +33,8 @@ public class SpatialType implements DataType {
* @param s the string
* @return the value
*/
public static SpatialType fromString(String s) {
return new SpatialType(Integer.parseInt(s.substring(1)));
public static SpatialDataType fromString(String s) {
return new SpatialDataType(Integer.parseInt(s.substring(1)));
}
@Override
......
......@@ -17,7 +17,7 @@ import org.h2.util.Utils;
* A data type implementation for the most common data types, including
* serializable objects.
*/
public class ObjectType implements DataType {
public class ObjectDataType implements DataType {
// TODO maybe support InputStream, Reader
// TODO maybe support ResultSet, Date, Time, Timestamp
......@@ -341,10 +341,10 @@ public class ObjectType implements DataType {
*/
abstract class AutoDetectDataType implements DataType {
protected final ObjectType base;
protected final ObjectDataType base;
protected final int typeId;
AutoDetectDataType(ObjectType base, int typeId) {
AutoDetectDataType(ObjectDataType base, int typeId) {
this.base = base;
this.typeId = typeId;
}
......@@ -411,7 +411,7 @@ public class ObjectType implements DataType {
*/
class BooleanType extends AutoDetectDataType {
BooleanType(ObjectType base) {
BooleanType(ObjectDataType base) {
super(base, TYPE_BOOLEAN);
}
......@@ -457,7 +457,7 @@ public class ObjectType implements DataType {
*/
class ByteType extends AutoDetectDataType {
ByteType(ObjectType base) {
ByteType(ObjectDataType base) {
super(base, TYPE_BYTE);
}
......@@ -502,7 +502,7 @@ public class ObjectType implements DataType {
*/
class CharacterType extends AutoDetectDataType {
CharacterType(ObjectType base) {
CharacterType(ObjectDataType base) {
super(base, TYPE_CHARACTER);
}
......@@ -548,7 +548,7 @@ public class ObjectType implements DataType {
*/
class ShortType extends AutoDetectDataType {
ShortType(ObjectType base) {
ShortType(ObjectDataType base) {
super(base, TYPE_SHORT);
}
......@@ -594,7 +594,7 @@ public class ObjectType implements DataType {
*/
class IntegerType extends AutoDetectDataType {
IntegerType(ObjectType base) {
IntegerType(ObjectDataType base) {
super(base, TYPE_INTEGER);
}
......@@ -667,7 +667,7 @@ public class ObjectType implements DataType {
*/
public class LongType extends AutoDetectDataType {
LongType(ObjectType base) {
LongType(ObjectDataType base) {
super(base, TYPE_LONG);
}
......@@ -740,7 +740,7 @@ public class ObjectType implements DataType {
*/
class FloatType extends AutoDetectDataType {
FloatType(ObjectType base) {
FloatType(ObjectDataType base) {
super(base, TYPE_FLOAT);
}
......@@ -771,9 +771,9 @@ public class ObjectType implements DataType {
if (obj instanceof Float) {
float x = (Float) obj;
int f = Float.floatToIntBits(x);
if (f == ObjectType.FLOAT_ZERO_BITS) {
if (f == ObjectDataType.FLOAT_ZERO_BITS) {
buff.put((byte) TAG_FLOAT_0);
} else if (f == ObjectType.FLOAT_ONE_BITS) {
} else if (f == ObjectDataType.FLOAT_ONE_BITS) {
buff.put((byte) TAG_FLOAT_1);
} else {
int value = Integer.reverse(f);
......@@ -810,7 +810,7 @@ public class ObjectType implements DataType {
*/
class DoubleType extends AutoDetectDataType {
DoubleType(ObjectType base) {
DoubleType(ObjectDataType base) {
super(base, TYPE_DOUBLE);
}
......@@ -841,9 +841,9 @@ public class ObjectType implements DataType {
if (obj instanceof Double) {
double x = (Double) obj;
long d = Double.doubleToLongBits(x);
if (d == ObjectType.DOUBLE_ZERO_BITS) {
if (d == ObjectDataType.DOUBLE_ZERO_BITS) {
buff.put((byte) TAG_DOUBLE_0);
} else if (d == ObjectType.DOUBLE_ONE_BITS) {
} else if (d == ObjectDataType.DOUBLE_ONE_BITS) {
buff.put((byte) TAG_DOUBLE_1);
} else {
long value = Long.reverse(d);
......@@ -880,7 +880,7 @@ public class ObjectType implements DataType {
*/
class BigIntegerType extends AutoDetectDataType {
BigIntegerType(ObjectType base) {
BigIntegerType(ObjectDataType base) {
super(base, TYPE_BIG_INTEGER);
}
......@@ -964,7 +964,7 @@ public class ObjectType implements DataType {
*/
class BigDecimalType extends AutoDetectDataType {
BigDecimalType(ObjectType base) {
BigDecimalType(ObjectDataType base) {
super(base, TYPE_BIG_DECIMAL);
}
......@@ -1068,7 +1068,7 @@ public class ObjectType implements DataType {
*/
class StringType extends AutoDetectDataType {
StringType(ObjectType base) {
StringType(ObjectDataType base) {
super(base, TYPE_STRING);
}
......@@ -1131,7 +1131,7 @@ public class ObjectType implements DataType {
*/
class UUIDType extends AutoDetectDataType {
UUIDType(ObjectType base) {
UUIDType(ObjectDataType base) {
super(base, TYPE_UUID);
}
......@@ -1183,7 +1183,7 @@ public class ObjectType implements DataType {
*/
class ByteArrayType extends AutoDetectDataType {
ByteArrayType(ObjectType base) {
ByteArrayType(ObjectDataType base) {
super(base, TYPE_BYTE_ARRAY);
}
......@@ -1250,7 +1250,7 @@ public class ObjectType implements DataType {
*/
class CharArrayType extends AutoDetectDataType {
CharArrayType(ObjectType base) {
CharArrayType(ObjectDataType base) {
super(base, TYPE_CHAR_ARRAY);
}
......@@ -1310,7 +1310,7 @@ public class ObjectType implements DataType {
*/
class IntArrayType extends AutoDetectDataType {
IntArrayType(ObjectType base) {
IntArrayType(ObjectDataType base) {
super(base, TYPE_INT_ARRAY);
}
......@@ -1370,7 +1370,7 @@ public class ObjectType implements DataType {
*/
class LongArrayType extends AutoDetectDataType {
LongArrayType(ObjectType base) {
LongArrayType(ObjectDataType base) {
super(base, TYPE_LONG_ARRAY);
}
......@@ -1430,7 +1430,7 @@ public class ObjectType implements DataType {
*/
class SerializedObjectType extends AutoDetectDataType {
SerializedObjectType(ObjectType base) {
SerializedObjectType(ObjectDataType base) {
super(base, TYPE_SERIALIZED_OBJECT);
}
......
......@@ -5,12 +5,12 @@
*/
package org.h2.mvstore.type;
import org.h2.mvstore.rtree.SpatialType;
import org.h2.mvstore.rtree.SpatialDataType;
/**
* A data type factory.
*/
public class ObjectTypeFactory implements DataTypeFactory {
public class ObjectDataTypeFactory implements DataTypeFactory {
@Override
public void setParent(DataTypeFactory parent) {
......@@ -20,16 +20,16 @@ public class ObjectTypeFactory implements DataTypeFactory {
@Override
public DataType buildDataType(String s) {
if ("s".equals(s)) {
return SpatialType.fromString(s);
return SpatialDataType.fromString(s);
} else if ("o".equals(s)) {
return new ObjectType();
return new ObjectDataType();
}
return null;
}
@Override
public String getDataType(Class<?> objectClass) {
if (objectClass == SpatialType.class) {
if (objectClass == SpatialDataType.class) {
return "s";
}
return "o";
......
......@@ -12,9 +12,9 @@ import org.h2.mvstore.DataUtils;
/**
* A string type.
*/
public class StringType implements DataType {
public class StringDataType implements DataType {
public static final StringType INSTANCE = new StringType();
public static final StringDataType INSTANCE = new StringDataType();
public int compare(Object a, Object b) {
return a.toString().compareTo(b.toString());
......
......@@ -15,13 +15,13 @@ import org.h2.util.StringUtils;
/**
* A row type.
*/
public class RowType implements DataType {
public class RowDataType implements DataType {
static final String PREFIX = "org.h2.test.store.row";
private final DataType[] types;
RowType(DataType[] types) {
RowDataType(DataType[] types) {
this.types = types;
}
......@@ -107,7 +107,7 @@ public class RowType implements DataType {
* @param factory the data type factory
* @return the row type
*/
static RowType fromString(String t, DataTypeFactory factory) {
static RowDataType fromString(String t, DataTypeFactory factory) {
if (!t.startsWith(PREFIX) || !t.endsWith(")")) {
throw new RuntimeException("Unknown type: " + t);
}
......@@ -117,7 +117,7 @@ public class RowType implements DataType {
for (int i = 0; i < array.length; i++) {
types[i] = factory.buildDataType(array[i]);
}
return new RowType(types);
return new RowDataType(types);
}
}
......@@ -13,13 +13,13 @@ import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Random;
import java.util.UUID;
import org.h2.mvstore.type.ObjectType;
import org.h2.mvstore.type.ObjectDataType;
import org.h2.test.TestBase;
/**
* Test the ObjectType class.
*/
public class TestObjectType extends TestBase {
public class TestObjectDataType extends TestBase {
/**
* Run just this test.
......@@ -37,7 +37,7 @@ public class TestObjectType extends TestBase {
private void testCommonValues() {
BigInteger largeBigInt = BigInteger.probablePrime(200, new Random(1));
ObjectType ot = new ObjectType();
ObjectDataType ot = new ObjectDataType();
assertEquals("o", ot.asString());
Object[] array = {
false, true,
......@@ -104,7 +104,7 @@ public class TestObjectType extends TestBase {
}
private void test(Object last, Object x) {
ObjectType ot = new ObjectType();
ObjectDataType ot = new ObjectDataType();
// switch to the last type before every operation,
// to test switching types
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论