|
@@ -0,0 +1,48 @@
|
|
|
+#define NANXING_DEBUG_
|
|
|
+#include"../extend/filter.h"
|
|
|
+#include<cstdlib>
|
|
|
+#include<cmath>
|
|
|
+#include<cstdint>
|
|
|
+uint64_t insert_n[10]={4000,1024,57001,7421,3731,24671,19937,134561,1944416,16419};
|
|
|
+double insert_p[10]={0.1,0.1,0.4,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
|
|
|
+uint64_t result_k[10]={3,3,1,3,3,3,3,3,3,3};
|
|
|
+uint64_t result_m[10]={19171,4908,108709,35566,17881,118237,94549,644888,9318671,78689};
|
|
|
+
|
|
|
+//由于这些都是一次性的,直接写成lambda表达式
|
|
|
+nanxing_extend::FilterPolicy<int> test_filter{};
|
|
|
+auto creat_bloomfilter=[](int i)->nanxing_extend::FilterPolicy<int>*{
|
|
|
+
|
|
|
+ return test_filter.creat_Bloomfilter(insert_n[i],insert_p[i]);
|
|
|
+
|
|
|
+};
|
|
|
+auto bloomfilter_creater_test=[]()
|
|
|
+{
|
|
|
+ for(int i=0;i<10;i++)
|
|
|
+ {
|
|
|
+ nanxing_extend::FilterPolicy<int>* bloomfilter=creat_bloomfilter(i);
|
|
|
+ bloomfilter->init_filter();
|
|
|
+ if((bloomfilter->get_k())!=result_k[i]||(bloomfilter->get_m())!=result_m[i])
|
|
|
+ {
|
|
|
+ if(std::abs(static_cast<long long>(bloomfilter->get_m()-result_m[i]))<15&&bloomfilter->get_k()==result_k[i]) //这里为了测试用了g++特定的数据类型
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ std::cerr<<"error"<<std::endl;
|
|
|
+ std::cout<<"i="<<i<<std::endl;
|
|
|
+ std::cout<<"n="<<insert_n[i]<<std::endl;
|
|
|
+ std::cout<<"p="<<insert_p[i]<<std::endl;
|
|
|
+ std::cout<<"k="<<result_k[i]<<std::endl;
|
|
|
+ std::cout<<"parameter.k="<<bloomfilter->get_k()<<std::endl;
|
|
|
+ std::cout<<"m="<<result_m[i]<<std::endl;
|
|
|
+ std::cout<<"parameterm="<<bloomfilter->get_m()<<std::endl;
|
|
|
+ goto LOOP;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ std::cout<<"bloomfilter_creater_test successful"<<std::endl;
|
|
|
+LOOP:
|
|
|
+};
|
|
|
+
|
|
|
+int main()
|
|
|
+{
|
|
|
+ bloomfilter_creater_test();
|
|
|
+}
|