Package org.h2.mvstore.tx
Class VersionedValueType<T,D>
- java.lang.Object
-
- org.h2.mvstore.type.BasicDataType<VersionedValue<T>>
-
- org.h2.mvstore.tx.VersionedValueType<T,D>
-
- All Implemented Interfaces:
java.util.Comparator<VersionedValue<T>>
,DataType<VersionedValue<T>>
,StatefulDataType<D>
public class VersionedValueType<T,D> extends BasicDataType<VersionedValue<T>> implements StatefulDataType<D>
The value type for a versioned value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
VersionedValueType.Factory<D>
-
Constructor Summary
Constructors Constructor Description VersionedValueType(DataType<T> valueType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(VersionedValue<T> a, VersionedValue<T> b)
Compare two keys.VersionedValue<T>[]
createStorage(int size)
Create storage object of array type to hold valuesboolean
equals(java.lang.Object obj)
VersionedValueType.Factory<D>
getFactory()
int
getMemory(VersionedValue<T> v)
Calculates the amount of used memory in bytes.private int
getValMemory(T obj)
int
hashCode()
VersionedValue<T>
read(java.nio.ByteBuffer buff)
Read an object.void
read(java.nio.ByteBuffer buff, java.lang.Object storage, int len)
Read a list of objects.void
save(WriteBuffer buff, MetaType<D> metaType)
Save the state.void
write(WriteBuffer buff, java.lang.Object storage, int len)
Write a list of objects.void
write(WriteBuffer buff, VersionedValue<T> v)
Write an object.-
Methods inherited from class org.h2.mvstore.type.BasicDataType
binarySearch, cast, isMemoryEstimationAllowed
-
-
-
-
Field Detail
-
factory
private final VersionedValueType.Factory<D> factory
-
-
Method Detail
-
createStorage
public VersionedValue<T>[] createStorage(int size)
Description copied from interface:DataType
Create storage object of array type to hold values- Specified by:
createStorage
in interfaceDataType<T>
- Parameters:
size
- number of values to hold- Returns:
- storage object
-
getMemory
public int getMemory(VersionedValue<T> v)
Description copied from interface:DataType
Calculates the amount of used memory in bytes.- Specified by:
getMemory
in interfaceDataType<T>
- Specified by:
getMemory
in classBasicDataType<VersionedValue<T>>
- Parameters:
v
- the object- Returns:
- the used memory
-
getValMemory
private int getValMemory(T obj)
-
read
public void read(java.nio.ByteBuffer buff, java.lang.Object storage, int len)
Description copied from interface:DataType
Read a list of objects.- Specified by:
read
in interfaceDataType<T>
- Overrides:
read
in classBasicDataType<VersionedValue<T>>
- Parameters:
buff
- the target bufferstorage
- the objectslen
- the number of objects to read
-
read
public VersionedValue<T> read(java.nio.ByteBuffer buff)
Description copied from interface:DataType
Read an object.- Specified by:
read
in interfaceDataType<T>
- Specified by:
read
in classBasicDataType<VersionedValue<T>>
- Parameters:
buff
- the source buffer- Returns:
- the object
-
write
public void write(WriteBuffer buff, java.lang.Object storage, int len)
Description copied from interface:DataType
Write a list of objects.- Specified by:
write
in interfaceDataType<T>
- Overrides:
write
in classBasicDataType<VersionedValue<T>>
- Parameters:
buff
- the target bufferstorage
- the objectslen
- the number of objects to write
-
write
public void write(WriteBuffer buff, VersionedValue<T> v)
Description copied from interface:DataType
Write an object.- Specified by:
write
in interfaceDataType<T>
- Specified by:
write
in classBasicDataType<VersionedValue<T>>
- Parameters:
buff
- the target bufferv
- the value
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Comparator<T>
- Overrides:
equals
in classBasicDataType<VersionedValue<T>>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBasicDataType<VersionedValue<T>>
-
save
public void save(WriteBuffer buff, MetaType<D> metaType)
Description copied from interface:StatefulDataType
Save the state.- Specified by:
save
in interfaceStatefulDataType<T>
- Parameters:
buff
- the target buffermetaType
- the meta type
-
compare
public int compare(VersionedValue<T> a, VersionedValue<T> b)
Description copied from interface:DataType
Compare two keys.- Specified by:
compare
in interfacejava.util.Comparator<T>
- Specified by:
compare
in interfaceDataType<T>
- Overrides:
compare
in classBasicDataType<VersionedValue<T>>
- Parameters:
a
- the first keyb
- the second key- Returns:
- -1 if the first key is smaller, 1 if larger, and 0 if equal
-
getFactory
public VersionedValueType.Factory<D> getFactory()
- Specified by:
getFactory
in interfaceStatefulDataType<T>
-
-