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 classThe base class for auto-detect data types.(package private) static classThe type for BigDecimal objects.(package private) static classThe type for BigInteger objects.(package private) static classThe type for boolean true and false.(package private) static classThe type for byte objects.(package private) static classThe type for character objects.(package private) static classThe type for java.util.Date objects.(package private) static classThe type for double objects.(package private) static classThe type for float objects.private static class(package private) static classThe type for integer objects.(package private) static classThe type for long objects.(package private) static classThe type for the null value(package private) static classThe type for object arrays.(package private) static classThe type for serialized objects.(package private) static classThe type for short objects.(package private) static classThe type for string objects.(package private) static classThe 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 intConstants 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 intFor 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 intFor 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 intThe 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 TypeMethodDescriptionintCompare two keys.static intcompareNotNull(byte[] data1, byte[] data2) Compare the contents of two byte arrays.Object[]createStorage(int size) Create storage object of array type to hold valuesstatic Objectdeserialize(byte[] data) De-serialize the byte array to an object.intCalculates the amount of used memory in bytes.private static int(package private) static booleanCheck whether this object is an array.(package private) static booleanisBigDecimal(Object obj) Check whether this object is a BigDecimal.(package private) static booleanisBigInteger(Object obj) Check whether this object is a BigInteger.(package private) static booleanCheck 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.voidwrite(WriteBuffer buff, Object obj) Write an object.Methods inherited from class BasicDataType
binarySearch, cast, equals, hashCode, isMemoryEstimationAllowed, read, writeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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
-
compare
Description copied from interface:DataTypeCompare two keys.- Specified by:
comparein interfaceComparator<Object>- Specified by:
comparein interfaceDataType<Object>- Overrides:
comparein 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
-
write
Description copied from interface:DataTypeWrite an object. -
newType
-
selectDataType
-
read
Description copied from interface:DataTypeRead 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)
-