mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Adding a unit test
This commit is contained in:
parent
0a14b39aed
commit
80d21e2ccd
@ -251,7 +251,10 @@ struct BloomFilterHash
|
||||
static const size_t MIN_BITS_PER_ROW = 2;
|
||||
static const size_t MIN_HASH_FUNCTION_COUNT = 2;
|
||||
|
||||
/// Return the smaller possible parameters for false positive rates bigger than 0.283
|
||||
/// Return the smaller possible parameters for false positive rates higher or equal than 0.283
|
||||
/// Otherwise, for those rates the loop won't find any possible values in the lookup table
|
||||
/// returning bits_per_row = 19 & size_of_hash_functions = 13. Which are the most restrictive values
|
||||
/// to be used with the smallest false positive rates.
|
||||
if (max_conflict_probability >= 0.283)
|
||||
return std::pair<size_t, size_t>(MIN_BITS_PER_ROW, MIN_HASH_FUNCTION_COUNT);
|
||||
|
||||
|
57
src/Interpreters/tests/gtest_calculationBestPractices.cpp
Normal file
57
src/Interpreters/tests/gtest_calculationBestPractices.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <Interpreters/BloomFilterHash.h>
|
||||
|
||||
using namespace DB;
|
||||
|
||||
|
||||
TEST(BloomFilterHash, ReasonableProbabilities)
|
||||
{
|
||||
const auto & output_1 = BloomFilterHash::calculationBestPractices(0.001);
|
||||
|
||||
ASSERT_EQ(output_1.first, 15);
|
||||
ASSERT_EQ(output_1.second, 7);
|
||||
|
||||
const auto & output_2 = BloomFilterHash::calculationBestPractices(0.025);
|
||||
|
||||
ASSERT_EQ(output_2.first, 8);
|
||||
ASSERT_EQ(output_2.second, 4);
|
||||
|
||||
const auto & output_3 = BloomFilterHash::calculationBestPractices(0.05);
|
||||
|
||||
ASSERT_EQ(output_3.first, 7);
|
||||
ASSERT_EQ(output_3.second, 3);
|
||||
|
||||
const auto & output_4 = BloomFilterHash::calculationBestPractices(0.1);
|
||||
|
||||
ASSERT_EQ(output_4.first, 6);
|
||||
ASSERT_EQ(output_4.second, 2);
|
||||
|
||||
const auto & output_5 = BloomFilterHash::calculationBestPractices(0.2);
|
||||
|
||||
ASSERT_EQ(output_5.first, 4);
|
||||
ASSERT_EQ(output_5.second, 2);
|
||||
|
||||
const auto & output_6 = BloomFilterHash::calculationBestPractices(0.282);
|
||||
|
||||
ASSERT_EQ(output_6.first, 3);
|
||||
ASSERT_EQ(output_6.second, 2);
|
||||
}
|
||||
|
||||
TEST(BloomFilterHash, HighProbabilities)
|
||||
{
|
||||
const auto & output_1 = BloomFilterHash::calculationBestPractices(0.283);
|
||||
|
||||
ASSERT_EQ(output_1.first, 2);
|
||||
ASSERT_EQ(output_1.second, 2);
|
||||
|
||||
const auto & output_2 = BloomFilterHash::calculationBestPractices(0.5);
|
||||
|
||||
ASSERT_EQ(output_2.first, 2);
|
||||
ASSERT_EQ(output_2.second, 2);
|
||||
|
||||
const auto & output_3 = BloomFilterHash::calculationBestPractices(0.8);
|
||||
|
||||
ASSERT_EQ(output_3.first, 2);
|
||||
ASSERT_EQ(output_3.second, 2);
|
||||
}
|
Loading…
Reference in New Issue
Block a user