2 * Copyright (C) 2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
11 * @brief HashKit Header
17 #if !defined(__cplusplus)
21 #include <sys/types.h>
22 #include <libhashkit/visibility.h>
23 #include <libhashkit/types.h>
24 #include <libhashkit/algorithm.h>
25 #include <libhashkit/behavior.h>
26 #include <libhashkit/strerror.h>
33 * @addtogroup hashkit_constants Constants
39 #define HASHKIT_MAX_KEY 251
40 #define HASHKIT_POINTS_PER_NODE 100
41 #define HASHKIT_POINTS_PER_NODE_WEIGHTED 160
42 #define HASHKIT_CONTINUUM_ADDITION 10
43 #define HASHKIT_CONTINUUM_KEY_SIZE 86
52 hashkit_options_st options
;
53 hashkit_distribution_t distribution
;
54 uint32_t continuum_count
;
55 uint32_t continuum_points_count
;
60 @note There are two places we use hashing, one is for when we have a key
61 and we want to find out what server it should be placed on. The second is
62 for when we are placing a value into the continuum.
64 hashkit_hash_algorithm_t for_key
;
65 hashkit_hash_algorithm_t for_distribution
;
67 hashkit_continuum_point_st
*continuum
;
69 hashkit_active_fn
*active_fn
;
70 hashkit_fn
*continuum_hash_fn
;
71 hashkit_key_fn
*continuum_key_fn
;
72 hashkit_sort_fn
*sort_fn
;
73 hashkit_weight_fn
*weight_fn
;
80 struct hashkit_continuum_point_st
87 * @addtogroup hashkit Pandora Hash Declarations
92 hashkit_st
*hashkit_create(hashkit_st
*hash
);
95 hashkit_st
*hashkit_clone(hashkit_st
*destination
, const hashkit_st
*ptr
);
98 void hashkit_free(hashkit_st
*hash
);
101 uint32_t hashkit_generate_value(const char *key
, size_t key_length
, hashkit_hash_algorithm_t hash_algorithm
);
103 #define hashkit_is_allocated(__object) ((__object)->options.is_allocated)
104 #define hashkit_is_initialized(__object) ((__object)->options.is_initialized)
112 #endif /* HASHKIT_H */