db_open_env(
+EnvName,
-EnvRef)
db_open_env(
+EnvName,
+CacheSize,
-EnvRef)
absolute_file_name/3
conversion.
By using db_open_env/3
one can specify the size of the cache:
CacheSize is the (integer) size of the cache in kilobytes. The
size of the cache cannot be less than 20 kilobytes.
db_open_env/2
will create a cache of the system's default size.
The size of the cache is determined when the environment is created and cannot be changed by future openings.
A process cannot open the same environment more than once.
db_close_env(
+EnvRef)
db_current_env(
?EnvName,
?EnvRef)
db_open(
+DBName,
+Mode,
?SpecList,
-DBRef)
db_open(
+DBName,
+Mode,
?SpecList,
+Options,
-DBRef)
update
and the
db-spec SpecList must be ground. If an existing
database is opened and Mode is read
or update
,
SpecList is unified with the db-spec given when the
database was created. If the unification fails an error is
raised. DBRef is unified with a reference to the opened
database. DBName is not subject to
absolute_file_name/3
conversion.
If Mode is enumerate
then the indexing specification is not
read, and SpecList is left unbound.
Options provides a way to specify an environment in which to open the database, or a cache size. Options should be a list of terms of the following form:
environment(
EnvRef)
cache_size(
CacheSize)
default
, a default cache size will be used. If
CacheSize is given as the atom off
or the atom
none
, all modified records will be flushed to disk after each
operation.
To avoid inconsistency, if multiple processes open the same
database, then all of them should do that with Mode set to
read
or enumerate
. (This is not enforced by the system.)
db_close(
+DBRef)
db_current(
?DBName,
?Mode,
?SpecList,
?EnvRef,
?DBRef)
none
.
db_store(
+DBRef,
+Term,
-TermRef)
db_fetch(
+DBRef,
?Term,
?TermRef)
If TermRef is not instantiated then both the functor and the instantiatedness of Term must match a spec in the db-spec associated with DBRef.
If TermRef is instantiated, the referenced term is read and unified with Term.
If you simply want to find all matching terms, it is more
efficient to use db_findall/5
or db_enumerate/3
.
db_findall(
+DBRef,
+Template,
+Term,
:Goal,
?Bag)
findall(
Template, (db_fetch(
DBRef,
Term, _),
Goal),
Bag)
.
db_erase(
+DBRef,
+TermRef)
db_erase(
+DBRef,
+TermRef,
+Term)
In the case of db_erase/2
the term associated with
TermRef has to be looked up. db_erase/3
assumes that the
term Term is identical with the term associated with
TermRef (modulo variable renaming). If this is not the
case, the behavior is undefined.
db_enumerate(
+DBRef,
?Term,
?TermRef)
Unifies Term with a term from the database DBRef. At the same time, TermRef is unified with a corresponding term reference. Backtracking over the predicate unifies with all terms matching Term.
Implemented by linear search—the db-spec associated with DBRef
is ignored. It is not useful to call this predicate with
TermRef instantiated.
db_sync(
+DBRef)
db_compress(
+DBRef,
+DBName)
db_compress(
+DBRef,
+DBName,
+SpecList)
db_compress/2
looks for a database with the db-spec of the
original one. db_compress/3
stores the terms found in the
original database with the indexing specification SpecList.
db_compress/2
cannot be used if the database DBRef
was opened in mode enumerate
.
If the database DBName already exists then the terms of DBRef will be appended to it. Of course DBName must have an indexing specification, which enables the terms in DBRef to be inserted into it.
In the case of db_compress/3
if the database DBName
does not exist, then SpecList must be a valid indexing
specification.
db_make_iterator(
+DBRef,
-Iterator)
db_make_iterator(
+DBRef,
+Term,
-Iterator)
db_make_iterator/2
iterate through the
whole database. Iterators created with db_make_iterator/3
iterate through the terms that would be found by
db_fetch(
DBRef,
Term, _)
.
Every iterator created by db_make_iterator/[2,3]
must be
destroyed with db_iterator_done/1
.
db_iterator_next(
+Iterator,
?Term,
?TermRef)
db_iterator_done(
+Iterator)
db_current_iterator(
?DBRef,
?Term,
?Iterator)
db_make_iterator/2
then Term will be left
unbound.
db_export(
+DBName,
+ExportFile)
db_export(
+DBName,
+Options,
+ExportFile)
db_import/[2,3]
.
Options should be an options list of the form acceptable by
db_open/[4,5]
.
In SICStus 3.12.0 bdb:export/[2,3]
is available instead of
db_export/[2,3]
.
db_import(
+DBName,
+ImportFile)
db_import(
+DBName,
+Options,
+ImportFile)
If ImportFile is imported into an existing database, the SpecList found in the ImportFile will be unified with the SpecList in the database.
Options should be an options list of the form acceptable by
db_open/[4,5]
.
In SICStus 3.12.0 bdb:import/[2,3]
is available instead of
db_import/[2,3]
.