1HASHKIT_SET_FUNCTION(3)      libmemcached-awesome      HASHKIT_SET_FUNCTION(3)
2
3
4

NAME

6       hashkit_set_function - libhashkit Documentation
7

SYNOPSIS

9       #include <libhashkit-1.0/hashkit.h>
10              Compile and link with -lhashkit
11
12       typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length,
13       void *context)
14
15              Param key
16                     the key to generate a hash of
17
18              Param key_length
19                     the length of the key without any terminating zero byte
20
21              Param context
22                     the   custom   hash   function   context   set    through
23                     hashkit_set_custom_function()                          or
24                     hashkit_set_custom_distribution_function()
25
26              Returns
27                     the custom hash function should return a hash  value  for
28                     key as an unsigned 32bit integer
29
30       typedef enum hashkit_return_t hashkit_return_t
31
32       enum hashkit_return_t
33
34              enumerator HASHKIT_SUCCESS
35                     Operation succeeded.
36
37              enumerator HASHKIT_FAILURE
38                     Operation failed.
39
40              enumerator HASHKIT_MEMORY_ALLOCATION_FAILURE
41                     Memory allocation failed.
42
43              enumerator HASHKIT_INVALID_HASH
44                     Invalid hashkit_hash_algorithm_t passed.
45
46              enumerator HASHKIT_INVALID_ARGUMENT
47                     Invalid argument passed.
48
49       typedef enum hashkit_hash_algorithm_t hashkit_hash_algorithm_t
50
51       enum hashkit_hash_algorithm_t
52
53              enumerator HASHKIT_HASH_DEFAULT
54                     Default hash algorithm (one_at_a_time).
55
56              enumerator HASHKIT_HASH_MD5
57
58              enumerator HASHKIT_HASH_CRC
59
60              enumerator HASHKIT_HASH_FNV1_64
61
62              enumerator HASHKIT_HASH_FNV1A_64
63
64              enumerator HASHKIT_HASH_FNV1_32
65
66              enumerator HASHKIT_HASH_FNV1A_32
67
68              enumerator HASHKIT_HASH_HSIEH
69                     Only  available  if libhashkit hash been built with HSIEH
70                     support.
71
72              enumerator HASHKIT_HASH_MURMUR
73                     Only available if libhashkit has been built  with  MURMUR
74                     support.
75
76              enumerator HASHKIT_HASH_MURMUR3
77                     Only  available  if libhashkit has been built with MURMUR
78                     support.
79
80              enumerator HASHKIT_HASH_JENKINS
81
82              enumerator HASHKIT_HASH_CUSTOM
83                     Use   custom   hashkit_hash_fn   function   set   through
84                     hashkit_set_custom_function()                          or
85                     hashkit_set_custom_distribution_function().
86
87       hashkit_return_t         hashkit_set_function(hashkit_st         *hash,
88       hashkit_hash_algorithm_t hash_algorithm)
89
90              Parameters
91
92hash -- pointer to an initialized hashkit_st struct
93
94hash_algorithm  --  valid hashkit_hash_algorithm_t con‐
95                       stant
96
97              Returns
98                     hashkit_return_t indicating success or failure
99
100       hashkit_return_t     hashkit_set_custom_function(hashkit_st      *hash,
101       hashkit_hash_fn function, void *context)
102
103              Parameters
104
105hash -- pointer to initialized hashkit_st struct
106
107function  -- hashkit_hash_fn function pointer to use as
108                       hash function for HASHKIT_HASH_CUSTOM
109
110context -- pointer to an opaque  user  managed  context
111                       for the custom hash function
112
113              Returns
114                     hashkit_return_t indicating success or failure
115
116       hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash)
117
118              Parameters
119                     hash -- pointer to an initialized hashkit_st struct
120
121              Returns
122                     hashkit_hash_algorithm_t  indicating  the  currently  set
123                     hash algorithm to use
124
125       hashkit_return_t  hashkit_set_distribution_function(hashkit_st   *hash,
126       hashkit_hash_algorithm_t hash_algorithm)
127
128              Parameters
129
130hash -- pointer to an initialized hashkit_st struct
131
132hash_algorithm  --  valid  hashkit_hash_algrothm_t con‐
133                       stant
134
135              Returns
136                     hashkit_return_t indicating success or failure
137
138       hashkit_return_t    hashkit_set_custom_distribution_function(hashkit_st
139       *hash, hashkit_hash_fn function, void *context)
140
141              Parameters
142
143hash -- pointer to initialized hashkit_st struct
144
145function  -- hashkit_hash_fn function pointer to use as
146                       distribution hash function for HASHKIT_HASH_CUSTOM
147
148context -- pointer to an opaque  user  managed  context
149                       for the custom distribution hash function
150
151       hashkit_hash_algorithm_t        hashkit_get_distribution_function(const
152       hashkit_st *hash)
153
154              Parameters
155                     hash -- pointer to an initialized hashkit_st struct
156
157              Returns
158                     hashkit_hash_algorithm_t  indicating  the  currently  set
159                     distribution hash algorithm to use
160

DESCRIPTION

162       These  functions  are used to set and retrieve the key and distribution
163       hash functions.
164

RETURN VALUE

166       hashkit_set_function(), hashkit_set_custom_function() and the distribu‐
167       tion equivalents return hashkit_return_t::HASHKIT_SUCCESS on success.
168
169       hashkit_get_function()  and  hashkit_get_distribution_function() return
170       hashkit_hash_algorithm_t indicating the hash function used.
171

SEE ALSO

173       libhashkit(3) hashkit_create(3) hashkit_functions(3)
174
175
176
177
1781.1                              Feb 02, 2022          HASHKIT_SET_FUNCTION(3)
Impressum