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:
  `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 final class`
`VersionedValueType.Factory<D>`

## Constructor Summary

Constructors
Constructor
Description
`VersionedValueType(DataType<T> valueType)`

## Method Summary

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 values
`boolean`
`equals(Object obj)`
`VersionedValueType.Factory<D>`
`getFactory()`
`int`
`getMemory(VersionedValue<T> v)`
Calculates the amount of used memory in bytes.
`int`
`hashCode()`
`VersionedValue<T>`
`read(ByteBuffer buff)`
Read an object.
`void`
`read(ByteBuffer buff, Object storage, int len)`
Read a list of objects.
`void`
`save(WriteBuffer buff, MetaType<D> metaType)`
Save the state.
`void`
`write(WriteBuffer buff, 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`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### VersionedValueType

public VersionedValueType(DataType<T> valueType)

## Method Details

### 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 interface `DataType<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 interface `DataType<T>`
Specified by:
  `getMemory` in class `BasicDataType<VersionedValue<T>>`
Parameters:
  `v` - the object
Returns:
  the used memory

### read

public void read(ByteBuffer buff, Object storage, int len)
Description copied from interface: `DataType`
Read a list of objects.

Specified by:
  `read` in interface `DataType<T>`
Overrides:
  `read` in class `BasicDataType<VersionedValue<T>>`
Parameters:
  `buff` - the target buffer
  `storage` - the objects
  `len` - the number of objects to read

### read

public VersionedValue<T> read(ByteBuffer buff)
Description copied from interface: `DataType`
Read an object.

Specified by:
  `read` in interface `DataType<T>`
Specified by:
  `read` in class `BasicDataType<VersionedValue<T>>`
Parameters:
  `buff` - the source buffer
Returns:
  the object

### write

public void write(WriteBuffer buff, Object storage, int len)
Description copied from interface: `DataType`
Write a list of objects.

Specified by:
  `write` in interface `DataType<T>`
Overrides:
  `write` in class `BasicDataType<VersionedValue<T>>`
Parameters:
  `buff` - the target buffer
  `storage` - the objects
  `len` - 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 interface `DataType<T>`
Specified by:
  `write` in class `BasicDataType<VersionedValue<T>>`
Parameters:
  `buff` - the target buffer
  `v` - the value

### equals

public boolean equals(Object obj)

Specified by:
  `equals` in interface `Comparator<T>`
Overrides:
  `equals` in class `BasicDataType<VersionedValue<T>>`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `BasicDataType<VersionedValue<T>>`

### save

public void save(WriteBuffer buff, MetaType<D> metaType)
Description copied from interface: `StatefulDataType`
Save the state.

Specified by:
  `save` in interface `StatefulDataType<T>`
Parameters:
  `buff` - the target buffer
  `metaType` - 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 interface `Comparator<T>`
Specified by:
  `compare` in interface `DataType<T>`
Overrides:
  `compare` in class `BasicDataType<VersionedValue<T>>`
Parameters:
  `a` - the first key
  `b` - 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 interface `StatefulDataType<T>`