Package org.h2.mvstore.type
Class IntegerDataType
- java.lang.Object
-
- org.h2.mvstore.type.BasicDataType<java.lang.Integer>
-
- org.h2.mvstore.type.IntegerDataType
-
- All Implemented Interfaces:
java.util.Comparator<java.lang.Integer>,DataType<java.lang.Integer>
public class IntegerDataType extends BasicDataType<java.lang.Integer>
Class IntegerDataType.- 4/10/24 1:18 PM initial creation
-
-
Field Summary
Fields Modifier and Type Field Description static IntegerDataTypeINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbinarySearch(java.lang.Integer keyObj, java.lang.Object storageObj, int size, int initialGuess)Perform binary search for the key within the storageintcompare(java.lang.Integer one, java.lang.Integer two)Compare two keys.java.lang.Integer[]createStorage(int size)Create storage object of array type to hold valuesintgetMemory(java.lang.Integer obj)Calculates the amount of used memory in bytes.java.lang.Integerread(java.nio.ByteBuffer buff)Read an object.voidwrite(WriteBuffer buff, java.lang.Integer data)Write an object.-
Methods inherited from class org.h2.mvstore.type.BasicDataType
cast, equals, hashCode, isMemoryEstimationAllowed, read, write
-
-
-
-
Field Detail
-
INSTANCE
public static final IntegerDataType INSTANCE
-
-
Method Detail
-
getMemory
public int getMemory(java.lang.Integer obj)
Description copied from interface:DataTypeCalculates the amount of used memory in bytes.- Specified by:
getMemoryin interfaceDataType<java.lang.Integer>- Specified by:
getMemoryin classBasicDataType<java.lang.Integer>- Parameters:
obj- the object- Returns:
- the used memory
-
write
public void write(WriteBuffer buff, java.lang.Integer data)
Description copied from interface:DataTypeWrite an object.- Specified by:
writein interfaceDataType<java.lang.Integer>- Specified by:
writein classBasicDataType<java.lang.Integer>- Parameters:
buff- the target bufferdata- the value
-
read
public java.lang.Integer read(java.nio.ByteBuffer buff)
Description copied from interface:DataTypeRead an object.- Specified by:
readin interfaceDataType<java.lang.Integer>- Specified by:
readin classBasicDataType<java.lang.Integer>- Parameters:
buff- the source buffer- Returns:
- the object
-
createStorage
public java.lang.Integer[] createStorage(int size)
Description copied from interface:DataTypeCreate storage object of array type to hold values- Parameters:
size- number of values to hold- Returns:
- storage object
-
compare
public int compare(java.lang.Integer one, java.lang.Integer two)Description copied from interface:DataTypeCompare two keys.- Specified by:
comparein interfacejava.util.Comparator<java.lang.Integer>- Specified by:
comparein interfaceDataType<java.lang.Integer>- Overrides:
comparein classBasicDataType<java.lang.Integer>- Parameters:
one- the first keytwo- the second key- Returns:
- -1 if the first key is smaller, 1 if larger, and 0 if equal
-
binarySearch
public int binarySearch(java.lang.Integer keyObj, java.lang.Object storageObj, int size, int initialGuess)Description copied from interface:DataTypePerform binary search for the key within the storage- Specified by:
binarySearchin interfaceDataType<java.lang.Integer>- Overrides:
binarySearchin classBasicDataType<java.lang.Integer>- Parameters:
keyObj- to search forstorageObj- to search within (an array of type T)size- number of data items in the storageinitialGuess- for key position- Returns:
- index of the key , if found, - index of the insertion point, if not
-
-