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

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`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(java.lang.Object obj)`
`VersionedValueType.Factory<D>` `getFactory()`
`int` `getMemory(VersionedValue<T> v)` Calculates the amount of used memory in bytes.
`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`

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

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

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

`comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

### Constructor Detail

#### VersionedValueType

    public VersionedValueType(DataType<T> valueType)

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

#### 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 interface `DataType<VersionedValue<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(java.nio.ByteBuffer buff)

Description copied from interface: `DataType`
Read an object.

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

#### equals

    public boolean equals(java.lang.Object obj)

Specified by:
  `equals` in interface `java.util.Comparator<VersionedValue<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<D>`
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 `java.util.Comparator<VersionedValue<T>>`
Specified by:
  `compare` in interface `DataType<VersionedValue<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<D>`