gdbm: drop "gdbm-" prefix

db4
Dmitry Shubin 2010-06-28 02:17:11 +04:00
parent 8790c73a26
commit 6705f4f466
3 changed files with 48 additions and 48 deletions

View File

@ -32,7 +32,7 @@ HELP: gdbm-info
{ $values { "str" string } } { $values { "str" string } }
{ $description "Returns version number and build date." } ; { $description "Returns version number and build date." } ;
HELP: gdbm-delete HELP: delete
{ $values { "key" object } } { $values { "key" object } }
{ $description "Removes the keyed item from the database." } ; { $description "Removes the keyed item from the database." } ;
@ -40,69 +40,69 @@ HELP: gdbm-error-message
{ $values { "error" gdbm-error } { "msg" string } } { $values { "error" gdbm-error } { "msg" string } }
{ $description "Returns error message in human readable format." } ; { $description "Returns error message in human readable format." } ;
HELP: gdbm-exists HELP: exists?
{ $values { "key" object } { "?" boolean } } { $values { "key" object } { "?" boolean } }
{ $description "Searches for a particular key without retreiving it." } ; { $description "Searches for a particular key without retreiving it." } ;
HELP: gdbm-fdesc HELP: gdbm-file-descriptor
{ $values { "desc" integer } } { $values { "desc" integer } }
{ $description "Returns the file descriptor of the database. This is used for manual database locking if it was opened with " { $snippet "nolock" } " flag set to " { $link t } "." } ; { $description "Returns the file descriptor of the database. This is used for manual database locking if it was opened with " { $snippet "nolock" } " flag set to " { $link t } "." } ;
HELP: gdbm-fetch HELP: fetch
{ $values { $values
{ "key" object } { "key" object }
{ "content/f" { "the value associated with " { $snippet "key" } " or " { $link f } " if there is no such key" } } { "content/f" { "the value associated with " { $snippet "key" } " or " { $link f } " if there is no such key" } }
} }
{ $description "Looks up a given key and returns value associated with it. This word makes no distinction between a missing value and a value set to " { $link f } "." } ; { $description "Looks up a given key and returns value associated with it. This word makes no distinction between a missing value and a value set to " { $link f } "." } ;
HELP: gdbm-fetch* HELP: fetch*
{ $values { "key" object } { "content" object } { "?" boolean } } { $values { "key" object } { "content" object } { "?" boolean } }
{ $description "Looks up a given key and returns value associated with it. The boolean flag can decide between the case of a missing value, and a value of " { $link f } "." } ; { $description "Looks up a given key and returns value associated with it. The boolean flag can decide between the case of a missing value, and a value of " { $link f } "." } ;
HELP: gdbm-first-key HELP: first-key
{ $values { "key/f" object } } { $values { "key/f" object } }
{ $description "Returns first key in the database. This word makes no distinction between an empty database case and a case of a first value set to " { $link f } "." } ; { $description "Returns first key in the database. This word makes no distinction between an empty database case and a case of a first value set to " { $link f } "." } ;
HELP: gdbm-first-key* HELP: first-key*
{ $values { "key" object } { "?" boolean } } { $values { "key" object } { "?" boolean } }
{ $description "Returns first key in the database. The boolean flag can decide between the case of an empty database and a case of a first value set to " { $link f } "." } ; { $description "Returns first key in the database. The boolean flag can decide between the case of an empty database and a case of a first value set to " { $link f } "." } ;
HELP: gdbm-insert HELP: insert
{ $values { "key" object } { "content" object } } { $values { "key" object } { "content" object } }
{ $description "Inserts record into the database. Throws an error if the key already exists." } ; { $description "Inserts record into the database. Throws an error if the key already exists." } ;
HELP: gdbm-next-key HELP: next-key
{ $values { "key" object } { "key/f" object } } { $values { "key" object } { "key/f" object } }
{ $description "Given a key returns next key in the database. This word makes no distinction between reaching the end of the database case and a case of a next value set to " { $link f } "." } ; { $description "Given a key returns next key in the database. This word makes no distinction between reaching the end of the database case and a case of a next value set to " { $link f } "." } ;
HELP: gdbm-next-key* HELP: next-key*
{ $values { "key" object } { "next-key" object } { "?" boolean } } { $values { "key" object } { "next-key" object } { "?" boolean } }
{ $description "Given a key returns next key in the database. The boolean flag can decide between the case of reaching the end of the database and a case of a next value set to " { $link f } "." } ; { $description "Given a key returns next key in the database. The boolean flag can decide between the case of reaching the end of the database and a case of a next value set to " { $link f } "." } ;
HELP: gdbm-reorganize HELP: reorganize
{ $description "Reorganisation is a process of shinking the space used by gdbm. This requires creating a new file and moving all elements from old gdbm file to new one." } ; { $description "Reorganisation is a process of shinking the space used by gdbm. This requires creating a new file and moving all elements from old gdbm file to new one." } ;
HELP: gdbm-replace HELP: replace
{ $values { "key" object } { "content" object } } { $values { "key" object } { "content" object } }
{ $description "Inserts record into the database replacing old value with the new one if the key already exists." } ; { $description "Inserts record into the database replacing old value with the new one if the key already exists." } ;
HELP: gdbm-set-block-merging HELP: set-block-merging
{ $values { "?" boolean } } { $values { "?" boolean } }
{ $description "If set, this option causes adjacent free blocks to be merged. The default is " { $link f } "." } ; { $description "If set, this option causes adjacent free blocks to be merged. The default is " { $link f } "." } ;
HELP: gdbm-set-block-pool HELP: set-block-pool
{ $values { "?" boolean } } { $values { "?" boolean } }
{ $description "If set, this option causes all subsequent free blocks to be placed in the global pool. The default is " { $link f } "." } ; { $description "If set, this option causes all subsequent free blocks to be placed in the global pool. The default is " { $link f } "." } ;
HELP: gdbm-set-cache-size HELP: set-cache-size
{ $values { "size" integer } } { $values { "size" integer } }
{ $description "Sets the size of the internal bucket cache. The default value is 100. This option may only be set once." } ; { $description "Sets the size of the internal bucket cache. The default value is 100. This option may only be set once." } ;
HELP: gdbm-set-sync-mode HELP: set-sync-mode
{ $values { "?" boolean } } { $values { "?" boolean } }
{ $description "Turns on or off file system synchronization. The default is " { $link f } "." } ; { $description "Turns on or off file system synchronization. The default is " { $link f } "." } ;
HELP: gdbm-sync HELP: synchronize
{ $description "Performs database synchronization: make sure the disk version of the database has been completely updated." } ; { $description "Performs database synchronization: make sure the disk version of the database has been completely updated." } ;
HELP: with-gdbm HELP: with-gdbm
@ -122,11 +122,11 @@ $nl
"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." "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."
{ $subsections gdbm <gdbm> with-gdbm } { $subsections gdbm <gdbm> with-gdbm }
"For actual record manipulation the following words are used:" "For actual record manipulation the following words are used:"
{ $subsections gdbm-insert gdbm-exists gdbm-fetch gdbm-delete } { $subsections insert exists? fetch delete }
{ $heading "Sequential access" } { $heading "Sequential access" }
"It is possible to iterate through all records in the database with." "It is possible to iterate through all records in the database with."
{ $subsections gdbm-first-key gdbm-next-key } { $subsections first-key next-key }
"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." "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."
; ;

View File

@ -20,30 +20,30 @@ CLEANUP
test.db reader >>role [ ] with-gdbm test.db reader >>role [ ] with-gdbm
] [ gdbm-file-open-error = ] must-fail-with ] [ gdbm-file-open-error = ] must-fail-with
[ f ] [ [ "foo" gdbm-exists ] with-test.db ] unit-test [ f ] [ [ "foo" exists? ] with-test.db ] unit-test
[ ] [ [ "foo" 41 gdbm-insert ] with-test.db ] unit-test [ ] [ [ "foo" 41 insert ] with-test.db ] unit-test
[ [
[ "foo" 42 gdbm-insert ] with-test.db [ "foo" 42 insert ] with-test.db
] [ gdbm-cannot-replace = ] must-fail-with ] [ gdbm-cannot-replace = ] must-fail-with
[ ] [ ]
[ [
[ [
"foo" 42 gdbm-replace "foo" 42 replace
"bar" 43 gdbm-replace "bar" 43 replace
"baz" 44 gdbm-replace "baz" 44 replace
] with-test.db ] with-test.db
] unit-test ] unit-test
[ 42 t ] [ [ "foo" gdbm-fetch* ] with-test.db ] unit-test [ 42 t ] [ [ "foo" fetch* ] with-test.db ] unit-test
[ f f ] [ [ "unknown" gdbm-fetch* ] with-test.db ] unit-test [ f f ] [ [ "unknown" fetch* ] with-test.db ] unit-test
[ [
[ [
300 gdbm-set-cache-size 300 gdbm-set-cache-size 300 set-cache-size 300 set-cache-size
] with-test.db ] with-test.db
] [ gdbm-option-already-set = ] must-fail-with ] [ gdbm-option-already-set = ] must-fail-with
@ -51,8 +51,8 @@ CLEANUP
[ [
V{ } V{ }
[ [
gdbm-first-key first-key
[ gdbm-next-key* ] [ [ swap push ] 2keep ] do while drop [ next-key* ] [ [ swap push ] 2keep ] do while drop
] with-test.db ] with-test.db
V{ "foo" "bar" "baz" } set= V{ "foo" "bar" "baz" } set=
@ -60,7 +60,7 @@ CLEANUP
[ f ] [ f ]
[ [
test.db newdb >>role [ "foo" gdbm-exists ] with-gdbm test.db newdb >>role [ "foo" exists? ] with-gdbm
] unit-test ] unit-test

View File

@ -71,42 +71,42 @@ PRIVATE>
: gdbm-error-message ( error -- msg ) gdbm_strerror ; : gdbm-error-message ( error -- msg ) gdbm_strerror ;
: gdbm-replace ( key content -- ) GDBM_REPLACE gdbm-store ; : replace ( key content -- ) GDBM_REPLACE gdbm-store ;
: gdbm-insert ( key content -- ) GDBM_INSERT gdbm-store ; : insert ( key content -- ) GDBM_INSERT gdbm-store ;
: gdbm-delete ( key -- ) : delete ( key -- )
[ dbf swap object>datum gdbm_delete check-error ] [ dbf swap object>datum gdbm_delete check-error ]
with-destructors ; with-destructors ;
: gdbm-fetch* ( key -- content ? ) : fetch* ( key -- content ? )
[ dbf swap object>datum gdbm_fetch datum>object* ] [ dbf swap object>datum gdbm_fetch datum>object* ]
with-destructors ; with-destructors ;
: gdbm-first-key* ( -- key ? ) : first-key* ( -- key ? )
[ dbf gdbm_firstkey datum>object* ] with-destructors ; [ dbf gdbm_firstkey datum>object* ] with-destructors ;
: gdbm-next-key* ( key -- next-key ? ) : next-key* ( key -- next-key ? )
[ dbf swap object>datum gdbm_nextkey datum>object* ] [ dbf swap object>datum gdbm_nextkey datum>object* ]
with-destructors ; with-destructors ;
: gdbm-fetch ( key -- content/f ) gdbm-fetch* drop ; : fetch ( key -- content/f ) fetch* drop ;
: gdbm-first-key ( -- key/f ) gdbm-first-key* drop ; : first-key ( -- key/f ) first-key* drop ;
: gdbm-next-key ( key -- key/f ) gdbm-next-key* drop ; : next-key ( key -- key/f ) next-key* drop ;
: gdbm-reorganize ( -- ) dbf gdbm_reorganize check-error ; : reorganize ( -- ) dbf gdbm_reorganize check-error ;
: gdbm-sync ( -- ) dbf gdbm_sync ; : synchronize ( -- ) dbf gdbm_sync ;
: gdbm-exists ( key -- ? ) : exists? ( key -- ? )
[ dbf swap object>datum gdbm_exists c-bool> ] [ dbf swap object>datum gdbm_exists c-bool> ]
with-destructors ; with-destructors ;
: gdbm-set-cache-size ( size -- ) GDBM_CACHESIZE setopt ; : set-cache-size ( size -- ) GDBM_CACHESIZE setopt ;
: gdbm-set-sync-mode ( ? -- ) GDBM_SYNCMODE setopt ; : set-sync-mode ( ? -- ) GDBM_SYNCMODE setopt ;
: gdbm-set-block-pool ( ? -- ) GDBM_CENTFREE setopt ; : set-block-pool ( ? -- ) GDBM_CENTFREE setopt ;
: gdbm-set-block-merging ( ? -- ) GDBM_COALESCEBLKS setopt ; : set-block-merging ( ? -- ) GDBM_COALESCEBLKS setopt ;
: gdbm-fdesc ( -- desc ) dbf gdbm_fdesc ; : gdbm-file-descriptor ( -- desc ) dbf gdbm_fdesc ;
: with-gdbm ( gdbm quot -- ) : with-gdbm ( gdbm quot -- )
[ gdbm-open &gdbm-close current-dbf set ] prepose curry [ gdbm-open &gdbm-close current-dbf set ] prepose curry