我正在运行在杜鹃过滤器库中提供的示例的修改版本:https://github.com/efficient/cuckoofilter/blob/master/example/test.cc如何添加字符串到杜鹃过滤器?
我想向杜鹃过滤器添加字符串。虽然字符串被添加,但是当我检查它是否存在于过滤器中时,它总是返回false。任何人都可以指出我的方法有什么问题吗?
size_t total_items = 1000000;
CuckooFilter<string, 12> filter(total_items);
// Insert items to this cuckoo filter
string temp1 = "sample";
if (filter.Add(temp1) != cuckoofilter::Ok) {
cout<<"not added"<<endl;
}
// Check if previously inserted items are in the filter
string temp2 = "sample";
assert(filter.Contain(temp2) == cuckoofilter::Ok);
断言应该是真的,但在这种情况下它是错误的。为什么?
感谢您的回答。我修改源使用SuperFastHash而不是SHA1/MD5,它的工作。 –