diff --git a/utils/bloom_calculations.cc b/utils/bloom_calculations.cc index 951a03b041..ffe5cf8e47 100644 --- a/utils/bloom_calculations.cc +++ b/utils/bloom_calculations.cc @@ -21,7 +21,7 @@ namespace bloom_calculations { * Each cell (i,j) the false positive rate determined by using i buckets per * element and j hash functions. */ -std::vector> probs = { +const std::vector> probs = { {1.0}, // dummy row representing 0 buckets per element {1.0, 1.0}, // dummy row representing 1 buckets per element {1.0, 0.393, 0.400}, @@ -50,7 +50,7 @@ std::vector> probs = { * The optimal number of hashes for a given number of bits per element. * These values are automatically calculated from the data above. */ -std::vector initialize_opt_k() { +static std::vector initialize_opt_k() { std::vector arr; arr.resize(probs.size()); @@ -68,6 +68,6 @@ std::vector initialize_opt_k() { return arr; } -std::vector opt_k_per_buckets = initialize_opt_k(); +const std::vector opt_k_per_buckets = initialize_opt_k(); } } diff --git a/utils/bloom_calculations.hh b/utils/bloom_calculations.hh index 425ead7aa2..d82de4582b 100644 --- a/utils/bloom_calculations.hh +++ b/utils/bloom_calculations.hh @@ -45,8 +45,8 @@ namespace bloom_calculations { int constexpr min_k = 1; int constexpr EXCESS = 20; - extern std::vector> probs; - extern std::vector opt_k_per_buckets; + extern const std::vector> probs; + extern const std::vector opt_k_per_buckets; /** * Given the number of buckets that can be used per element, return a @@ -130,9 +130,7 @@ namespace bloom_calculations { * lower than this, it will throw an unsupported_operation_exception. */ inline double min_supported_bloom_filter_fp_chance() { - int max_buckets = probs.size() - 1; - int max_K = probs[max_buckets].size() - 1; - return probs[max_buckets][max_K]; + return probs.back().back(); } }