package octez-l2-libs
Make_nested_map(S)(K1)(K2)(V) constructs a Nested_map
module using module parameter S
to define where the map is going to be persisted on store, K1
and K2
to define the primary and secondary key, respectively, and V
to define the values of the resulting Nested_map
.
Parameters
module S : Store_sigs.STORAGE_INFO
module K1 : Store_sigs.KEY
module K2 : Store_sigs.COMPARABLE_KEY
module V : Store_sigs.VALUE
Signature
type 'a store = 'a t
The type of the store
that is used for persisting data on disk.
type primary_key = K1.key
primary_key
is the type of primary keys for the Nested_map
.
type secondary_key = K2.key
secondary_key
is the type of secondary keys for the Nested_map
.
type value = V.value
value
is the type of values that are going to be persisted on disk, indexed by primary and secondary key.
val path : Store_sigs.path
Path in the irmin tree.
val mem :
[> `Read ] store ->
primary_key:primary_key ->
secondary_key:secondary_key ->
bool Tezos_base.TzPervasives.tzresult Lwt.t
mem store ~primary_key ~secondary_key
returns whether there is a value for the nested map persisted on store
for the nested map, indexed by primary_key
and then by secondary_key
.
val get :
[> `Read ] store ->
primary_key:primary_key ->
secondary_key:secondary_key ->
value Tezos_base.TzPervasives.tzresult Lwt.t
get store ~primary_key ~secondary_key
retrieves from store
the value of the nested map associated with primary_key
and secondary_key
, if any. If such a value does not exist, it fails with error Store_errors.Cannot_read_key_from_store k
, where k
is the string representation of the primary key.
val find :
[> `Read ] store ->
primary_key:primary_key ->
secondary_key:secondary_key ->
value option Tezos_base.TzPervasives.tzresult Lwt.t
find store ~primary_key ~secondary_key
is the same as get store ~primary_key ~secondary_key
, except that no error is thrown and an optional value is returned instead. The returned value is None
if there is not a value bound to primary_key
and seconary_key
in the store
for the Nested_map
.
val list_secondary_keys_with_values :
[> `Read ] store ->
primary_key:primary_key ->
(secondary_key * value) list Tezos_base.TzPervasives.tzresult Lwt.t
list secondary_keys store ~primary_key
retrieves from store
the list of bindings of the nested map that share the same ~primary_key
. For each of these bindings, both the secondary_key and value are returned.
val list_secondary_keys :
[> `Read ] store ->
primary_key:primary_key ->
secondary_key list Tezos_base.TzPervasives.tzresult Lwt.t
list_secondary_keys store ~primary_key
retrieves from store
the list of secondary_keys for which a value indexed by both primary_key
and secondary key is persisted on disk.
val list_values :
[> `Read ] store ->
primary_key:primary_key ->
value list Tezos_base.TzPervasives.tzresult Lwt.t
list_values store ~primary_key
retrieves from store
the list of values for which a binding with primary key primary_key
and arbitrary secondary key exists.
val add :
Store_sigs.rw store ->
primary_key:primary_key ->
secondary_key:secondary_key ->
value ->
unit Tezos_base.TzPervasives.tzresult Lwt.t
add store ~primary_key ~secondary_key value
persists value
to disk. The value is bound to the primary_key
and secondary_key
.