| 1 |
#ifndef ASSOC_H |
| 2 |
#define ASSOC_H |
| 3 |
|
| 4 |
struct 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 */ |
| 32 |
ENGINE_ERROR_CODE assoc_init(struct default_engine *engine); |
| 33 |
hash_item *assoc_find(struct default_engine *engine, uint32_t hash, |
| 34 |
const char *key, const size_t nkey); |
| 35 |
int assoc_insert(struct default_engine *engine, uint32_t hash, |
| 36 |
hash_item *item); |
| 37 |
void assoc_delete(struct default_engine *engine, uint32_t hash, |
| 38 |
const char *key, const size_t nkey); |
| 39 |
int start_assoc_maintenance_thread(struct default_engine *engine); |
| 40 |
void stop_assoc_maintenance_thread(struct default_engine *engine); |
| 41 |
|
| 42 |
#endif |