1HASHKIT_FUNCTION(3) libmemcached-awesome HASHKIT_FUNCTION(3)
2
3
4
6 hashkit_function - libhashkit Documentation
7
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 Parameters
16
17 • key -- the key to generate a hash of
18
19 • key_length -- the length of the key without any termi‐
20 nating zero byte
21
22 • context -- 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
92 • hash -- pointer to an initialized hashkit_st struct
93
94 • hash_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
105 • hash -- pointer to initialized hashkit_st struct
106
107 • function -- hashkit_hash_fn function pointer to use as
108 hash function for HASHKIT_HASH_CUSTOM
109
110 • context -- 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
130 • hash -- pointer to an initialized hashkit_st struct
131
132 • hash_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
143 • hash -- pointer to initialized hashkit_st struct
144
145 • function -- hashkit_hash_fn function pointer to use as
146 distribution hash function for HASHKIT_HASH_CUSTOM
147
148 • context -- 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
162 These functions are used to set and retrieve the key and distribution
163 hash functions.
164
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
173 libhashkit(3) hashkit_create(3) hashkit_functions(3)
174
175
176
177
1781.1 Sep 20, 2021 HASHKIT_FUNCTION(3)