44#ifndef __FAST_HASH_FILTER_H__
45#define __FAST_HASH_FILTER_H__
59#define UINT64_MAX -1ULL
65#define FHF_TABLE_COLS 8
70#define FHF_COL_FULL ((uint8_t) 0xFF)
242 while (__sync_lock_test_and_set(&table->
lock_table[table_row], 1))
248 __sync_lock_release(&table->
lock_table[table_row]);
254 __sync_lock_release(&table->
lock_table[table_row]);
260 __sync_lock_release(&table->
lock_table[table_row]);
266 __sync_lock_release(&table->
lock_table[table_row]);
272 __sync_lock_release(&table->
lock_table[table_row]);
278 __sync_lock_release(&table->
lock_table[table_row]);
284 __sync_lock_release(&table->
lock_table[table_row]);
290 __sync_lock_release(&table->
lock_table[table_row]);
303 __sync_lock_release(&table->
lock_table[table_row]);
308 __sync_lock_release(&table->
lock_table[table_row]);
339static inline int fhf_insert_own_or_update(
fhf_table_t *table,
const void *key, int8_t **lock,
void ** data_ptr)
345 while (__sync_lock_test_and_set(&table->
lock_table[table_row], 1))
411 __sync_lock_release(&table->
lock_table[table_row]);
431static inline int fhf_update_data(
fhf_table_t *table,
const void *key, int8_t **lock,
void **data_ptr)
437 while (__sync_lock_test_and_set(&table->
lock_table[table_row], 1))
482 __sync_lock_release(&table->
lock_table[table_row]);
500static inline int fhf_get_data(
fhf_table_t *table,
const void *key,
const void **data_ptr)
557static inline int fhf_get_data_locked(
fhf_table_t *table,
const void *key, int8_t **lock,
const void **data_ptr)
563 while (__sync_lock_test_and_set(&table->
lock_table[table_row], 1))
608 __sync_lock_release(&table->
lock_table[table_row]);
617static inline void fhf_unlock_data(int8_t *lock)
619 __sync_lock_release(lock);
642 while (__sync_lock_test_and_set(&table->
lock_table[table_row], 1))
649 __sync_lock_release(&table->
lock_table[table_row]);
654 __sync_lock_release(&table->
lock_table[table_row]);
675static inline int fhf_remove_locked(
fhf_table_t *table,
const void *key, int8_t *lock_ptr)
681 if (lock_ptr == &table->
lock_table[table_row]) {
686 __sync_lock_release(&table->
lock_table[table_row]);
702static inline int fhf_remove_iter(
fhf_iter_t *iter)
729static inline int fhf_get_next_iter(
fhf_iter_t *iter)
792 uint64_t new_table_rows;
805 while (new_table_rows <=
UINT64_MAX/2 + 1 && new_table_rows != 0) {
809 if (new_table == NULL)
813 if (iterator_old_table == NULL) {
@ FHF_RESIZE_FAILED_INSERT
@ FHF_RESIZE_FAILED_ALLOC
void fhf_destroy_iter(fhf_iter_t *iter)
Function for destroying iterator and freeing memory.
uint8_t fhf_lt_pow_of_two[]
void fhf_reinit_iter(fhf_iter_t *iter)
Function for reinitializing iterator for table.
void fhf_clear(fhf_table_t *table)
Function for clearing table.
void fhf_destroy(fhf_table_t *table)
Function for destroying table and freeing memory.
fhf_table_t * fhf_init(uint64_t table_rows, uint32_t key_size, uint32_t data_size)
Function for initializing table.
fhf_iter_t * fhf_init_iter(fhf_table_t *table)
Function for initializing iterator for the table.
uint8_t fhf_lt_free_flag[]
uint64_t(* hash_function)(const void *, uint32_t, uint64_t)
uint8_t * free_flag_field