1#ifndef ASSOC_H
2#define ASSOC_H
3
4struct assoc {
5   /* how many powers of 2's worth of buckets we use */
6   unsigned int hashpower;
7
8
9   /* Main hash table. This is where we look except during expansion. */
10   hash_item** primary_hashtable;
11
12   /*
13    * Previous hash table. During expansion, we look here for keys that haven't
14    * been moved over to the primary yet.
15    */
16   hash_item** old_hashtable;
17
18   /* Number of items in the hash table. */
19   unsigned int hash_items;
20
21   /* Flag: Are we in the middle of expanding now? */
22   bool expanding;
23
24   /*
25    * During expansion we migrate values with bucket granularity; this is how
26    * far we've gotten so far. Ranges from 0 .. hashsize(hashpower - 1) - 1.
27    */
28   unsigned int expand_bucket;
29};
30
31/* associative array */
32ENGINE_ERROR_CODE assoc_init(struct default_engine *engine);
33void assoc_destroy(struct default_engine *engine);
34hash_item *assoc_find(struct default_engine *engine, uint32_t hash,
35                      const char *key, const size_t nkey);
36int assoc_insert(struct default_engine *engine, uint32_t hash,
37                 hash_item *item);
38void assoc_delete(struct default_engine *engine, uint32_t hash,
39                  const char *key, const size_t nkey);
40int start_assoc_maintenance_thread(struct default_engine *engine);
41void stop_assoc_maintenance_thread(struct default_engine *engine);
42
43#endif
44