Package org.h2.mvstore.type
Class ObjectDataType
- All Implemented Interfaces:
Comparator<Object>
,DataType<Object>
A data type implementation for the most common data types, including
serializable objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
The base class for auto-detect data types.(package private) static class
The type for BigDecimal objects.(package private) static class
The type for BigInteger objects.(package private) static class
The type for boolean true and false.(package private) static class
The type for byte objects.(package private) static class
The type for character objects.(package private) static class
The type for java.util.Date objects.(package private) static class
The type for double objects.(package private) static class
The type for float objects.private static class
(package private) static class
The type for integer objects.(package private) static class
The type for long objects.(package private) static class
The type for the null value(package private) static class
The type for object arrays.(package private) static class
The type for serialized objects.(package private) static class
The type for short objects.(package private) static class
The type for string objects.(package private) static class
The type for UUID objects. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Class<?>[]
(package private) static final long
(package private) static final long
(package private) static final int
(package private) static final int
Constants for floating point synchronization.private ObjectDataType.AutoDetectDataType
<Object> (package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
For very common values (e.g.(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
For small-values/small-arrays, we encode the value/array-length in the tag.(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
The type constants are also used as tag values.(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compare two keys.static int
compareNotNull
(byte[] data1, byte[] data2) Compare the contents of two byte arrays.Object[]
createStorage
(int size) Create storage object of array type to hold valuesstatic Object
deserialize
(byte[] data) De-serialize the byte array to an object.int
Calculates the amount of used memory in bytes.private static int
(package private) static boolean
Check whether this object is an array.(package private) static boolean
isBigDecimal
(Object obj) Check whether this object is a BigDecimal.(package private) static boolean
isBigInteger
(Object obj) Check whether this object is a BigInteger.(package private) static boolean
Check whether this object is a date.private ObjectDataType.AutoDetectDataType
<Object> newType
(int typeId) read
(ByteBuffer buff) Read an object.selectDataType
(int typeId) static byte[]
Serialize the object to a byte array.(package private) ObjectDataType.AutoDetectDataType
<Object> switchType
(Object obj) Switch the last remembered type to match the type of the given object.void
write
(WriteBuffer buff, Object obj) Write an object.Methods inherited from class org.h2.mvstore.type.BasicDataType
binarySearch, cast, equals, hashCode, isMemoryEstimationAllowed, read, write
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
TYPE_NULL
static final int TYPE_NULLThe type constants are also used as tag values.- See Also:
-
TYPE_BOOLEAN
static final int TYPE_BOOLEAN- See Also:
-
TYPE_BYTE
static final int TYPE_BYTE- See Also:
-
TYPE_SHORT
static final int TYPE_SHORT- See Also:
-
TYPE_INT
static final int TYPE_INT- See Also:
-
TYPE_LONG
static final int TYPE_LONG- See Also:
-
TYPE_BIG_INTEGER
static final int TYPE_BIG_INTEGER- See Also:
-
TYPE_FLOAT
static final int TYPE_FLOAT- See Also:
-
TYPE_DOUBLE
static final int TYPE_DOUBLE- See Also:
-
TYPE_BIG_DECIMAL
static final int TYPE_BIG_DECIMAL- See Also:
-
TYPE_CHAR
static final int TYPE_CHAR- See Also:
-
TYPE_STRING
static final int TYPE_STRING- See Also:
-
TYPE_UUID
static final int TYPE_UUID- See Also:
-
TYPE_DATE
static final int TYPE_DATE- See Also:
-
TYPE_ARRAY
static final int TYPE_ARRAY- See Also:
-
TYPE_SERIALIZED_OBJECT
static final int TYPE_SERIALIZED_OBJECT- See Also:
-
TAG_BOOLEAN_TRUE
static final int TAG_BOOLEAN_TRUEFor very common values (e.g. 0 and 1) we save space by encoding the value in the tag. e.g. TAG_BOOLEAN_TRUE and TAG_FLOAT_0.- See Also:
-
TAG_INTEGER_NEGATIVE
static final int TAG_INTEGER_NEGATIVE- See Also:
-
TAG_INTEGER_FIXED
static final int TAG_INTEGER_FIXED- See Also:
-
TAG_LONG_NEGATIVE
static final int TAG_LONG_NEGATIVE- See Also:
-
TAG_LONG_FIXED
static final int TAG_LONG_FIXED- See Also:
-
TAG_BIG_INTEGER_0
static final int TAG_BIG_INTEGER_0- See Also:
-
TAG_BIG_INTEGER_1
static final int TAG_BIG_INTEGER_1- See Also:
-
TAG_BIG_INTEGER_SMALL
static final int TAG_BIG_INTEGER_SMALL- See Also:
-
TAG_FLOAT_0
static final int TAG_FLOAT_0- See Also:
-
TAG_FLOAT_1
static final int TAG_FLOAT_1- See Also:
-
TAG_FLOAT_FIXED
static final int TAG_FLOAT_FIXED- See Also:
-
TAG_DOUBLE_0
static final int TAG_DOUBLE_0- See Also:
-
TAG_DOUBLE_1
static final int TAG_DOUBLE_1- See Also:
-
TAG_DOUBLE_FIXED
static final int TAG_DOUBLE_FIXED- See Also:
-
TAG_BIG_DECIMAL_0
static final int TAG_BIG_DECIMAL_0- See Also:
-
TAG_BIG_DECIMAL_1
static final int TAG_BIG_DECIMAL_1- See Also:
-
TAG_BIG_DECIMAL_SMALL
static final int TAG_BIG_DECIMAL_SMALL- See Also:
-
TAG_BIG_DECIMAL_SMALL_SCALED
static final int TAG_BIG_DECIMAL_SMALL_SCALED- See Also:
-
TAG_INTEGER_0_15
static final int TAG_INTEGER_0_15For small-values/small-arrays, we encode the value/array-length in the tag.- See Also:
-
TAG_LONG_0_7
static final int TAG_LONG_0_7- See Also:
-
TAG_STRING_0_15
static final int TAG_STRING_0_15- See Also:
-
TAG_BYTE_ARRAY_0_15
static final int TAG_BYTE_ARRAY_0_15- See Also:
-
FLOAT_ZERO_BITS
static final int FLOAT_ZERO_BITSConstants for floating point synchronization. -
FLOAT_ONE_BITS
static final int FLOAT_ONE_BITS -
DOUBLE_ZERO_BITS
static final long DOUBLE_ZERO_BITS -
DOUBLE_ONE_BITS
static final long DOUBLE_ONE_BITS -
COMMON_CLASSES
-
last
-
-
Constructor Details
-
ObjectDataType
public ObjectDataType()
-
-
Method Details
-
createStorage
Description copied from interface:DataType
Create storage object of array type to hold values- Parameters:
size
- number of values to hold- Returns:
- storage object
-
compare
Description copied from interface:DataType
Compare two keys.- Specified by:
compare
in interfaceComparator<Object>
- Specified by:
compare
in interfaceDataType<Object>
- Overrides:
compare
in classBasicDataType<Object>
- Parameters:
a
- the first keyb
- the second key- Returns:
- -1 if the first key is smaller, 1 if larger, and 0 if equal
-
getMemory
Description copied from interface:DataType
Calculates the amount of used memory in bytes. -
write
Description copied from interface:DataType
Write an object. -
newType
-
selectDataType
-
read
Description copied from interface:DataType
Read an object. -
getTypeId
-
switchType
Switch the last remembered type to match the type of the given object.- Parameters:
obj
- the object- Returns:
- the auto-detected type used
-
isBigInteger
Check whether this object is a BigInteger.- Parameters:
obj
- the object- Returns:
- true if yes
-
isBigDecimal
Check whether this object is a BigDecimal.- Parameters:
obj
- the object- Returns:
- true if yes
-
isDate
Check whether this object is a date.- Parameters:
obj
- the object- Returns:
- true if yes
-
isArray
Check whether this object is an array.- Parameters:
obj
- the object- Returns:
- true if yes
-
serialize
Serialize the object to a byte array.- Parameters:
obj
- the object to serialize- Returns:
- the byte array
-
deserialize
De-serialize the byte array to an object.- Parameters:
data
- the byte array- Returns:
- the object
-
compareNotNull
public static int compareNotNull(byte[] data1, byte[] data2) Compare the contents of two byte arrays. If the content or length of the first array is smaller than the second array, -1 is returned. If the content or length of the second array is smaller than the first array, 1 is returned. If the contents and lengths are the same, 0 is returned.This method interprets bytes as unsigned.
- Parameters:
data1
- the first byte array (must not be null)data2
- the second byte array (must not be null)- Returns:
- the result of the comparison (-1, 1 or 0)
-