package index

  1. Overview
  2. Docs

Parameters

module K : Key
module V : Value
module IO : IO
module M : MUTEX
module T : THREAD

Signature

include S with type key = K.t with type value = V.t
type t

The type for indexes.

type key = K.t

The type for keys.

type value = V.t

The type for values.

val v : ?fresh:bool -> ?readonly:bool -> log_size:int -> string -> t

The constructor for indexes.

  • parameter fresh

    whether an existing index should be overwritten.

  • parameter read_only

    whether read-only mode is enabled for this index.

  • parameter log_size

    the maximum number of bindings in the `log` IO.

val clear : t -> unit

clear t clears t so that there are no more bindings in it.

val find : t -> key -> value

find t k is the binding of k in t.

val mem : t -> key -> bool

mem t k is true iff k is bound in t.

exception Invalid_key_size of key
exception Invalid_value_size of value

The exceptions raised when trying to add a key or a value of different size than encoded_size

val replace : t -> key -> value -> unit

replace t k v binds k to v in t, replacing any existing binding of k.

val filter : t -> ((key * value) -> bool) -> unit

filter t p removes all the bindings (k, v) that do not satisfy p. This operation is costly and blocking.

val iter : (key -> value -> unit) -> t -> unit

Iterates over the index bindings. Limitations:

  • Order is not specified.
  • In case of recent replacements of existing values (since the last merge), this will hit both the new and old bindings.
  • May not observe recent concurrent updates to the index by other processes.
val flush : ?with_fsync:bool -> t -> unit

Flushes all internal buffers of the IO instances. If with_fsync is true, this also flushes the OS caches for each IO instance.

val close : t -> unit

Closes all resources used by t.

type async

The type of asynchronous computation.

val force_merge : ?hook:[ `After | `Before ] Hook.t -> t -> async

force_merge t forces a merge for t. Optionally, a hook can be passed that will be called twice:

  • `Before: immediately before merging (while holding the merge lock);
  • `After: immediately after merging (while holding the merge lock).
val await : async -> unit

Wait for an asynchronous computation to finish.

val replace_with_timer : ?sampling_interval:int -> t -> key -> value -> unit

Time replace operations. The reported time is an average on an number of consecutive operations, which can be specified by sampling_interval. If sampling_interval is not set, no operation is timed.

OCaml

Innovation. Community. Security.