hashkit_set_distribution_function - libhashkit Documentation
Contents
Description
These functions are used to set and retrieve the key and distribution hash functions.
Name
hashkit_set_distribution_function - libhashkit Documentation
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)
1.1 Mar 31, 2024 HASHKIT_SET_DISTRIBUTION_FUNCTION(3)
Synopsis
#include<libhashkit-1.0/hashkit.h>
Compile and link with -lhashkit
typedefuint32_t(*hashkit_hash_fn)(constchar*key,size_tkey_length,void*context)Paramkey
the key to generate a hash of
Paramkey_length
the length of the key without any terminating zero byte
Paramcontext
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
typedefenumhashkit_return_thashkit_return_tenumhashkit_return_tenumeratorHASHKIT_SUCCESS
Operation succeeded.
enumeratorHASHKIT_FAILURE
Operation failed.
enumeratorHASHKIT_MEMORY_ALLOCATION_FAILURE
Memory allocation failed.
enumeratorHASHKIT_INVALID_HASH
Invalid hashkit_hash_algorithm_t passed.
enumeratorHASHKIT_INVALID_ARGUMENT
Invalid argument passed.
typedefenumhashkit_hash_algorithm_thashkit_hash_algorithm_tenumhashkit_hash_algorithm_tenumeratorHASHKIT_HASH_DEFAULT
Default hash algorithm (one_at_a_time).
enumeratorHASHKIT_HASH_MD5enumeratorHASHKIT_HASH_CRCenumeratorHASHKIT_HASH_FNV1_64enumeratorHASHKIT_HASH_FNV1A_64enumeratorHASHKIT_HASH_FNV1_32enumeratorHASHKIT_HASH_FNV1A_32enumeratorHASHKIT_HASH_HSIEH
Only available if libhashkit hash been built with HSIEH support.
enumeratorHASHKIT_HASH_MURMUR
Only available if libhashkit has been built with MURMUR support.
enumeratorHASHKIT_HASH_MURMUR3
Only available if libhashkit has been built with MURMUR support.
enumeratorHASHKIT_HASH_JENKINSenumeratorHASHKIT_HASH_CUSTOM
Use custom hashkit_hash_fn function set through hashkit_set_custom_function() or
hashkit_set_custom_distribution_function().
hashkit_return_thashkit_set_function(hashkit_st*hash,hashkit_hash_algorithm_thash_algorithm)Parameters
• hash -- pointer to an initialized hashkit_st struct
• hash_algorithm -- valid hashkit_hash_algorithm_t constant
Returnshashkit_return_t indicating success or failure
hashkit_return_thashkit_set_custom_function(hashkit_st*hash,hashkit_hash_fnfunction,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
Returnshashkit_return_t indicating success or failure
hashkit_hash_algorithm_thashkit_get_function(consthashkit_st*hash)Parametershash -- pointer to an initialized hashkit_st struct
Returnshashkit_hash_algorithm_t indicating the currently set hash algorithm to use
hashkit_return_thashkit_set_distribution_function(hashkit_st*hash,hashkit_hash_algorithm_thash_algorithm)Parameters
• hash -- pointer to an initialized hashkit_st struct
• hash_algorithm -- valid hashkit_hash_algrothm_t constant
Returnshashkit_return_t indicating success or failure
hashkit_return_thashkit_set_custom_distribution_function(hashkit_st*hash,hashkit_hash_fnfunction,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_thashkit_get_distribution_function(consthashkit_st*hash)Parametershash -- pointer to an initialized hashkit_st struct
Returnshashkit_hash_algorithm_t indicating the currently set distribution hash algorithm to use
