org.h2.mvstore.db

## Class ValueDataType

- java.lang.Object
- - org.h2.mvstore.type.BasicDataType<Value>
  - - org.h2.mvstore.db.ValueDataType

All Implemented Interfaces:
  java.util.Comparator<Value>, DataType<Value>, StatefulDataType<Database>

    public final class ValueDataType
    extends BasicDataType<Value>
    implements StatefulDataType<Database>

A row type.

### Nested Class Summary

Nested Classes
`static class` `ValueDataType.Factory`

### Constructor Summary

Constructors
Constructor and Description
`ValueDataType()`
`ValueDataType(CastDataProvider provider, CompareMode compareMode, DataHandler handler, int[] sortTypes)`
`ValueDataType(Database database, int[] sortTypes)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`int` `compare(Value a, Value b)` Compare two keys.
`int` `compareValues(Value a, Value b, int sortType)` Compares the specified values.
`Value[]` `createStorage(int size)` Create storage object of array type to hold values
`boolean` `equals(java.lang.Object obj)`
`ValueDataType.Factory` `getFactory()`
`int` `getMemory(Value v)` Calculates the amount of used memory in bytes.
`RowFactory` `getRowFactory()`
`int` `hashCode()`
`Value` `read(java.nio.ByteBuffer buff)` Read an object.
`void` `save(WriteBuffer buff, MetaType<Database> metaType)` Save the state.
`void` `setRowFactory(RowFactory rowFactory)`
`void` `write(WriteBuffer buff, Value v)` Write an object.
`static void` `writeLong(WriteBuffer buff, long x)` Writes a long.

### Methods inherited from class org.h2.mvstore.type.BasicDataType

`binarySearch, cast, isMemoryEstimationAllowed, read, write`

### 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

#### ValueDataType

    public ValueDataType()

#### ValueDataType

    public ValueDataType(Database database,
                         int[] sortTypes)

#### ValueDataType

    public ValueDataType(CastDataProvider provider,
                         CompareMode compareMode,
                         DataHandler handler,
                         int[] sortTypes)

### Method Detail

#### getRowFactory

    public RowFactory getRowFactory()

#### setRowFactory

    public void setRowFactory(RowFactory rowFactory)

#### createStorage

    public Value[] createStorage(int size)

Description copied from interface: `DataType`
Create storage object of array type to hold values

Specified by:
  `createStorage` in interface `DataType<Value>`
Parameters:
  `size` - number of values to hold
Returns:
  storage object

#### compare

    public int compare(Value a,
                       Value b)

Description copied from interface: `DataType`
Compare two keys.

Specified by:
  `compare` in interface `java.util.Comparator<Value>`
Specified by:
  `compare` in interface `DataType<Value>`
Overrides:
  `compare` in class `BasicDataType<Value>`
Parameters:
  `a` - the first key
  `b` - the second key
Returns:
  -1 if the first key is smaller, 1 if larger, and 0 if equal

#### compareValues

    public int compareValues(Value a,
                             Value b,
                             int sortType)

Compares the specified values.

Parameters:
  `a` - the first value
  `b` - the second value
  `sortType` - the sorting type
Returns:
  0 if equal, -1 if first value is smaller for ascending or larger for descending sort type, 1 otherwise

#### getMemory

    public int getMemory(Value v)

Description copied from interface: `DataType`
Calculates the amount of used memory in bytes.

Specified by:
  `getMemory` in interface `DataType<Value>`
Specified by:
  `getMemory` in class `BasicDataType<Value>`
Parameters:
  `v` - the object
Returns:
  the used memory

#### read

    public Value read(java.nio.ByteBuffer buff)

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

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

#### write

    public void write(WriteBuffer buff,
                      Value v)

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

Specified by:
  `write` in interface `DataType<Value>`
Specified by:
  `write` in class `BasicDataType<Value>`
Parameters:
  `buff` - the target buffer
  `v` - the value

#### writeLong

    public static void writeLong(WriteBuffer buff,
                                 long x)

Writes a long.

Parameters:
  `buff` - the target buffer
  `x` - the long value

#### equals

    public boolean equals(java.lang.Object obj)

Specified by:
  `equals` in interface `java.util.Comparator<Value>`
Overrides:
  `equals` in class `BasicDataType<Value>`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `BasicDataType<Value>`

#### save

    public void save(WriteBuffer buff,
                     MetaType<Database> metaType)

Description copied from interface: `StatefulDataType`
Save the state.

Specified by:
  `save` in interface `StatefulDataType<Database>`
Parameters:
  `buff` - the target buffer
  `metaType` - the meta type

#### getFactory

    public ValueDataType.Factory getFactory()

Specified by:
  `getFactory` in interface `StatefulDataType<Database>`