Underlying data-storage module
Author(s): Arsen Kostenko.
This module contains very low-level utilities of data storage specific to a single node. Neither data sharing nor remote invocation is performed at this level. Note that no dedicated data manipulation is performed neither on this level. Also keep in mind that concept of Key should always meet the same constraints as the second argument of functor/3 predicate. Important decision taken at this point is representation of all information stored in the DHT as usual Prolog facts. This behavior is implemented by representing relations of form Key -> Value in form of Key(Value) facts.
Usage and interface
- Library usage:
:- use_module(library(dht_storage)). - Exports:
- Predicates:
dht_store/3, dht_extract_b/2, dht_extract_nb/2, dht_consult_b/2, dht_consult_nb/2, dht_key_hash/2.
- Predicates:
- Imports:
- System library modules:
concurrency/concurrency. - Packages:
prelude, nonpure, assertions, regtypes, isomodes.
- System library modules:
Documentation on exports
Usage:dht_store(Key,KeyHash,Value)
The value provided in Value is stored under a key given as Key.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:int/1)KeyHash is an integer.
(basic_props:gnd/1)Value is ground.
Usage 1:dht_extract_b(Key,Value)
Search for exact fact.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 2:dht_extract_b(Key,Value)
Search for fact matching pattern. Pattern is supplied as Value.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(term_typing:var/1)Value is a free variable. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 1:dht_extract_nb(Key,Value)
Check that combination of Key/Value appears in database.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 2:dht_extract_nb(Key,Value)
Search for combination of Key/Value matching pattern. Pattern is supplied as Value.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(term_typing:var/1)Value is a free variable. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 1:dht_consult_b(Key,Value)
Search for exact combination of Key/Value.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 2:dht_consult_b(Key,Value)
Search for combination of Key/Value matching pattern. Pattern is supplied as Value.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 1:dht_consult_nb(Key,Value)
Search for exact combination of Key/Value.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 2:dht_consult_nb(Key,Value)
Search for combination of Key/Value matching pattern. Pattern is supplied as Value.
- The following properties should hold at call time:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground. - The following properties should hold upon exit:
(basic_props:atm/1)Key is an atom.
(basic_props:gnd/1)Value is ground.
Usage 1:dht_key_hash(Key,KeyHash)
The most general case (when both arguments are free) is searching for any key-hash pair stored in auxiliary database.
- The following properties should hold at call time:
(term_typing:var/1)Key is a free variable.
(term_typing:var/1)KeyHash is a free variable. - The following properties should hold upon exit:
(basic_props:gnd/1)Key is ground.
(basic_props:int/1)KeyHash is an integer.
Usage 2:dht_key_hash(Key,KeyHash)
Here Key is ground, which in turn leads to search for information on concrete predicate.
- The following properties should hold at call time:
(basic_props:gnd/1)Key is ground.
(term_typing:var/1)KeyHash is a free variable. - The following properties should hold upon exit:
(basic_props:gnd/1)Key is ground.
(basic_props:int/1)KeyHash is an integer.
Usage 3:dht_key_hash(Key,KeyHash)
On the contrary to previous example, this one has only second argument KeyHash ground. Therefore, this type of call would search for keys, that where mapped into given value of hash-function.
- The following properties should hold at call time:
(term_typing:var/1)Key is a free variable.
(basic_props:int/1)KeyHash is an integer. - The following properties should hold upon exit:
(basic_props:gnd/1)Key is ground.
(basic_props:int/1)KeyHash is an integer.
Usage 4:dht_key_hash(Key,KeyHash)
Finally, calling dht_key_hash with both arguments ground is similar to straight-forward check on auxiliary database, or to asking a question: “Does auxiliary database has any information on this key, which is mapped into that hash value?”
- The following properties should hold at call time:
(basic_props:gnd/1)Key is ground.
(basic_props:int/1)KeyHash is an integer.