package leveldb

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Iteration over bindings in a database.

val make : ?fill_cache:bool -> db -> iterator

Create a new iterator. Note that the iterator keeps a reference to the * DB, so the latter will not be GCed automatically as long as the iterator * is being used. Note also that if the DB is closed manually, the iterator * will be invalidated and further operations will fail. The returned * iterator needs not be closed manually, for it will be closed in its * finalizer.

val close : iterator -> unit

Close the iterator. Further operations on it will fail. Note that * the iterator fill be closed automatically in its finalizer if this * function is not called manually.

val seek_to_first : iterator -> unit

Jump the the first binding in the database/snapshot.

val seek_to_last : iterator -> unit

Jump the the last binding in the database/snapshot.

val seek : iterator -> string -> int -> int -> unit

seek it s off len seeks to first binding whose key is >= to the key * corresponding to the substring of s starting at off and of length * len. * Note that the contents of the key will be copied to the stack, so * exceedingly large keys could cause a stack overflow. *

  • raises Error

    if the offset/length does not represent a substring of the * key.

val next : iterator -> unit

Jump to the next binding.

val prev : iterator -> unit

Jump to the previous binding.

val valid : iterator -> bool
  • returns

    true iff the iterator is pointing to a binding.

val fill_key : iterator -> bytes ref -> int

fill_key it r places the key for the current binding in the string * referred to by r if it fits, otherwise it creates a new string and * updates the reference. *

  • raises Error

    if the iterator is not valid *

    @return

    length of the key

val fill_value : iterator -> bytes ref -> int

Similar to fill_key, but returning the value.

val get_key : iterator -> string

Return the key part of the binding pointer to by the iterator. *

val get_value : iterator -> string

Return the value part of the binding pointer to by the iterator. *

val iter : (string -> string -> bool) -> iterator -> unit

iter f db applies f to all the bindings in the database/snapshot the * iterator belongs to, until f returns false, i.e. runs f key value * for all the bindings in lexicographic key order.

val rev_iter : (string -> string -> bool) -> iterator -> unit

Like iter, but proceed in reverse lexicographic order.

val iter_from : (string -> string -> bool) -> iterator -> string -> unit

iter_from f it start applies f key value for all the bindings after * start (inclusive) until it returns false.

val rev_iter_from : (string -> string -> bool) -> iterator -> string -> unit

iter_from f it start applies f key value for all the bindings before * start (inclusive) in reverse lexicographic order until f returns * false..

OCaml

Innovation. Community. Security.