K - the type of keys in this map. Must be 32-byte long in the serialized formV - the type of values in this mappublic final class ProofMapIndexProxy<K,V> extends AbstractNativeProxy implements MapIndex<K,V>
This map is implemented as a Merkle-Patricia tree. It does not permit null keys and values, and requires that keys are 32-byte long.
The "destructive" methods of the map, i.e., the one that change the map contents,
are specified to throw UnsupportedOperationException if
the map has been created with a read-only database view.
All method arguments are non-null by default.
This class is not thread-safe and and its instances shall not be shared between threads.
When the view goes out of scope, this map is destroyed. Subsequent use of the closed map
is prohibited and will result in IllegalStateException.
ViewnativeHandle| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all of the key-value pairs from the map.
|
boolean |
containsKey(K key)
Returns true if this map contains a mapping for the specified key.
|
java.util.Iterator<MapEntry<K,V>> |
entries()
Returns an iterator over the map entries.
|
V |
get(K key)
Returns the value associated with the specified key,
or
null if there is no mapping for the key. |
java.lang.String |
getName()
Returns the name of this index.
|
java.lang.String |
getName()
Returns the name of this index.
|
com.exonum.binding.common.proofs.map.UncheckedMapProof |
getProof(java.util.Collection<? extends K> keys)
Returns a proof that there are values mapped to the specified keys or that there are no such
mappings.
|
com.exonum.binding.common.proofs.map.UncheckedMapProof |
getProof(K key,
K... otherKeys)
Returns a proof that there are values mapped to the specified keys or that there are no such
mappings.
|
com.exonum.binding.common.hash.HashCode |
getRootHash()
Returns the root hash of the underlying Merkle-Patricia tree.
|
java.util.Iterator<K> |
keys()
Returns an iterator over the map keys in lexicographical order.
|
static <K,V> ProofMapIndexProxy<K,V> |
newInGroupUnsafe(java.lang.String groupName,
byte[] mapId,
View view,
com.exonum.binding.common.serialization.Serializer<K> keySerializer,
com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
Creates a new proof map in a collection group
with the given name.
|
static <K,V> ProofMapIndexProxy<K,V> |
newInstance(java.lang.String name,
View view,
com.exonum.binding.common.serialization.Serializer<K> keySerializer,
com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
Creates a ProofMapIndexProxy.
|
void |
put(K key,
V value)
Puts a new key-value pair into the map.
|
void |
putAll(java.util.Map<? extends K,? extends V> sourceMap)
Puts all key-value pairs from the given map into this map.
|
void |
remove(K key)
Removes the value mapped to the specified key from the map.
|
java.lang.String |
toString() |
java.util.Iterator<V> |
values()
Returns an iterator over the map values in lexicographical order of keys.
|
getNativeHandle, isValidHandlepublic static <K,V> ProofMapIndexProxy<K,V> newInstance(java.lang.String name, View view, com.exonum.binding.common.serialization.Serializer<K> keySerializer, com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
K - the type of keys in the mapV - the type of values in the mapname - a unique alphanumeric non-empty identifier of this map in the underlying storage:
[a-zA-Z0-9_]view - a database view. Must be valid.
If a view is read-only, "destructive" operations are not permitted.keySerializer - a serializer of keys, must always produce 32-byte long valuesvalueSerializer - a serializer of valuesjava.lang.IllegalStateException - if the view is not validjava.lang.IllegalArgumentException - if the name is emptyStandardSerializerspublic static <K,V> ProofMapIndexProxy<K,V> newInGroupUnsafe(java.lang.String groupName, byte[] mapId, View view, com.exonum.binding.common.serialization.Serializer<K> keySerializer, com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
See a caveat on index identifiers.
K - the type of keys in the mapV - the type of values in the mapgroupName - a name of the collection groupmapId - an identifier of this collection in the group, see the caveatsview - a database viewkeySerializer - a serializer of keys, must always produce 32-byte long valuesvalueSerializer - a serializer of valuesjava.lang.IllegalStateException - if the view is not validjava.lang.IllegalArgumentException - if the name or index id is emptyStandardSerializerspublic boolean containsKey(K key)
MapIndexcontainsKey in interface MapIndex<K,V>public void put(K key, V value)
put in interface MapIndex<K,V>key - a proof map key, must be 32-byte long when serializedvalue - a storage value to associate with the keyjava.lang.IllegalStateException - if this map is not validjava.lang.IllegalArgumentException - if the size of the key is not 32 bytesjava.lang.UnsupportedOperationException - if this map is read-onlypublic void putAll(java.util.Map<? extends K,? extends V> sourceMap)
MapIndexMapIndex.put(K, V) operations.public V get(K key)
MapIndexnull if there is no mapping for the key.public com.exonum.binding.common.proofs.map.UncheckedMapProof getProof(K key, K... otherKeys)
key - a proof map key which might be mapped to some value, must be 32-byte longotherKeys - other proof map keys which might be mapped to some values, each must be
32-byte longjava.lang.IllegalStateException - if this map is not validjava.lang.IllegalArgumentException - if the size of any of the keys is not 32 bytespublic com.exonum.binding.common.proofs.map.UncheckedMapProof getProof(java.util.Collection<? extends K> keys)
keys - proof map keys which might be mapped to some values, each must be 32-byte longjava.lang.IllegalStateException - if this map is not validjava.lang.IllegalArgumentException - if the size of any of the keys is not 32 bytes
or keys collection is emptypublic com.exonum.binding.common.hash.HashCode getRootHash()
java.lang.IllegalStateException - if this map is not validpublic void remove(K key)
MapIndexpublic java.util.Iterator<K> keys()
MapIndexAny destructive operation on the same Fork this map uses
(but not necessarily on this map) will invalidate the iterator.
public java.util.Iterator<V> values()
MapIndexAny destructive operation on the same Fork this map uses
(but not necessarily on this map) will invalidate the iterator.
public java.util.Iterator<MapEntry<K,V>> entries()
MapIndexAny destructive operation on the same Fork this map uses
(but not necessarily on this map) will invalidate the iterator.
public void clear()
MapIndexpublic java.lang.String getName()
public final java.lang.String getName()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2018 Exonum. All rights reserved.