Interface Access
- All Known Implementing Classes:
AbstractAccess
,Fork
,Prefixed
,RoErasedAccess
,Snapshot
public interface Access
An access can be read-only or read-write. Read-only accesses produce indexes that forbid modifying operations.
The changes made to read-write accesses are not usually applied immediately to the database state, but are performed separately. For example, Exonum will apply the changes made by all transactions when a block is confirmed.
Accesses may perform index address resolution: they may modify the passed index address before fetching it from the database. That implies that addresses passed to index factory methods are relative to an access object. The address resolution rules must be documented in interface implementations.
As each Access object requires some MerkleDB resources to function, they work in a scope that is usually managed by the framework. When an Access is closed, all indexes created with it are destroyed and become inaccessible; and no new indexes can be created.
All method arguments are non-null by default.
This Java interface is similar to a combination of Rust Access
and AccessExt
traits.
-
Method Summary
Modifier and Type Method Description boolean
canModify()
Returns true if this access allows modifications to the database state; false if it is immutable.long
getAccessNativeHandle()
Returns a native handle of this access.<E> EntryIndex<E>
getEntry(IndexAddress address, Serializer<E> serializer)
Creates a new Entry.<E> KeySetIndexProxy<E>
getKeySet(IndexAddress address, Serializer<E> serializer)
Creates a new KeySet.<E> ListIndexProxy<E>
getList(IndexAddress address, Serializer<E> serializer)
Creates a new ListIndex.<K, V> MapIndexProxy<K,V>
getMap(IndexAddress address, Serializer<K> keySerializer, Serializer<V> valueSerializer)
Creates a new MapIndex.<E> ProofEntryIndex<E>
getProofEntry(IndexAddress address, Serializer<E> serializer)
Creates a new ProofEntry.<E> ProofListIndexProxy<E>
getProofList(IndexAddress address, Serializer<E> serializer)
Creates a new ProofListIndex.<K, V> ProofMapIndexProxy<K,V>
getProofMap(IndexAddress address, Serializer<K> keySerializer, Serializer<V> valueSerializer)
Creates a new ProofMapIndex.<K, V> ProofMapIndexProxy<K,V>
getRawProofMap(IndexAddress address, Serializer<K> keySerializer, Serializer<V> valueSerializer)
Creates a new "raw" ProofMapIndex.<E> ValueSetIndexProxy<E>
getValueSet(IndexAddress address, Serializer<E> serializer)
Creates a new ValueSet.
-
Method Details
-
getProofList
Creates a new ProofListIndex.- Type Parameters:
E
- the type of elements in this list- Parameters:
address
- an index address in the MerkleDBserializer
- a serializer of list elements- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
StandardSerializers
-
getList
Creates a new ListIndex.- Type Parameters:
E
- the type of elements in this list- Parameters:
address
- an index address in the MerkleDBserializer
- a serializer of list elements- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
getProofList(IndexAddress, Serializer)
,StandardSerializers
-
getProofMap
<K, V> ProofMapIndexProxy<K,V> getProofMap(IndexAddress address, Serializer<K> keySerializer, Serializer<V> valueSerializer)Creates a new ProofMapIndex.- Type Parameters:
K
- the type of keys in the mapV
- the type of values in the map- Parameters:
address
- an index address in the MerkleDBkeySerializer
- a serializer of keysvalueSerializer
- a serializer of values- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
StandardSerializers
-
getRawProofMap
<K, V> ProofMapIndexProxy<K,V> getRawProofMap(IndexAddress address, Serializer<K> keySerializer, Serializer<V> valueSerializer)Creates a new "raw" ProofMapIndex. A raw ProofMapIndex does not hash keys, hence imposes some requirements on them.- Type Parameters:
K
- the type of keys in the mapV
- the type of values in the map- Parameters:
address
- an index address in the MerkleDBkeySerializer
- a serializer of keys, must always produce 32-byte long values that suit the requirementsvalueSerializer
- a serializer of values- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
getProofMap(IndexAddress, Serializer, Serializer)
,StandardSerializers
-
getMap
<K, V> MapIndexProxy<K,V> getMap(IndexAddress address, Serializer<K> keySerializer, Serializer<V> valueSerializer)Creates a new MapIndex.- Type Parameters:
K
- the type of keys in the mapV
- the type of values in the map- Parameters:
address
- an index address in the MerkleDBkeySerializer
- a serializer of keysvalueSerializer
- a serializer of values- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
getProofMap(IndexAddress, Serializer, Serializer)
,StandardSerializers
-
getKeySet
Creates a new KeySet.- Type Parameters:
E
- the type of keys in this set- Parameters:
address
- an index address in the MerkleDBserializer
- a serializer of set keys- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
getValueSet(IndexAddress, Serializer)
,StandardSerializers
-
getValueSet
Creates a new ValueSet.- Type Parameters:
E
- the type of values in this set- Parameters:
address
- an index address in the MerkleDBserializer
- a serializer of set values- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
getKeySet(IndexAddress, Serializer)
,StandardSerializers
-
getProofEntry
Creates a new ProofEntry.- Type Parameters:
E
- the type of the entry- Parameters:
address
- an index address in the MerkleDBserializer
- an entry serializer- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
StandardSerializers
-
getEntry
Creates a new Entry.- Type Parameters:
E
- the type of the entry- Parameters:
address
- an index address in the MerkleDBserializer
- an entry serializer- Throws:
java.lang.IllegalStateException
- if this access is not valid- See Also:
StandardSerializers
-
canModify
boolean canModify()Returns true if this access allows modifications to the database state; false if it is immutable. -
getAccessNativeHandle
long getAccessNativeHandle()Returns a native handle of this access.- Throws:
java.lang.IllegalStateException
- if the access is invalid (closed or nullptr)
-