## org.h2.mvstore
Class MVMapConcurrent<K,V>

    java.lang.Object
      java.util.AbstractMap<K,V>
          org.h2.mvstore.MVMap<K,V>
              org.h2.mvstore.MVMapConcurrent<K,V>

Type Parameters:
  `K` - the key class
  `V` - the value class

All Implemented Interfaces:
  java.util.concurrent.ConcurrentMap<K,V>, java.util.Map<K,V>

    public class MVMapConcurrent<K,V>

extends MVMap<K,V>

A stored map. Read operations can happen concurrently with all other operations, without risk of corruption.

Write operations first read the relevant area from disk to memory concurrently, and only then modify the data. The in-memory part of write operations is synchronized. For scalable concurrent in-memory write operations, the map should be split into multiple smaller sub-maps that are then synchronized independently.

Nested Class Summary
`static class` `MVMapConcurrent.Builder<K,V>` A builder for this class.

Nested classes/interfaces inherited from class org.h2.mvstore.MVMap
`MVMap.MapBuilder<M extends MVMap<K,V>,K,V>`

Nested classes/interfaces inherited from class java.util.AbstractMap
`java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>`

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary

Fields inherited from class org.h2.mvstore.MVMap
`currentWriteVersion, root, store, writeVersion`

Constructor Summary
`MVMapConcurrent(DataType keyType, DataType valueType)`

Method Summary
`protected void` `checkConcurrentWrite()` Check that no write operation is in progress.
`protected Page` `copyOnWrite(Page p, long writeVersion)` Create a copy of a page, if the write version is higher than the current version.
`V` `put(K key, V value)` Add or replace a key-value pair.
`V` `remove(java.lang.Object key)` Remove a key-value pair, if the key exists.
`protected void` `waitUntilWritten(long version)` If there is a concurrent update to the given version, wait until it is finished.

Methods inherited from class org.h2.mvstore.MVMap

`afterWrite, areValuesEqual, beforeWrite, binarySearch, binarySearchPage, ceilingKey, clear, containsKey, cursor, entrySet, equals, firstKey, floorKey, get, getChildPageCount, getCreateVersion, getFirstLast, getId, getKey, getKeyIndex, getKeyType, getLiveKey, getMinMax, getName, getRoot, getStore, getType, getValueType, getVersion, hashCode, higherKey, init, isClosed, isEmpty, isReadOnly, isVolatile, keyIterator, keyList, keySet, lastKey, lowerKey, newRoot, openVersion, put, putIfAbsent, remove, remove, removePage, replace, replace, rewrite, setVolatile, size, sizeAsLong, splitRootIfNeeded, toString`

Methods inherited from class java.util.AbstractMap
`clone, containsValue, putAll, values`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Map
`containsValue, putAll, values`

Constructor Detail

### MVMapConcurrent

    public MVMapConcurrent(DataType keyType,
                           DataType valueType)

Method Detail

### copyOnWrite

    protected Page copyOnWrite(Page p,
                               long writeVersion)

  Description copied from class: `MVMap`
  Create a copy of a page, if the write version is higher than the current version. If a copy is created, the old page is marked as deleted.

  Overrides:
    `copyOnWrite` in class `MVMap<K,V>`
  Parameters:
    `p` - the page
    `writeVersion` - the write version
  Returns:
    a page with the given write version

### checkConcurrentWrite

    protected void checkConcurrentWrite()

  Description copied from class: `MVMap`
  Check that no write operation is in progress.

  Overrides:
    `checkConcurrentWrite` in class `MVMap<K,V>`

### put

    public V put(K key,
                 V value)

  Description copied from class: `MVMap`
  Add or replace a key-value pair.

  Specified by:
    `put` in interface `java.util.Map<K,V>`
  Overrides:
    `put` in class `MVMap<K,V>`
  Parameters:
    `key` - the key (may not be null)
    `value` - the value (may not be null)
  Returns:
    the old value if the key existed, or null otherwise

### waitUntilWritten

    protected void waitUntilWritten(long version)

  Description copied from class: `MVMap`
  If there is a concurrent update to the given version, wait until it is finished.

  Overrides:
    `waitUntilWritten` in class `MVMap<K,V>`
  Parameters:
    `version` - the read version

### remove

    public V remove(java.lang.Object key)

  Description copied from class: `MVMap`
  Remove a key-value pair, if the key exists.

  Specified by:
    `remove` in interface `java.util.Map<K,V>`
  Overrides:
    `remove` in class `MVMap<K,V>`
  Parameters:
    `key` - the key (may not be null)
  Returns:
    the old value if the key existed, or null otherwise