From 8cfeb8342a08774fb1030830859c3fc30514f0b5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 3 Oct 2013 09:20:34 -0700 Subject: [PATCH] common/bloom_filter: note that uint32_t interface requires well-mixed values Signed-off-by: Sage Weil --- src/common/bloom_filter.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/common/bloom_filter.hpp b/src/common/bloom_filter.hpp index 6d5f645d8c904..6216c7fb34d42 100644 --- a/src/common/bloom_filter.hpp +++ b/src/common/bloom_filter.hpp @@ -131,6 +131,15 @@ public: inserted_element_count_ = 0; } + /** + * insert a u32 into the set + * + * NOTE: the internal hash is weak enough that consecutive inputs do + * not achieve the desired fpp. Well-mixed values should be used + * here (e.g., put rjhash(x) into the filter instead of just x). + * + * @param val integer value to insert + */ inline void insert(uint32_t val) { std::size_t bit_index = 0; std::size_t bit = 0; @@ -181,6 +190,16 @@ public: } } + /** + * check if a u32 is contained by set + * + * NOTE: the internal hash is weak enough that consecutive inputs do + * not achieve the desired fpp. Well-mixed values should be used + * here (e.g., put rjhash(x) into the filter instead of just x). + * + * @param val integer value to query + * @returns true if value is (probably) in the set, false if it definitely is not + */ inline virtual bool contains(uint32_t val) const { std::size_t bit_index = 0; -- 2.39.5