Module Disk_persistence.Make_table

Create an on-disk persistent version of Hashtbl.

Parameters

module H : H

Signature

type key = H.key
type value = H.value
type t

Type of persistent hash tables

val replace : t -> key -> value -> unit Mavryk_base.TzPervasives.tzresult Lwt.t

Persistent version of H.replace

val remove : t -> key -> unit Mavryk_base.TzPervasives.tzresult Lwt.t

Persistent version of H.remove

val find : t -> key -> value option

Same as H.find

val mem : t -> key -> bool

Same as H.mem

val iter_s : (key -> value -> unit Lwt.t) -> t -> unit Lwt.t

Same as H.iter_s

val iter_es : (key -> value -> unit Mavryk_base.TzPervasives.tzresult Lwt.t) -> t -> unit Mavryk_base.TzPervasives.tzresult Lwt.t

Same as H.iter_es

val fold : (key -> value -> 'a -> 'a) -> t -> 'a -> 'a

Same as H.fold

val length : t -> int

Same as H.length

Persistent version of H.replace_seq

val load_from_disk : warn_unreadable: (string -> Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace -> unit Lwt.t) option -> initial_size:int -> data_dir:string -> filter:(value -> bool) -> t Mavryk_base.TzPervasives.tzresult Lwt.t

load_from_disk ~warn_unreadable ~initial_size ~data_dir creates a hash table of size initial_size. The hash table is populated by persistent elements present in data_dir/H.name which pass the filter (the directory is created if it does not exist). If warn_unreadable is Some warn, unreadable files are ignored but a warning is printed with warn, otherwise the loading fails on the first unreadable file.