static inline void _ol_rehash_insert_bucket( ol_bucket **tmp_hashes, const size_t to_alloc, ol_bucket *bucket) { int new_index; new_index = _ol_calc_idx(to_alloc, bucket->hash); if (tmp_hashes[new_index] != NULL) { /* Enforce that this is the last bucket, KILL THE ORPHANS */ ol_bucket *last_bucket = _ol_get_last_bucket_in_slot( tmp_hashes[new_index]); last_bucket->next = bucket; } else { tmp_hashes[new_index] = bucket; } }
static inline void _ol_rehash_insert_bucket( ol_bucket **tmp_hashes, const size_t to_alloc, ol_bucket *bucket) { int new_index; uint32_t hash; MurmurHash3_x86_32(bucket->key, bucket->klen, DEVILS_SEED, &hash); new_index = _ol_calc_idx(to_alloc, hash); if (tmp_hashes[new_index] != NULL) { /* Enforce that this is the last bucket, KILL THE ORPHANS */ ol_bucket *last_bucket = _ol_get_last_bucket_in_slot( tmp_hashes[new_index]); last_bucket->next = bucket; } else tmp_hashes[new_index] = bucket; }
int _ol_set_bucket_no_incr(ol_database *db, ol_bucket *bucket, uint32_t hash) { /* TODO: error codes? */ unsigned int index = _ol_calc_idx(db->cur_ht_size, hash); if (db->hashes[index] != NULL) { db->meta->key_collisions++; ol_bucket *tmp_bucket = db->hashes[index]; tmp_bucket = _ol_get_last_bucket_in_slot(tmp_bucket); tmp_bucket->next = bucket; } else { db->hashes[index] = bucket; } if (db->is_enabled(OL_F_SPLAYTREE, &db->feature_set)) { /* Put the bucket into the tree */ ol_splay_tree_node *node = NULL; node = ols_insert(db->tree, bucket->key, bucket->klen, bucket); /* Make sure the bucket can reference the node. */ bucket->node = node; } return 0; }