GNU Database Manager


The gdbm vocabulary provides an interface to GNU DataBase Manager. This is a GNU implementation of the standard Unix dbm library, originally developed at Berkeley.

This is a very brief manual. For a more detailed description consult the official gdbm documentation.

Basics
All interaction with gdbm database should be realized using special combinator which automates all work for database initialisation and cleanup. All initialisation options are passed to combinator with a database configuration object.
gdbm

<gdbm> ( -- gdbm )

with-gdbm ( gdbm quot -- )


For actual record manipulation the following words are used:
gdbm-insert ( key content -- )

gdbm-exists? ( key -- ? )

gdbm-fetch ( key -- content/f )

gdbm-delete ( key -- )


Sequential access
It is possible to iterate through all records in the database with
gdbm-first-key ( -- key/f )

gdbm-next-key ( key -- key/f )


The following combinators, however, provide more convenient way to do that:
each-gdbm-key ( ... quot: ( ... key -- ... ) -- ... )

each-gdbm-value ( ... quot: ( ... value -- ... ) -- ... )

each-gdbm-record ( ... quot: ( ... key value -- ... ) -- ... )


The order in which records are accessed has nothing to do with the order in which records have been stored. Note that these words can only be used in read-only algorithms since delete operation re-arranges the hash table.