Package org.h2.mvstore.type
Class LongDataType
- java.lang.Object
-
- org.h2.mvstore.type.BasicDataType<java.lang.Long>
-
- org.h2.mvstore.type.LongDataType
-
- All Implemented Interfaces:
java.util.Comparator<java.lang.Long>
,DataType<java.lang.Long>
public class LongDataType extends BasicDataType<java.lang.Long>
Class LongDataType.- 8/21/17 6:52 PM initial creation
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Long[]
EMPTY_LONG_ARR
static LongDataType
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
LongDataType()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
binarySearch(long key, java.lang.Long[] storage, int low, int high, int x)
int
binarySearch(java.lang.Long keyObj, java.lang.Object storageObj, int size, int initialGuess)
Perform binary search for the key within the storageint
compare(java.lang.Long one, java.lang.Long two)
Compare two keys.java.lang.Long[]
createStorage(int size)
Create storage object of array type to hold valuesint
getMemory(java.lang.Long obj)
Calculates the amount of used memory in bytes.java.lang.Long
read(java.nio.ByteBuffer buff)
Read an object.void
write(WriteBuffer buff, java.lang.Long 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 LongDataType INSTANCE
-
EMPTY_LONG_ARR
private static final java.lang.Long[] EMPTY_LONG_ARR
-
-
Method Detail
-
getMemory
public int getMemory(java.lang.Long obj)
Description copied from interface:DataType
Calculates the amount of used memory in bytes.- Specified by:
getMemory
in interfaceDataType<java.lang.Long>
- Specified by:
getMemory
in classBasicDataType<java.lang.Long>
- Parameters:
obj
- the object- Returns:
- the used memory
-
write
public void write(WriteBuffer buff, java.lang.Long data)
Description copied from interface:DataType
Write an object.- Specified by:
write
in interfaceDataType<java.lang.Long>
- Specified by:
write
in classBasicDataType<java.lang.Long>
- Parameters:
buff
- the target bufferdata
- the value
-
read
public java.lang.Long read(java.nio.ByteBuffer buff)
Description copied from interface:DataType
Read an object.- Specified by:
read
in interfaceDataType<java.lang.Long>
- Specified by:
read
in classBasicDataType<java.lang.Long>
- Parameters:
buff
- the source buffer- Returns:
- the object
-
createStorage
public java.lang.Long[] createStorage(int size)
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
public int compare(java.lang.Long one, java.lang.Long two)
Description copied from interface:DataType
Compare two keys.- Specified by:
compare
in interfacejava.util.Comparator<java.lang.Long>
- Specified by:
compare
in interfaceDataType<java.lang.Long>
- Overrides:
compare
in classBasicDataType<java.lang.Long>
- 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.Long keyObj, java.lang.Object storageObj, int size, int initialGuess)
Description copied from interface:DataType
Perform binary search for the key within the storage- Specified by:
binarySearch
in interfaceDataType<java.lang.Long>
- Overrides:
binarySearch
in classBasicDataType<java.lang.Long>
- 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
-
binarySearch
private static int binarySearch(long key, java.lang.Long[] storage, int low, int high, int x)
-
-