]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/bloom_filter: fix estimated element count for compressed filters
authorSage Weil <sage@inktank.com>
Sun, 6 Oct 2013 17:18:30 +0000 (10:18 -0700)
committerSage Weil <sage@inktank.com>
Sun, 6 Oct 2013 17:18:30 +0000 (10:18 -0700)
We need to compensate for the fact that there are fewer bits than there
used to be.

This is a crappy adjustment; it is non-linear.  It's clone enough for now,
though.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/bloom_filter.hpp

index 4b711526676c1d78f26208392ac9a3da9f6df277..8587caa2d8dbeca320a01d563fd2fb1052f3f47e 100644 (file)
@@ -317,7 +317,7 @@ public:
     return (double)set / (double)(table_size_ << 3);
   }
 
-  inline double approx_unique_element_count() const {
+  virtual inline double approx_unique_element_count() const {
     // this is not a very good estimate; a better solution should have
     // some asymptotic behavior as density() approaches 1.0.
     return (double)target_element_count_ * 2.0 * density();
@@ -637,6 +637,14 @@ public:
     return true;
   }
 
+  virtual inline double approx_unique_element_count() const {
+    // this is not a very good estimate; a better solution should have
+    // some asymptotic behavior as density() approaches 1.0.
+    //
+    // the compress() correction is also bad; it tends to under-estimate.
+    return (double)target_element_count_ * 2.0 * density() * (double)size_list.back() / (double)size_list.front();
+  }
+
 private:
 
   inline virtual void compute_indices(const bloom_type& hash, std::size_t& bit_index, std::size_t& bit) const