Various wrappers for DHT logics module
Author(s): Arsen Kostenko.
This module contains miscellaneous predicates related to the dht_logic.pl module. Mostly various calculation-wrappers.
Usage and interface
- Library usage:
:- use_module(library(dht_logic_misc)). - Exports:
- Imports:
- System library modules:
indexer/hash, dht/dht_config. - Packages:
prelude, nonpure, assertions, regtypes, isomodes.
- System library modules:
Documentation on exports
Usage:hash_size(Size)
The only purpose of hash_size/1 predicate is to get corresponding value from system wide configurations stored in dht_config.pl file and convert it into the number of nodes virtually available in the current DHT installation.
- The following properties should hold at call time:
(term_typing:var/1)Size is a free variable. - The following properties should hold upon exit:
(basic_props:gnd/1)Size is ground.
(basic_props:int/1)Size is an integer.
Usage 1:highest_hash_number(N)
If used with a ground argument highest_hash_number/1 simply checks whether the value supplied corresponds to the biggest hash number possible in the DHT.
- The following properties should hold at call time:
(basic_props:int/1)N is an integer.
Usage 2:highest_hash_number(N)
Otherwise (if argument happens to be a free variable) the value of N is bound to the highest hash number possible in the DHT.
- The following properties should hold at call time:
(term_typing:var/1)N is a free variable. - The following properties should hold upon exit:
(basic_props:int/1)N is an integer.
Usage:consistent_hash(Term,DHTHash)
Straightforward computation of hash (DHTHash) on the basis of Term supplied.
- The following properties should hold at call time:
(basic_props:term/1)Term is any term.
(term_typing:var/1)DHTHash is a free variable. - The following properties should hold upon exit:
(basic_props:term/1)Term is any term.
(basic_props:int/1)DHTHash is an integer.
Usage:next_on_circle(Id,Num)
next_on_circle/2 is a calculation wrapping. One can only use it with first argument ground and equal to integer value. What is more, that value MUST be kept within certain bounds: value of Id MUST meet the constraints 0<=Id<=HighNum, where HighNum is retrieved via highest_hash_number/1 predicate.
- The following properties should hold at call time:
(basic_props:int/1)Id is an integer.
(term_typing:var/1)Num is a free variable. - The following properties should hold upon exit:
(basic_props:int/1)Id is an integer.
(basic_props:int/1)Num is an integer.
Usage:not_in_circle_oc(Id,Start,End)
Yet another wrapper around simple calculations. All arguments are expected to be ground, by the time the predicate is called. The predicate checks whether the value supplied as Id fits into circle sector defined by values of Start and End. If the condition is not true - the whole predicate fails.
- The following properties should hold at call time:
(basic_props:int/1)Id is an integer.
(basic_props:int/1)Start is an integer.
(basic_props:int/1)End is an integer.
Usage:in_circle_oo(Id,Start,End)
Check whether value of Id fits into sector defined by Start and End excluding both, fail otherwise.
- The following properties should hold at call time:
(basic_props:int/1)Id is an integer.
(basic_props:int/1)Start is an integer.
(basic_props:int/1)End is an integer.
Usage:in_circle_oc(Id,Start,End)
Check whether value of Id fits into sector defined by Start and End excluding first and including second. Fail if the condition does not hold.
- The following properties should hold at call time:
(basic_props:int/1)Id is an integer.
(basic_props:int/1)Start is an integer.
(basic_props:int/1)End is an integer.