K - the type of keys in this mapV - 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.
The Merkle-Patricia tree backing the proof map uses internal 32-byte keys. The tree balance relies on the internal keys being uniformly distributed.
By default, when creating the proof map using methods
#newInstance and
#newInGroupUnsafe,
the user keys are converted into internal keys through hashing. This allows to use keys of
an arbitrary size and ensures the balance of the internal tree.
It is also possible to create a proof map that will not hash keys with methods
#newInstanceNoKeyHashing
and #newInGroupUnsafeNoKeyHashing. In this mode the map will use the user keys as internal
tree keys. Such mode of operation is appropriate iff all of the following conditions
hold:
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.
|
Iterator<com.exonum.binding.common.collect.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. |
IndexAddress |
getAddress()
Returns the index address: its unique identifier in the database.
|
com.exonum.binding.common.hash.HashCode |
getIndexHash()
Returns the index hash which represents the complete state of this map.
|
com.exonum.binding.common.proofs.map.UncheckedMapProof |
getProof(Collection<? extends K> keys)
Deprecated.
Proofs are temporarily disabled since 0.9.0-rc1, and will be re-enabled
in a later release
|
com.exonum.binding.common.proofs.map.UncheckedMapProof |
getProof(K key,
K... otherKeys)
Deprecated.
Proofs are temporarily disabled since 0.9.0-rc1, and will be re-enabled
in a later release
|
Iterator<K> |
keys()
Returns an iterator over the map keys.
|
static <K,V> ProofMapIndexProxy<K,V> |
newInGroupUnsafe(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> |
newInGroupUnsafeNoKeyHashing(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 that uses non-hashed keys
in a collection group with the given name.
|
static <K,V> ProofMapIndexProxy<K,V> |
newInstance(String name,
View view,
com.exonum.binding.common.serialization.Serializer<K> keySerializer,
com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
Creates a ProofMapIndexProxy.
|
static <K,V> ProofMapIndexProxy<K,V> |
newInstanceNoKeyHashing(String name,
View view,
com.exonum.binding.common.serialization.Serializer<K> keySerializer,
com.exonum.binding.common.serialization.Serializer<V> valueSerializer)
Creates a ProofMapIndexProxy that uses non-hashed keys.
|
void |
put(K key,
V value)
Puts a new key-value pair into the map.
|
void |
putAll(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.
|
String |
toString() |
Iterator<V> |
values()
Returns an iterator over the map values.
|
getNativeHandle, isValidHandleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAddress, getNamepublic static <K,V> ProofMapIndexProxy<K,V> newInstance(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 keysvalueSerializer - a serializer of valuesIllegalStateException - if the view is not validIllegalArgumentException - if the name is emptyStandardSerializerspublic static <K,V> ProofMapIndexProxy<K,V> newInstanceNoKeyHashing(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 valuesIllegalStateException - if the view is not validIllegalArgumentException - if the name is emptyStandardSerializerspublic static <K,V> ProofMapIndexProxy<K,V> newInGroupUnsafe(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 keysvalueSerializer - a serializer of valuesIllegalStateException - if the view is not validIllegalArgumentException - if the name or index id is emptyStandardSerializerspublic static <K,V> ProofMapIndexProxy<K,V> newInGroupUnsafeNoKeyHashing(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 valuesIllegalStateException - if the view is not validIllegalArgumentException - 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 keyvalue - a storage value to associate with the keyIllegalStateException - if this map is not validIllegalArgumentException - if the size of the key is not 32 bytes (in case of a
proof map that uses non-hashed keys)UnsupportedOperationException - if this map is read-onlypublic void putAll(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.@Deprecated public com.exonum.binding.common.proofs.map.UncheckedMapProof getProof(K key, K... otherKeys)
key - a proof map key which might be mapped to some valueotherKeys - other proof map keys which might be mapped to some valuesIllegalStateException - if this map is not validIllegalArgumentException - if the size of any of the keys is not 32 bytes (in case of a
proof map that uses non-hashed keys)@Deprecated public com.exonum.binding.common.proofs.map.UncheckedMapProof getProof(Collection<? extends K> keys)
keys - proof map keys which might be mapped to some valuesIllegalStateException - if this map is not validIllegalArgumentException - if the size of any of the keys is not 32 bytes (in case of a
proof map that uses non-hashed keys) or
keys collection is emptypublic com.exonum.binding.common.hash.HashCode getIndexHash()
IllegalStateException - if this map is not validpublic void remove(K key)
MapIndexpublic Iterator<K> keys()
MapIndexpublic Iterator<V> values()
MapIndexpublic Iterator<com.exonum.binding.common.collect.MapEntry<K,V>> entries()
MapIndexpublic void clear()
MapIndexpublic IndexAddress getAddress()
StorageIndexgetAddress in interface StorageIndexCopyright © 2019 Exonum. All rights reserved.