Module Cdb

module Cdb: sig .. end

Disk-based constant hash tables (Dustin Sallings)

DJB's fast, reliable, simple package for creating and reading constant databases.

CDB Definition. http://cr.yp.to/cdb.html

OCaml code Copyright (c) 2003 Dustin Sallings <dustin@spy.net>

arch-tag: 1E3B7401-2AE1-11D8-A379-000393CB0F1E

Snarfed from: <http://www.west.spy.net/~dustin/projects/ocaml/doc/Cdb.html>

Hacked by KW 20060908T025444 <http://www.lib.uchicago.edu/keith/>

-- inlined Extoption.is_none to remove sole external dependency
Author(s): Dustin Sallings



CDB creation handle.
type cdb_creator = {
   table_count : int array;
   mutable pointers : (Int32.t * Int32.t) list;
   out : Pervasives.out_channel;
}
val is_none : 'a option -> bool

Initial hash value
val hash_init : int64
val ff64 : int64
val ffffffff64 : int64
val ff32 : int32

Hash the given string.
val hash : string -> int32
val write_le : cdb_creator -> int -> unit

Write a little endian integer to the file
val write_le32 : cdb_creator -> int32 -> unit

Open a cdb creator for writing.
val open_out : string -> cdb_creator

Convert out_channel to cdb_creator.
val cdb_creator_of_out_channel : Pervasives.out_channel -> cdb_creator
val hash_to_table : int32 -> int
val hash_to_bucket : int32 -> int -> int
val pos_out_32 : Pervasives.out_channel -> int32

Add a value to the cdb
val add : cdb_creator -> string -> string -> unit

Process a hash table
val process_table : cdb_creator ->
int array ->
(int32 * int32) list Pervasives.ref ->
(int, int32 * int32) Hashtbl.t -> int -> int -> unit

Close and finish the cdb creator.
val close_cdb_out : cdb_creator -> unit

Iterating a cdb file
val read_le : Pervasives.in_channel -> int
val read_le32 : Pervasives.in_channel -> int32

Iterate a CDB.
val iter : (string -> string -> 'a) -> string -> unit

Searching

Type type of a cdb_file.
type cdb_file = {
   f : Pervasives.in_channel;
   tables : (Int32.t * int) array;
}
Open a CDB file for searching.
val open_cdb_in : string -> cdb_file

Close a cdb file.
val close_cdb_in : cdb_file -> unit

Get a stream of matches.
val get_matches : cdb_file -> string -> string Stream.t

Find the first record with the given key.
val find : cdb_file -> string -> string