/* * __wt_bloom_open -- * Open a Bloom filter object for use by a single session. The filter must * have been created and finalized. */ int __wt_bloom_open(WT_SESSION_IMPL *session, const char *uri, uint32_t factor, uint32_t k, WT_CURSOR *owner, WT_BLOOM **bloomp) { WT_BLOOM *bloom; WT_CURSOR *c; WT_DECL_RET; uint64_t size; WT_RET(__bloom_init(session, uri, NULL, &bloom)); WT_ERR(__bloom_open_cursor(bloom, owner)); c = bloom->c; /* Find the largest key, to get the size of the filter. */ WT_ERR(c->prev(c)); WT_ERR(c->get_key(c, &size)); WT_ERR(c->reset(c)); WT_ERR(__bloom_setup(bloom, 0, size, factor, k)); *bloomp = bloom; return (0); err: (void)__wt_bloom_close(bloom); return (ret); }
/* * __wt_bloom_create -- * * Creates and configures a WT_BLOOM handle, allocates a bitstring in memory to * use while populating the bloom filter. * * count - is the expected number of inserted items * factor - is the number of bits to use per inserted item * k - is the number of hash values to set or test per item */ int __wt_bloom_create( WT_SESSION_IMPL *session, const char *uri, const char *config, uint64_t count, uint32_t factor, uint32_t k, WT_BLOOM **bloomp) { WT_BLOOM *bloom; WT_RET(__bloom_init(session, uri, config, &bloom)); WT_RET(__bloom_setup(bloom, count, 0, factor, k)); WT_RET(__bit_alloc(session, bloom->m, &bloom->bitstring)); *bloomp = bloom; return (0); }
* * count - is the expected number of inserted items * factor - is the number of bits to use per inserted item * k - is the number of hash values to set or test per item */ int __wt_bloom_create( WT_SESSION_IMPL *session, const char *uri, const char *config, uint64_t count, uint32_t factor, uint32_t k, WT_BLOOM **bloomp) WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { WT_BLOOM *bloom; WT_DECL_RET; WT_RET(__bloom_init(session, uri, config, &bloom)); WT_ERR(__bloom_setup(bloom, count, 0, factor, k)); WT_ERR(__bit_alloc(session, bloom->m, &bloom->bitstring)); *bloomp = bloom; return (0); err: WT_TRET(__wt_bloom_close(bloom)); return (ret); } /* * __bloom_open_cursor -- * Open a cursor to read from a Bloom filter. */ static int