Next: LMDB Export-Import, Previous: LMDB Example Session, Up: lib-lmdb [Contents][Index]

A db-spec has the form of a `SpecList`:

`speclist`=

`[`

`spec1`, …,`specM``]`

`spec`=

`functor``(`

`argspec1`, …,`argspecN``)`

`argspec`=

`+`

|`-`

where `functor` is a Prolog atom. The case `N` = 0 is
allowed.

A spec `F``(`

`argspec1`, …, `argspecN``)`

is
*applicable* to any nonvar term with principal functor
`F`/`N`.

When storing a term `T`, we generate a hash code for every
applicable spec in the db-spec, and a reference to `T` is stored
with each of them. (More precisely, with each element of the set of
generated hash codes). If `T` contains nonvar elements on each
`+`

position in the spec, then the hash code depends on each of
these elements. If `T` does contain some variables on
`+`

position, then the hash code depends only on the functor
of `T`.

When fetching a term `Q`, we look for an applicable spec for
which there are no variables in `Q` on positions marked
`+`

. If no applicable spec can be found, a domain error is raised.
If no spec can be found where on each `+`

position a nonvar
term occurs in `Q`, an instantiation error is raised.
Otherwise, we choose the spec with the most `+`

positions,
breaking ties by choosing the leftmost one.

The terms that contain nonvar terms on every `+`

position will be looked up using indexing based on the principal
functor of the term and the principal functor of
terms on `+`

positions. The other (more general)
terms will be looked up using an indexing based on the principal
functor of the term only.

Send feedback on this subject.