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.
-
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.read(ByteBuffer buff) Read an object.static byte[]Serialize the object to a byte array.voidwrite(WriteBuffer buff, Object obj) Write an object.Methods inherited from class org.h2.mvstore.type.BasicDataType
binarySearch, cast, equals, hashCode, isMemoryEstimationAllowed, read, writeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ObjectDataType
public ObjectDataType()
-
-
Method Details
-
createStorage
Description copied from interface:DataTypeCreate storage object of array type to hold values- Parameters:
size- number of values to hold- Returns:
- storage object
-
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
Description copied from interface:DataTypeCalculates the amount of used memory in bytes. -
write
Description copied from interface:DataTypeWrite an object. -
read
Description copied from interface:DataTypeRead an object. -
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)
-