HASHKIT_SET_DISTRIBUTION_FUNCTION(3)

πŸ’– HASHKIT_SET_DISTRIBUTION_FUNCTION(3) πŸ’–

okay bestie, welcome to the libmemcached-awesome corner of the manual, page HASHKIT_SET...ION_FUNCTION(3). yes the title is literally truncated like that, that's just how man pages do. sit down, grab a boba, we're doing hash functions today πŸ§‹βœ¨


🌸 NAME 🌸

hashkit_set_distribution_function β€” libhashkit Documentation


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libhashkit-1.0/hashkit.h>

Compile and link with -lhashkit

typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length,
void *context)
  • Param key β€” the key to generate a hash of
  • Param key_length β€” the length of the key without any terminating zero byte
  • Param context β€” the custom hash function context set through hashkit_set_custom_function() or hashkit_set_custom_distribution_function()
  • Returns β€” the custom hash function should return a hash value for key as an unsigned 32bit integer
typedef enum hashkit_return_t hashkit_return_t
enum hashkit_return_t
  • enumerator HASHKIT_SUCCESS β€” Operation succeeded. πŸ’… we love a win
  • enumerator HASHKIT_FAILURE β€” Operation failed. 😭
  • enumerator HASHKIT_MEMORY_ALLOCATION_FAILURE β€” Memory allocation failed.
  • enumerator HASHKIT_INVALID_HASH β€” Invalid hashkit_hash_algorithm_t passed.
  • enumerator HASHKIT_INVALID_ARGUMENT β€” Invalid argument passed.
typedef enum hashkit_hash_algorithm_t hashkit_hash_algorithm_t
enum hashkit_hash_algorithm_t
  • enumerator HASHKIT_HASH_DEFAULT β€” Default hash algorithm (one_at_a_time).
  • enumerator HASHKIT_HASH_MD5
  • enumerator HASHKIT_HASH_CRC
  • enumerator HASHKIT_HASH_FNV1_64
  • enumerator HASHKIT_HASH_FNV1A_64
  • enumerator HASHKIT_HASH_FNV1_32
  • enumerator HASHKIT_HASH_FNV1A_32
  • enumerator HASHKIT_HASH_HSIEH β€” Only available if libhashkit hash been built with HSIEH support. (yes, "hash been". iconic typo, we keep it πŸ’€)
  • enumerator HASHKIT_HASH_MURMUR β€” Only available if libhashkit has been built with MURMUR support.
  • enumerator HASHKIT_HASH_MURMUR3 β€” Only available if libhashkit has been built with MURMUR support.
  • enumerator HASHKIT_HASH_JENKINS
  • enumerator HASHKIT_HASH_CUSTOM β€” Use custom hashkit_hash_fn function set through hashkit_set_custom_function() or hashkit_set_custom_distribution_function().

hashkit_return_t hashkit_set_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)

Parameters

  • hash -- pointer to an initialized hashkit_st struct
  • hash_algorithm -- valid hashkit_hash_algorithm_t constant

Returns β€” hashkit_return_t indicating success or failure


hashkit_return_t hashkit_set_custom_function(hashkit_st *hash,
hashkit_hash_fn function, void *context)

Parameters

  • hash -- pointer to initialized hashkit_st struct
  • function -- hashkit_hash_fn function pointer to use as hash function for HASHKIT_HASH_CUSTOM
  • context -- pointer to an opaque user managed context for the custom hash function

Returns β€” hashkit_return_t indicating success or failure


hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash)

Parameters

  • hash -- pointer to an initialized hashkit_st struct

Returns β€” hashkit_hash_algorithm_t indicating the currently set hash algorithm to use


hashkit_return_t hashkit_set_distribution_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)

Parameters

  • hash -- pointer to an initialized hashkit_st struct
  • hash_algorithm -- valid hashkit_hash_algrothm_t constant
bestie that algrothm spelling? that's literally in the source. not me fixing it. we're keeping the lore fr fr πŸ™ˆ

Returns β€” hashkit_return_t indicating success or failure


hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st
*hash, hashkit_hash_fn function, void *context)

Parameters

  • hash -- pointer to initialized hashkit_st struct
  • function -- hashkit_hash_fn function pointer to use as distribution hash function for HASHKIT_HASH_CUSTOM
  • context -- pointer to an opaque user managed context for the custom distribution hash function

hashkit_hash_algorithm_t hashkit_get_distribution_function(const
hashkit_st *hash)

Parameters

  • hash -- pointer to an initialized hashkit_st struct

Returns β€” hashkit_hash_algorithm_t indicating the currently set distribution hash algorithm to use


✨ DESCRIPTION ✨

so basically these functions are the ones you use to set and retrieve the key and distribution hash functions. that's the whole vibe. set it, get it, slay. πŸ‘‘


πŸŽ€ RETURN VALUE πŸŽ€

hashkit_set_function(), hashkit_set_custom_function() and the distribution equivalents return hashkit_return_t::HASHKIT_SUCCESS on success. πŸ’–

hashkit_get_function() and hashkit_get_distribution_function() return hashkit_hash_algorithm_t indicating the hash function used. πŸ¦‹


🌈 SEE ALSO 🌈

libhashkit(3) hashkit_create(3) hashkit_functions(3)


and that's a wrap, bestie!! this was libmemcached-awesome, version 1.1, dated Jul 24, 2025 β€” go forth and hash responsibly, ily, mwah πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from