org.h2.mvstore
Class TransactionStore.TransactionMap<K,V>

java.lang.Object
  extended by org.h2.mvstore.TransactionStore.TransactionMap<K,V>
Type Parameters:
K - the key type
V - the value type
Enclosing class:
TransactionStore

public static class TransactionStore.TransactionMap<K,V>
extends java.lang.Object

A map that supports transactions.


Method Summary
 V get(K key)
          Get the value for the given key at the time when this map was opened.
 V get(K key, MVMap<K,java.lang.Object[]> m)
          Get the value for the given key.
 V getLatest(K key)
          Get the most recent value for the given key.
 long getSize()
          Get the size of the map as seen by this transaction.
 V put(K key, V value)
          Update the value for the given key.
 V remove(K key)
          Remove an entry.
 boolean tryPut(K key, V value)
          Try to update the value for the given key.
 boolean tryRemove(K key)
          Try to remove the value for the given key.
 boolean trySet(K key, V value, boolean onlyIfUnchanged)
          Try to set or remove the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSize

public long getSize()
Get the size of the map as seen by this transaction.

Returns:
the size

remove

public V remove(K key)
Remove an entry.

If the row is locked, this method will retry until the row could be updated or until a lock timeout.

Parameters:
key - the key
Throws:
java.lang.IllegalStateException - if a lock timeout occurs

put

public V put(K key,
             V value)
Update the value for the given key.

If the row is locked, this method will retry until the row could be updated or until a lock timeout.

Parameters:
key - the key
value - the new value (not null)
Throws:
java.lang.IllegalStateException - if a lock timeout occurs

tryRemove

public boolean tryRemove(K key)
Try to remove the value for the given key.

This will fail if the row is locked by another transaction (that means, if another open transaction changed the row).

Parameters:
key - the key
Returns:
whether the entry could be removed

tryPut

public boolean tryPut(K key,
                      V value)
Try to update the value for the given key.

This will fail if the row is locked by another transaction (that means, if another open transaction changed the row).

Parameters:
key - the key
value - the new value
Returns:
whether the entry could be updated

trySet

public boolean trySet(K key,
                      V value,
                      boolean onlyIfUnchanged)
Try to set or remove the value. When updating only unchanged entries, then the value is only changed if it was not changed after opening the map.

Parameters:
key - the key
value - the new value (null to remove the value)
onlyIfUnchanged - only set the value if it was not changed (by this or another transaction) since the map was opened
Returns:
true if the value was set

get

public V get(K key)
Get the value for the given key at the time when this map was opened.

Parameters:
key - the key
Returns:
the value or null

getLatest

public V getLatest(K key)
Get the most recent value for the given key.

Parameters:
key - the key
Returns:
the value or null

get

public V get(K key,
             MVMap<K,java.lang.Object[]> m)
Get the value for the given key.

Parameters:
key - the key
m - the map
Returns:
the value or null