dbh_genkey - Man Page

generate cuantified or ordered keys

Synopsis

#include <dbh.h>

void dbh_genkey (unsigned char *key, unsigned char length, unsigned int n);
void dbh_genkey2 (unsigned char *key, unsigned char length, unsigned int n);
void dbh_orderkey (unsigned char *key, unsigned char length, unsigned int n, unsigned char base);

Description

dbh_genkey and dbh_genkey2 obtain a key from a secuential series of natural numbers (positive integers without zero) which does not conserve the order of the natural numbers, but which are optimized for construction of a balanced hash tree. In dbh_genkey the key is expressed in cuantified numbers based on the 0 digit. In dbh_genkey2 the key is expressed in cuantified numbers based on the A symbol.

dbh_orderkey will obtain a key from a secuential series of natural numbers (positive integers without zero) which conserves the order of the natural numbers. This function generates a key that belongs to a finite subset of the cuantified numbers, but which preserves the order of the natural numbers (up to the supreme, of course).

In these functions key is pointer to the address where to put the generated key, length is the key length, and n is the natural number for which to generate the key. For dbh_orderkey base is the number system base to use. This will equal the maximum number of nodes per branch. This ---along with the keylength--- will  define a maximum number of records for the DBHashTable.

Return Value

These functions do not return any value.

Notes

Cuantified numbers are an alternate way to view the set of natural numbers {1, 2, 3, ...} where  order is defined in two levels. In natural numbers there is only one level of order (defined by the > boolean operator). In cuantified numbers the first level of order is defined by the cuanta or quantity. The cuanta is obtained by adding all the digits of the cuantified number. Thus, for example, 10022, 5, 32, and 11111 are all equal at the first level  of order since they all add up to 5. The second level or order may be obtained in different manners. In functions dbh_genkey and dbh_genkey2 the corresponding order of the natural numbers from which they are associated is not conserved. In dbh_orderkey the corresponding order of the natural numbers from which they are associated is conserved, but at a price. The base, or maximum value each digit may reach, must be defined. This effectively puts a limit on the number of keys which may be generated for a given number of digits.

When a DBHashTable is constructed with cuantified keys, the maximum amount of disk access instructions generated to access any given record is equal to the cuanta of the cuantified number represented by the key. This allows a DBHashTable to be constructed with minimum access time across all records.

See Also

dbh (0), dbh_update (3), dbh_load (3)

Author

Edscott Wilson Garcia <edscott@xfce.org>

Referenced By

dbh(3), dbh_open(3).

The man pages dbh_genkey2(3) and dbh_orderkey(3) are aliases of dbh_genkey(3).

DBH DBHashTables Programmers' Manual