HASHKIT_SET_FUNCTION(3)
π NAME π
hashkit_set_function β libhashkit Documentation. Periodt.
Okay bestie, quick vibe check before we dive in: this is a section 3 page from the libmemcached-awesome manual, and it's your one-stop shop for telling hashkit which hash function to use and asking it which one it's using. Let's get into it π
π¦ 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)
Here's what all that means, no gatekeeping:
- key β the key to generate a hash of
- key_length β the length of the key without any terminating zero byte
- context β the custom hash function context set through
hashkit_set_custom_function()orhashkit_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
HASHKIT_SUCCESSβ Operation succeeded. πHASHKIT_FAILUREβ Operation failed. πHASHKIT_MEMORY_ALLOCATION_FAILUREβ Memory allocation failed.HASHKIT_INVALID_HASHβ Invalidhashkit_hash_algorithm_tpassed.HASHKIT_INVALID_ARGUMENTβ Invalid argument passed.
typedef enum hashkit_hash_algorithm_t hashkit_hash_algorithm_t
enum hashkit_hash_algorithm_t
HASHKIT_HASH_DEFAULTβ Default hash algorithm (one_at_a_time).HASHKIT_HASH_MD5HASHKIT_HASH_CRCHASHKIT_HASH_FNV1_64HASHKIT_HASH_FNV1A_64HASHKIT_HASH_FNV1_32HASHKIT_HASH_FNV1A_32HASHKIT_HASH_HSIEHβ Only available if libhashkit hash been built with HSIEH support. (yes, "hash been", I'm just reporting the lore π«Ά)HASHKIT_HASH_MURMURβ Only available if libhashkit has been built with MURMUR support.HASHKIT_HASH_MURMUR3β Only available if libhashkit has been built with MURMUR support.HASHKIT_HASH_JENKINSHASHKIT_HASH_CUSTOMβ Use customhashkit_hash_fnfunction set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function().
Now the actual functions, the main characters π
hashkit_return_t hashkit_set_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)
Parameters
- hash -- pointer to an initialized
hashkit_ststruct - hash_algorithm -- valid
hashkit_hash_algorithm_tconstant
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_ststruct - function --
hashkit_hash_fnfunction pointer to use as hash function forHASHKIT_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_ststruct
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_ststruct - hash_algorithm -- valid
hashkit_hash_algrothm_tconstant
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_ststruct - function --
hashkit_hash_fnfunction pointer to use as distribution hash function forHASHKIT_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_ststruct
Returns β hashkit_hash_algorithm_t indicating the currently set distribution hash algorithm to use
β¨ DESCRIPTION β¨
These functions are used to set and retrieve the key and distribution hash functions. That's it, that's the whole vibe β you're either telling hashkit which function to use, or asking it which one it's on. Simple, iconic, we love a low-drama API πΈ
π 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 π
That's the whole page bestie, go forth and hash responsibly πβ¨
libmemcached-awesome, version 1.1 β Jul 24, 2025 β HASHKIT_SET_FUNCTION(3) π¦π
π¦ where this page comes from
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms