From 1ac743fa666a80879a5cf30e1859941814859afc Mon Sep 17 00:00:00 2001 From: Jon Malkin <786705+jmalkin@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:35:56 -0700 Subject: [PATCH] managed to conflict with myself when jumping between boxes. resolved now. --- filters/include/bloom_filter.hpp | 57 +++++++++++++-------------- filters/include/bloom_filter_impl.hpp | 2 +- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/filters/include/bloom_filter.hpp b/filters/include/bloom_filter.hpp index 78396277..a38d0413 100644 --- a/filters/include/bloom_filter.hpp +++ b/filters/include/bloom_filter.hpp @@ -47,8 +47,6 @@ using bloom_filter_builder = bloom_filter_builder_alloc> */ template> class bloom_filter_builder_alloc { - using A = Allocator; - public: /** * Returns the optimal number of hash functions to given target numbers of distinct items @@ -58,14 +56,14 @@ class bloom_filter_builder_alloc { * @param num_filter_bits The intended size of the Bloom Filter in bits * @return The suggested number of hash functions to use with the filter */ - static uint16_t suggest_num_hashes(const uint64_t max_distinct_items, const uint64_t num_filter_bits); + static uint16_t suggest_num_hashes(uint64_t max_distinct_items, uint64_t num_filter_bits); /** * Returns the optimal number of hash functions to achieve a target false positive probability. * @param target_false_positive_prob A desired false positive probability per item * @return The suggested number of hash functions to use with the filter. */ - static uint16_t suggest_num_hashes(const double target_false_positive_prob); + static uint16_t suggest_num_hashes(double target_false_positive_prob); /** * Returns the optimal number of bits to use in a Bloom filter given a target number of distinct @@ -74,7 +72,7 @@ class bloom_filter_builder_alloc { * @param target_false_positive_prob A desired false positive probability per item * @return The suggested number of bits to use with the filter */ - static uint64_t suggest_num_filter_bits(const uint64_t max_distinct_items, const double target_false_positive_prob); + static uint64_t suggest_num_filter_bits(uint64_t max_distinct_items, double target_false_positive_prob); /** * Creates a new Bloom filter with an optimal number of bits and hash functions for the given inputs, @@ -85,10 +83,10 @@ class bloom_filter_builder_alloc { * @param allocator The allocator to use for the filter (default: standard allocator) * @return A new Bloom filter configured for the given input parameters */ - static bloom_filter_alloc create_by_accuracy(const uint64_t max_distinct_items, - const double target_false_positive_prob, - const uint64_t seed = generate_random_seed(), - const Allocator& allocator = Allocator()); + static bloom_filter_alloc create_by_accuracy(uint64_t max_distinct_items, + double target_false_positive_prob, + uint64_t seed = generate_random_seed(), + const Allocator& allocator = Allocator()); /** * Creates a Bloom filter with given number of bits and number of hash functions, @@ -100,10 +98,10 @@ class bloom_filter_builder_alloc { * @param allocator The allocator to use for the filter (default: standard allocator) * @return A new Bloom filter configured for the given input parameters */ - static bloom_filter_alloc create_by_size(const uint64_t num_bits, - const uint16_t num_hashes, - const uint64_t seed = generate_random_seed(), - const Allocator& allocator = Allocator()); + static bloom_filter_alloc create_by_size(uint64_t num_bits, + uint16_t num_hashes, + uint64_t seed = generate_random_seed(), + const Allocator& allocator = Allocator()); /** * Creates a new Bloom filter with an optimal number of bits and hash functions for the given inputs, @@ -118,12 +116,12 @@ class bloom_filter_builder_alloc { * @param allocator The allocator to use for the filter (default: standard allocator) * @return A new Bloom filter configured for the given input parameters in the provided memory */ - static bloom_filter_alloc initialize_by_accuracy(void* memory, - const size_t length_bytes, - const uint64_t max_distinct_items, - const double target_false_positive_prob, - const uint64_t seed = generate_random_seed(), - const Allocator& allocator = Allocator()); + static bloom_filter_alloc initialize_by_accuracy(void* memory, + size_t length_bytes, + uint64_t max_distinct_items, + double target_false_positive_prob, + uint64_t seed = generate_random_seed(), + const Allocator& allocator = Allocator()); /** * Initializes a Bloom filter with given number of bits and number of hash functions, @@ -138,12 +136,12 @@ class bloom_filter_builder_alloc { * @param allocator The allocator to use for the filter (default: standard allocator) * @return A new BloomFilter configured for the given input parameters */ - static bloom_filter_alloc initialize_by_size(void* memory, - const size_t length_bytes, - const uint64_t num_bits, - const uint16_t num_hashes, - const uint64_t seed = generate_random_seed(), - const Allocator& allocator = Allocator()); + static bloom_filter_alloc initialize_by_size(void* memory, + size_t length_bytes, + uint64_t num_bits, + uint16_t num_hashes, + uint64_t seed = generate_random_seed(), + const Allocator& allocator = Allocator()); /** * @brief Generates a random 64-bit seed value @@ -184,8 +182,6 @@ class bloom_filter_builder_alloc { template> class bloom_filter_alloc { - using A = Allocator; - public: /** @@ -259,7 +255,7 @@ class bloom_filter_alloc { // This is a convenience alias for users // The type returned by the following serialize method - using vector_bytes = std::vector::template rebind_alloc>; + using vector_bytes = std::vector::template rebind_alloc>; /** * This method serializes the filter as a vector of bytes. @@ -688,9 +684,10 @@ class bloom_filter_alloc { * @param print_filter If true, the filter bits will be printed as well. * @return A human-readable string representation of the Bloom Filter. */ - string to_string(bool print_filter = false) const; + string to_string(bool print_filter = false) const; private: + using A = Allocator; using AllocUint8 = typename std::allocator_traits::template rebind_alloc; static const uint64_t DIRTY_BITS_VALUE = static_cast(-1LL); @@ -735,7 +732,7 @@ class bloom_filter_alloc { void update_num_bits_set(uint64_t num_bits_set); - A allocator_; + Allocator allocator_; uint64_t seed_; uint16_t num_hashes_; bool is_dirty_; diff --git a/filters/include/bloom_filter_impl.hpp b/filters/include/bloom_filter_impl.hpp index f82ea341..dc022ba4 100644 --- a/filters/include/bloom_filter_impl.hpp +++ b/filters/include/bloom_filter_impl.hpp @@ -539,7 +539,7 @@ void bloom_filter_alloc::update_num_bits_set(uint64_t num_bits_set) { // UPDATE METHODS template -void bloom_filter_alloc::update(std::string& item) { +void bloom_filter_alloc::update(const std::string& item) { if (item.empty()) return; const uint64_t h0 = XXHash64::hash(item.data(), item.size(), seed_); const uint64_t h1 = XXHash64::hash(item.data(), item.size(), h0);