module Cdb: sig .. end
CDB Implementation.
http://cr.yp.to/cdb/cdb.txt
val hash : string -> int32
Building a CDB
type cdb_creator = {
|
table_count : int array; |
|
mutable pointers : (Int32.t * Int32.t) list; |
|
out : Pervasives.out_channel; |
}
CDB creation handle.
val open_out : string -> cdb_creator
Open a cdb creator for writing.
fn : the file to write
val cdb_creator_of_out_channel : Pervasives.out_channel -> cdb_creator
Convert out_channel to cdb_creator.
out_channel : the out_channel to convert
val add : cdb_creator -> string -> string -> unit
Add a value to the cdb
val close_cdb_out : cdb_creator -> unit
Close and finish the cdb creator.
Iterating a CDB
val iter : (string -> string -> unit) -> string -> unit
Iterate a CDB.
f : the function to call for every key/value pair
fn : the name of the cdb to iterate
Searching
type cdb_file = {
|
f : Pervasives.in_channel; |
|
tables : (Int32.t * int) array; |
}
Type type of a cdb_file.
val open_cdb_in : string -> cdb_file
Open a CDB file for searching.
fn : the file to open
val close_cdb_in : cdb_file -> unit
Close a cdb file.
cdf : the cdb file to close
val get_matches : cdb_file -> string -> string Stream.t
Get a stream of matches.
cdf : the cdb file
key : the key to search
val find : cdb_file -> string -> string
Find the first record with the given key.
cdf : the cdb_file
key : the key to find