#include <map_handle.h>
Inherited by ccf::kv::MapHandle< K, V, KSerialiser, VSerialiser >.
template<typename K, typename V, typename KSerialiser, typename VSerialiser>
class ccf::kv::ReadableMapHandle< K, V, KSerialiser, VSerialiser >
Grants read access to a ccf::kv::Map
, as part of a ccf::kv::Tx
.
◆ KeyType
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
◆ ValueType
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
◆ ReadableMapHandle()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
◆ foreach()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
template<class F >
Iterate over all entries in the map.
The passed functor should have the signature bool(const K& k, const V& v)
. The iteration order is undefined. Return true to continue iteration, or return false from any invocation to terminate the iteration at that point - the functor will not be invoked again after it returns false.
The set of key-value entries which will be iterated over is determined at the point foreach is called, and does not include any modifications made by the functor. This means:
- If the functor sets a value V at a new key K', the functor will not be called for (K', V)
- If the functor changes the value at key K from V to V', the functor will be called with the old value (K, V), not the new value (K, V')
- If the functor removes K, the functor will still be called for (K, V)
Calling get
will always return the true latest state; the iterator visibility described above only applies to the keys and values passed to this functor.
- Template Parameters
-
F | Functor type. Should usually be derived implicitly from f |
- Parameters
-
f | Functor instance, taking (const K& k, const V& v) and returning a bool. Return value determines whether the iteration should continue (true) or stop (false) |
◆ foreach_key()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
template<class F >
Iterate over all keys in the map.
Similar to foreach
but the functor takes a single key argument rather than a key and value. Avoids deserialisation of values.
- Template Parameters
-
F | Functor type. Should usually be derived implicitly from f |
- Parameters
-
f | Functor instance, taking (const K& k) and returning a bool. Return value determines whether the iteration should continue (true) or stop (false) |
◆ foreach_value()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
template<class F >
Iterate over all values in the map.
Similar to foreach
but the functor takes a single value argument rather than a key and value. Avoids deserialisation of keys.
- Template Parameters
-
F | Functor type. Should usually be derived implicitly from f |
- Parameters
-
f | Functor instance, taking (const V& v) and returning a bool. Return value determines whether the iteration should continue (true) or stop (false) |
◆ get()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
Get value for key.
This returns the value for the key as seen by this transaction. If the key has been updated in the current transaction, that update will be reflected in the return of this call. Where the key has not been modified, this returns the state of a snapshot version from the start of the transaction's execution.
- Parameters
-
- Returns
- Optional containing associated value, or empty if the key doesn't exist
◆ get_globally_committed()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
Get globally committed value for key, which has been replicated and acknowledged by consensus protocol.
This reads a globally replicated value for the specified key. The value will have been the most recent replicated value when the transaction began. Consensus may have advanced and committed a more recent version while this transaction executes. This is undetectable to the transaction.
- Parameters
-
- Returns
- Optional containing associated value, or empty if the key doesn't exist in globally committed state
◆ get_name_of_map()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
Get name of this map.
- Returns
- String containing name used to construct this map handle
◆ get_version_of_previous_write()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
Get version when this key was last written to, by a previous transaction.
Returns nullopt when there is no value, because the key has no value (never existed or has been removed). Note that this is always talking about the version of previously applied state and not the same values as get
or has
. This current transaction's pending writes have no version yet, and this method does not talk about them.
- Parameters
-
- Returns
- Optional containing version of applied transaction which last wrote at this key, or nullopt if such a version does not exist
◆ has()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
Test if key is present.
This obeys the same rules as get
regarding key visibility, but is more efficient if you do not need the associated value.
- Parameters
-
- Returns
- Boolean true iff key exists
◆ size()
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
Returns number of entries in this map.
This is the count of all currently present keys, including both those which were already committed and any modifications (taking into account new additions or removals) that have been made during this transaction.
- Returns
- Count of entries
◆ read_handle
template<typename K , typename V , typename KSerialiser , typename VSerialiser >
The documentation for this class was generated from the following file: