This package allows using files as a "
cache" for predicates defined by facts. This is useful for huge tables of facts that may push the memory limits of the system too far. Goals of a
filed predicate are executed simply by reading from the corresponding file.

Anything in the DB file used for the predicate that is different from a fact for the corresponding predicate is ignored. Each call to a filed predicate forces opening the file, so the use of this package is subject to the limit on the number of open files that the system can support.

Dynamic modification of the filed predicates is also allowed during execution of the program. Thus filed predicates are regarded as dynamic, data predicates residing in a file. However, dynamic modifications to the predicates do not affect the file, unless the predicate is also declared persistent.

The package is compatible with
persdb in the sense that a predicate can be made both filed and persistent. In this way, the predicate can be used in programs, but it will not be loaded (saving memory), can also be modified during execution, and modifications will persist in the file. Thus, the user interface to both packages is the same (so the DB file must be one for both filing and persistency).

Library usage:
This facility is used as a package, thus either including
factsdb in the package list of the module, or by using the
use_package/1 declaration. The facility predicates are defined in library module
factsdb_rt.

Description: Version of
data_facts:asserta_fact/1 for filed predicates. The current instance of Fact is interpreted as a fact and is added at the beginning of the definition of the corresponding predicate. Therefore, before all the facts filed in the DB file for the predicate. The predicate concerned must be declared as
facts; if it is not, then
data_facts:asserta_fact/1 is used.

The following properties should hold at call time:Fact is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1)

PREDICATE:assertz_fact/1:

Meta-predicate with arguments: assertz_fact(fact).

Usage:assertz_fact(Fact)

Description: Version of
data_facts:assertz_fact/1 for filed predicates. The current instance of Fact is interpreted as a fact and is added at the end of the definition of the corresponding predicate. Therefore, after all the facts filed in the DB file for the predicate. The predicate concerned must be declared as
facts; if it is not, then
data_facts:assertz_fact/1 is used.

The following properties should hold at call time:Fact is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1)

PREDICATE:call/1:

Meta-predicate with arguments: call(fact).

Usage:call(Fact)

Description: Same as
current_fact/1 if the predicate concerned is declared as
facts. If it is not, an exception is raised.

The following properties should hold at call time:Fact is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1)

PREDICATE:current_fact/1:

Meta-predicate with arguments: current_fact(fact).

Usage:current_fact(Fact)

Description: Version of
data_facts:current_fact/1 for filed predicates. The current instance of Fact is interpreted as a fact and is unified with an actual fact in the current definition of the corresponding predicate. Therefore, with a fact previously asserted or filed in the DB file for the predicate, if it has not been retracted. The predicate concerned must be declared as
facts; if it is not, then
data_facts:current_fact/1 is used.

The following properties should hold at call time:Fact is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1)

PREDICATE:retract_fact/1:

Meta-predicate with arguments: retract_fact(fact).

Usage:retract_fact(Fact)

Description: Version of
data_facts:retract_fact/1 for filed predicates. The current instance of Fact is interpreted as a fact and is unified with an actual fact in the current definition of the corresponding predicate; such a fact is deleted from the predicate definition. This is true even for the facts filed in the DB file for the predicate; but these are NOT deleted from the file (unless the predicate is persistent). The predicate concerned must be declared as
facts; if it is not, then
data_facts:retract_fact/1 is used.

The following properties should hold at call time:Fact is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1)

Description: Declares the predicate PredDesc as filed. Keyword is the
identifier of a location where the file DB for the predicate is kept. The location Keyword is described in the
file_alias predicate, which must contain a fact in which the first argument unifies with Keyword.

The following properties should hold upon exit:PredDesc is a Name/Arity structure denoting a predicate name:

predname(P/A) :-
atm(P),
nnegint(A).

(basic_props:predname/1)
Keyword is an atom corresponding to a directory identifier.
(persdbcache:keyword/1)

PREDICATE:keyword/1:

See
persdbrt. The same conventions for location of DB files apply in both packages.

The DB files for persistent predicates have to be used as such from the beginning. Using a DB file for a filed predicate first, and then using it also when making the predicate persistent won't work. Nor the other way around: using a DB file for a persistent predicate first, and then using it also when making the predicate filed.