## org.h2.dev.store.btree
Class MVStore

    java.lang.Object
      org.h2.dev.store.btree.MVStore

    public class MVStore

extends java.lang.Object

A persistent storage for maps.

Field Summary
`static boolean` `ASSERT` Whether assertions are enabled.

Method Summary
`void` `close()` Close the file.
`boolean` `compact(int fillRate)` Try to reduce the file size.
`Compressor` `getCompressor()`
`long` `getCurrentVersion()` Get the current version of the store.
`int` `getMaxPageSize()` The maximum number of key-value pairs in a page.
`MVMap<java.lang.String,java.lang.String>` `getMetaMap()` Get the metadata map.
`int` `getReadCount()` Get the number of read operations since this store was opened.
`int` `getRetainChunk()`
`boolean` `getReuseSpace()`
`int` `getWriteCount()` Get the number of write operations since this store was opened.
`boolean` `hasUnsavedChanges()` Check whether there are any unsaved changes.
`long` `incrementVersion()` Increment the current version.
`static MVStore` `open(java.lang.String fileName)` Open a tree store.
`static MVStore` `open(java.lang.String fileName, MapFactory mapFactory)` Open a tree store.

`

`<K,V> MVMap<K,V>`

`

`openMap(java.lang.String name, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass)`
Open a map.

`

`<T extends MVMap<?,?>> T`

`

`openMap(java.lang.String name, java.lang.String mapType, java.lang.String keyType, java.lang.String valueType)`
Open a map.

`void` `rollbackTo(long version)` Revert to the given version.
`void` `setCompressor(Compressor compressor)`
`void` `setMaxPageSize(int maxPageSize)`
`void` `setRetainChunk(int retainChunk)` Which chunk to retain.
`void` `setReuseSpace(boolean reuseSpace)`
`long` `store()` Commit all changes and persist them to disk.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ASSERT

    public static final boolean ASSERT

  Whether assertions are enabled.

  See Also:
    Constant Field Values

Method Detail

### open

    public static MVStore open(java.lang.String fileName)

  Open a tree store.

  Parameters:
    `fileName` - the file name
  Returns:
    the store

### open

    public static MVStore open(java.lang.String fileName,
                               MapFactory mapFactory)

  Open a tree store.

  Parameters:
    `fileName` - the file name (null for in-memory)
    `mapFactory` - the map factory
  Returns:
    the store

### openMap

    public <T extends MVMap<?,?>> T openMap(java.lang.String name,
                                            java.lang.String mapType,
                                            java.lang.String keyType,
                                            java.lang.String valueType)

  Open a map.

  Type Parameters:
    `T` - the map type
  Parameters:
    `name` - the name of the map
    `mapType` - the map type
    `keyType` - the key type
    `valueType` - the value type
  Returns:
    the map

### getMetaMap

    public MVMap<java.lang.String,java.lang.String> getMetaMap()

  Get the metadata map. It contains the following entries:

       map.{name} = {mapId}/{keyType}/{valueType}
       root.{mapId} = {rootPos}
       chunk.{chunkId} = {chunkData}

  Returns:
    the metadata map

### openMap

    public <K,V> MVMap<K,V> openMap(java.lang.String name,
                                    java.lang.Class<K> keyClass,
                                    java.lang.Class<V> valueClass)

  Open a map.

  Type Parameters:
    `K` - the key type
    `V` - the value type
  Parameters:
    `name` - the name of the map
    `keyClass` - the key class
    `valueClass` - the value class
  Returns:
    the map

### close

    public void close()

  Close the file. Uncommitted changes are ignored, and all open maps are closed.

### incrementVersion

    public long incrementVersion()

  Increment the current version.

  Returns:
    the old version

### store

    public long store()

  Commit all changes and persist them to disk. This method does nothing if there are no unsaved changes, otherwise it stores the data and increments the current version.

  Returns:
    the version before the commit

### hasUnsavedChanges

    public boolean hasUnsavedChanges()

  Check whether there are any unsaved changes.

  Returns:
    if there are any changes

### compact

    public boolean compact(int fillRate)

  Try to reduce the file size. Chunks with a low number of live items will be re-written. If the current fill rate is higher than the target fill rate, no optimization is done.

  Parameters:
    `fillRate` - the minimum percentage of live entries
  Returns:
    if anything was written

### setMaxPageSize

    public void setMaxPageSize(int maxPageSize)

### getMaxPageSize

    public int getMaxPageSize()

  The maximum number of key-value pairs in a page.

  Returns:
    the maximum number of entries

### getCompressor

    public Compressor getCompressor()

### setCompressor

    public void setCompressor(Compressor compressor)

### getReuseSpace

    public boolean getReuseSpace()

### setReuseSpace

    public void setReuseSpace(boolean reuseSpace)

### getRetainChunk

    public int getRetainChunk()

### setRetainChunk

    public void setRetainChunk(int retainChunk)

  Which chunk to retain. If not set, old chunks are re-used as soon as possible, which may make it impossible to roll back beyond a save operation, or read a older version before.

  This setting is not persisted.

  Parameters:
    `retainChunk` - the earliest chunk to retain (0 to retain all chunks, -1 to re-use space as early as possible)

### rollbackTo

    public void rollbackTo(long version)

  Revert to the given version. All later changes (stored or not) are forgotten. All maps that were created later are closed. A rollback to a version before the last stored version is immediately persisted. Before this method returns, the current version is incremented.

  Parameters:
    `version` - the version to revert to

### getCurrentVersion

    public long getCurrentVersion()

  Get the current version of the store. When a new store is created, the version is 1. For each commit, it is incremented by one.

  Returns:
    the version

### getWriteCount

    public int getWriteCount()

  Get the number of write operations since this store was opened.

  Returns:
    the number of write operations

### getReadCount

    public int getReadCount()

  Get the number of read operations since this store was opened.

  Returns:
    the number of read operations