K - the key typeV - the value typepublic final class TransactionMap<K,V> extends 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.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
TransactionMap.TMIterator<K,V,X> |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 限定符和类型 | 字段和说明 |
|---|---|
MVMap<K,VersionedValue<V>> |
map
The map used for writing (the latest version).
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
append(K key,
V value)
Appends entry to underlying map.
|
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(Object key)
Whether the map contains the key.
|
TransactionMap.TMIterator<K,V,Map.Entry<K,V>> |
entryIterator(K from,
K to)
Iterate over entries.
|
Set<Map.Entry<K,V>> |
entrySet() |
Map.Entry<K,V> |
firstEntry()
Get the first entry.
|
K |
firstKey()
Get the first key.
|
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(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() |
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.
|
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.
|
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.
|
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(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, valuescompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, remove, replace, replace, replaceAllpublic 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 在接口中 Map<K,V>size 在类中 AbstractMap<K,V>sizeAsLong()public long sizeAsLongMax()
public long sizeAsLong()
public V remove(Object key)
If the row is locked, this method will retry until the row could be updated or until a lock timeout.
remove 在接口中 Map<K,V>remove 在类中 AbstractMap<K,V>key - the keyMVStoreException - if a lock timeout occursClassCastException - 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 在接口中 Map<K,V>put 在类中 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(Object key)
get 在接口中 Map<K,V>get 在类中 AbstractMap<K,V>key - the keyClassCastException - if type of the specified key is not compatible with this mappublic V getFromSnapshot(K key)
key - the keypublic V getImmediate(K key)
key - the keypublic boolean containsKey(Object key)
containsKey 在接口中 Map<K,V>containsKey 在类中 AbstractMap<K,V>key - the keyClassCastException - if type of the specified key is not compatible with this mappublic boolean isDeletedByCurrentTransaction(K key)
key - the keytrue if it waspublic boolean isSameTransaction(K key)
key - the keypublic boolean isClosed()
public Map.Entry<K,V> firstEntry()
public K firstKey()
public Map.Entry<K,V> lastEntry()
public K lastKey()
public 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 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 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 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 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,Map.Entry<K,V>> entryIterator(K from, K to)
from - the first key to returnto - the last key to returnpublic Transaction getTransaction()
Copyright © 2022. All rights reserved.