dbh_genkey(3)

πŸ“¦ version 5.0.22, in fedora 43, fedora 44

πŸ’– dbh_genkey(3) πŸ’–

okay so bestie, you found the DBHashTables Programmers' Manual page for key generation and honestly? it's giving ✨ foundational ✨. this is dbh_genkey, dbh_genkey2, and dbh_orderkey β€” the trio that makes your hash tree balanced and gorgeous. let's get into it 🫢


πŸŽ€ NAME πŸŽ€

dbh_genkey, dbh_genkey2, dbh_orderkey β€” 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 πŸ¦‹

so dbh_genkey and dbh_genkey2 pull a key out of a secuential series of natural numbers (positive integers, no zero, we don't do zero here bestie) β€” but here's the tea: they do not conserve the order of the natural numbers. instead they're optimized for building a balanced hash tree, which is literally the whole point. 🌈

the difference between the two? the flavour of the key:

  • 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.

then there's dbh_orderkey, our main character πŸ‘‘. it also grabs a key from a secuential series of natural numbers (again: positive integers, zero not invited), but it does conserve the order of the natural numbers. the key it generates belongs to a finite subset of the cuantified numbers, and it preserves the order of the natural numbers β€” up to the supreme, of course. 😌

in all of these:

  • key is a pointer to the address where you put the generated key πŸ’–
  • length is the key length
  • n is the natural number you're generating a key for

and for dbh_orderkey specifically, base is the number system base to use. this equals the maximum number of nodes per branch. this β€” along with the keylength β€” will define a maximum number of records for the DBHashTable. so like, choose wisely bestie, that's a whole ceiling you're setting 🫠


✨ RETURN VALUE ✨

these functions do not return any value. that's it. that's the section. no return, no drama, just vibes πŸ’…


πŸ’œ NOTES πŸ’œ

cuantified numbers are an alternate way to look at the set of natural numbers {1, 2, 3, ...} where order is defined in two levels. in natural numbers there's only one level of order β€” defined by the > boolean operator. simple. clean. iconic.

in cuantified numbers, the first level of order is defined by the cuanta or quantity. the cuanta? you get it by adding up all the digits of the cuantified number. so for example:

10022, 5, 32, and 11111 are all equal at the first level of order, because they all add up to 5. 🀯 periodt.

the second level of order may be obtained in different manners, and this is where the three functions diverge:

  • in dbh_genkey and dbh_genkey2, the corresponding order of the natural numbers they're associated with is not conserved. πŸ™ˆ
  • in dbh_orderkey, the corresponding order of the natural numbers they're associated with 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.
⚠️ so yeah, dbh_orderkey keeps your order intact but makes you pay the base tax. no free lunch, bestie.

and here's the slay part: 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. πŸ”₯ which means a DBHashTable can be constructed with minimum access time across all records. efficient queen. πŸ‘‘


🌟 SEE ALSO 🌟

  • dbh (0)
  • dbh_update (3)
  • dbh_load (3)

πŸ’Œ Author πŸ’Œ

Edscott Wilson Garcia <edscott@xfce.org> 🫢


DBHashTables Β· DBH Β· dbh_genkey(3) β€” mwah, go build that balanced tree bestie, you got this πŸ’–βœ¨πŸ¦‹πŸŽ€πŸ’…

πŸ“¦ where this page comes from