K - the key typeV - the value typepublic final class TransactionMap<K,V>
extends java.util.AbstractMap<K,V>
Methods of this class may be changed at any time without notice. If you use this class directly make sure that your application or library requires exactly the same version of MVStore or H2 jar as the version that you use during its development and build.
| Modifier and Type | Class and Description |
|---|---|
static class |
TransactionMap.TMIterator<K,V,X> |
| Modifier and Type | Field and Description |
|---|---|
MVMap<K,VersionedValue<V>> |
map
The map used for writing (the latest version).
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(K key,
V value)
Appends entry to underlying map.
|
java.util.Map.Entry<K,V> |
ceilingEntry(K key)
Get the entry with smallest key that is larger than or equal to this key,
or null if no such key exists.
|
K |
ceilingKey(K key)
Get the smallest key that is larger than or equal to this key,
or null if no such key exists.
|
void |
clear()
Clear the map.
|
boolean |
containsKey(java.lang.Object key)
Whether the map contains the key.
|
TransactionMap.TMIterator<K,V,java.util.Map.Entry<K,V>> |
entryIterator(K from,
K to)
Iterate over entries.
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
java.util.Map.Entry<K,V> |
firstEntry()
Get the first entry.
|
K |
firstKey()
Get the first key.
|
java.util.Map.Entry<K,V> |
floorEntry(K key)
Get the entry with largest key that is smaller than or equal to this key,
or null if no such key exists.
|
K |
floorKey(K key)
Get the largest key that is smaller than or equal to this key,
or null if no such key exists.
|
V |
get(java.lang.Object key)
Get the effective value for the given key.
|
V |
getFromSnapshot(K key)
Get the value for the given key, or null if value does not exist in accordance with transactional rules.
|
V |
getImmediate(K key)
Get the value for the given key, or null if not found.
|
TransactionMap<K,V> |
getInstance(Transaction transaction)
Get a clone of this map for the given transaction.
|
DataType<K> |
getKeyType() |
Transaction |
getTransaction() |
java.util.Map.Entry<K,V> |
higherEntry(K key)
Get the entry with smallest key that is larger than the given key, or null if no
such key exists.
|
K |
higherKey(K key)
Get the smallest key that is larger than the given key, or null if no
such key exists.
|
boolean |
isClosed()
Check whether this map is closed.
|
boolean |
isDeletedByCurrentTransaction(K key)
Check if the row was deleted by this transaction.
|
boolean |
isSameTransaction(K key)
Whether the entry for this key was added or removed from this
session.
|
java.util.Iterator<K> |
keyIterator(K from)
Iterate over keys.
|
TransactionMap.TMIterator<K,V,K> |
keyIterator(K from,
boolean reverse)
Iterate over keys in the specified order.
|
TransactionMap.TMIterator<K,V,K> |
keyIterator(K from,
K to)
Iterate over keys.
|
TransactionMap.TMIterator<K,V,K> |
keyIteratorUncommitted(K from,
K to)
Iterate over keys, including keys from uncommitted entries.
|
java.util.Map.Entry<K,V> |
lastEntry()
Get the last entry.
|
K |
lastKey()
Get the last key.
|
V |
lock(K key)
Lock row for the given key.
|
java.util.Map.Entry<K,V> |
lowerEntry(K key)
Get the entry with largest key that is smaller than the given key, or null if no
such key exists.
|
K |
lowerKey(K key)
Get the largest key that is smaller than the given key, or null if no
such key exists.
|
V |
put(K key,
V value)
Update the value for the given key.
|
V |
putCommitted(K key,
V value)
Update the value for the given key, without adding an undo log entry.
|
V |
putIfAbsent(K key,
V value)
Put the value for the given key if entry for this key does not exist.
|
V |
remove(java.lang.Object key)
Remove an entry.
|
int |
size()
Get the number of entries, as a integer.
|
long |
sizeAsLong()
Get the size of the map as seen by this transaction.
|
long |
sizeAsLongMax()
Get the size of the raw map.
|
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)
Try to set or remove the value.
|
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuespublic final MVMap<K,VersionedValue<V>> map
Key: key the key of the data. Value: { transactionId, oldVersion, value }
public TransactionMap<K,V> getInstance(Transaction transaction)
transaction - the transactionpublic int size()
Integer.MAX_VALUE is
returned if there are more than this entries.size in interface java.util.Map<K,V>size in class java.util.AbstractMap<K,V>sizeAsLong()public long sizeAsLongMax()
public long sizeAsLong()
public V remove(java.lang.Object key)
If the row is locked, this method will retry until the row could be updated or until a lock timeout.
remove in interface java.util.Map<K,V>remove in class java.util.AbstractMap<K,V>key - the keyMVStoreException - if a lock timeout occursjava.lang.ClassCastException - if type of the specified key is not compatible with this mappublic V put(K key, V value)
If the row is locked, this method will retry until the row could be updated or until a lock timeout.
put in interface java.util.Map<K,V>put in class java.util.AbstractMap<K,V>key - the keyvalue - the new value (not null)MVStoreException - if a lock timeout occurspublic V putIfAbsent(K key, V value)
key - the keyvalue - the new value (not null)public void append(K key, V value)
key - should be higher in map's order than any existing keyvalue - to be appendedpublic V lock(K key)
If the row is locked, this method will retry until the row could be updated or until a lock timeout.
key - the keyMVStoreException - if a lock timeout occurspublic V putCommitted(K key, V value)
key - the keyvalue - the valuepublic boolean tryRemove(K key)
This will fail if the row is locked by another transaction (that means, if another open transaction changed the row).
key - the keypublic boolean tryPut(K key, V value)
This will fail if the row is locked by another transaction (that means, if another open transaction changed the row).
key - the keyvalue - the new valuepublic boolean trySet(K key, V value)
key - the keyvalue - the new value (null to remove the value)public V get(java.lang.Object key)
public V getFromSnapshot(K key)
key - the keypublic V getImmediate(K key)
key - the keypublic boolean containsKey(java.lang.Object key)
public boolean isDeletedByCurrentTransaction(K key)
key - the keytrue if it waspublic boolean isSameTransaction(K key)
key - the keypublic boolean isClosed()
public void clear()
public java.util.Map.Entry<K,V> firstEntry()
public K firstKey()
public java.util.Map.Entry<K,V> lastEntry()
public K lastKey()
public java.util.Map.Entry<K,V> higherEntry(K key)
key - the key (may not be null)public K higherKey(K key)
key - the key (may not be null)public java.util.Map.Entry<K,V> ceilingEntry(K key)
key - the key (may not be null)public K ceilingKey(K key)
key - the key (may not be null)public java.util.Map.Entry<K,V> floorEntry(K key)
key - the key (may not be null)public K floorKey(K key)
key - the key (may not be null)public java.util.Map.Entry<K,V> lowerEntry(K key)
key - the key (may not be null)public K lowerKey(K key)
key - the key (may not be null)public java.util.Iterator<K> keyIterator(K from)
from - the first key to returnpublic TransactionMap.TMIterator<K,V,K> keyIterator(K from, boolean reverse)
from - the first key to returnreverse - if true, iterate in reverse (descending) orderpublic TransactionMap.TMIterator<K,V,K> keyIterator(K from, K to)
from - the first key to returnto - the last key to return or null if there is no limitpublic TransactionMap.TMIterator<K,V,K> keyIteratorUncommitted(K from, K to)
from - the first key to returnto - the last key to return or null if there is no limitpublic TransactionMap.TMIterator<K,V,java.util.Map.Entry<K,V>> entryIterator(K from, K to)
from - the first key to returnto - the last key to returnpublic Transaction getTransaction()