/* * __wt_bloom_hash -- * Calculate the hash values for a given key. */ int __wt_bloom_hash(WT_BLOOM *bloom, WT_ITEM *key, WT_BLOOM_HASH *bhash) { WT_UNUSED(bloom); bhash->h1 = __wt_hash_fnv64(key->data, key->size); bhash->h2 = __wt_hash_city64(key->data, key->size); return (0); }
/* * __wt_bloom_insert -- * Adds the given key to the Bloom filter. */ int __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key) { uint64_t h1, h2; uint32_t i; h1 = __wt_hash_fnv64(key->data, key->size); h2 = __wt_hash_city64(key->data, key->size); for (i = 0; i < bloom->k; i++, h1 += h2) { __bit_set(bloom->bitstring, h1 % bloom->m); } return (0); }
/* * __wt_bloom_inmem_get -- * Tests whether the given key is in the Bloom filter. * This can be used in place of __wt_bloom_get * for Bloom filters that are memory only. */ int __wt_bloom_inmem_get(WT_BLOOM *bloom, WT_ITEM *key) { uint64_t h1, h2; uint32_t i; h1 = __wt_hash_fnv64(key->data, key->size); h2 = __wt_hash_city64(key->data, key->size); for (i = 0; i < bloom->k; i++, h1 += h2) { if (!__bit_test(bloom->bitstring, h1 % bloom->m)) return (WT_NOTFOUND); } return (0); }