Next: , Previous: , Up: lib-lmdb   [Contents][Index]


10.26.4 The DB-Spec—Informal Description

The db-spec defines which functors are allowed and which parts of a term are used for indexing in a database. The syntax of a db-spec is a skeletal goal with no module. The db-spec is a list of atoms and compound terms where the arguments are either + or -. A term can be inserted in the database if there is a spec in the spec list with the same functor.

Multilevel indexing is not supported, terms have to be “flattened”.

Every spec with the functor of the indexed term specifies an indexing. Every argument where there is a + in the spec is indexed on.

The idea of the db-spec is illustrated with a few examples. (A section further down explains the db-spec in a more formal way).

Given a spec of [f(+,-), .(+,-), g, f(-,+)] the indexing works as follows. (The parts with indexing are underlined.)

TermStoreFetch
g(x,y)domain errordomain error
f(A,B)f(A,B)instantiation error
-
f(a,b)f(a,b)  f(a,b)f(a,b)
- -     -   -- -
[a,b].(a,.(b,[])).(a,.(b,[]))
- -- -
ggg
--

The specification [f(+,-), f(-,+)] is different from [f(+,+)]. The first specifies that two indices are to be made whereas the second specifies that only one index is to be made on both arguments of the term.


Send feedback on this subject.