本文整理汇总了C++中BloomFilter类的典型用法代码示例。如果您正苦于以下问题:C++ BloomFilter类的具体用法?C++ BloomFilter怎么用?C++ BloomFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BloomFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
BloomFilter *s = new BloomFilter(4);
char c;
//cout<<"BLABLA";
Key k;
do {
cout<<"a - add\nf - find\nd - del\nq - quit\n";
cin>>c;
if (!(c!='a' || c!='f' || c!='d' || c!='q'))
continue;
cout<<"Value:\n";
cin>>k;
if(c=='a') {
s->add(k);
} else if(c == 'f') {
if((s->testExist(k, false)))
cout<<"Found!\n";
else
cout<<"Nod found!\n";
} else if(c == 'd') {
s->del(k);
} else {
break;
}
}while(c!='q');
cout<<"That's all, folks!\n";
return 0;
}
示例2: main
int main(int argc, char *argv[]) {
// Test TTTDs
std::filebuf fb;
if (fb.open(argv[1], std::ios::in))
{
std::istream input(&fb);
// The following TTTDs parameters are from TTTDs paper, in practice we should set the chunk size larger
TTTDsChunker chunker(460, 2800, 540, 270, 1, 1600);
vector<Chunk *> *chunks = chunker.createChunks(input);
// Test FBC
FBCChunker fChunker(2000, 500, 32);
for (vector<Chunk *>::iterator c = chunks->begin(); c != chunks->end(); c++) {
fChunker.splitBigChunk(**c);
}
fChunker.printFreqTable();
fb.close();
} else {
cout << "Can not open input stream" << endl;
exit(EXIT_FAILURE);
}
// Test bloom filter
BloomFilter bf;
cout << "Before insert: " << bf.lookup("hello", 6) << endl;
bf.insert("hello", 6);
cout << "After insert: " << bf.lookup("hello", 6) << endl;
return 0;
}
示例3: main
int main(int argc, char* argv[])
{
size_t size = BloomFilter<std::string>::GetBufferSize(INSERT_NUM, 0.001);
size_t k = BloomFilter<std::string>::GetK(INSERT_NUM, 0.001);
BloomFilter<std::string> bf = BloomFilter<std::string>::CreateBloomFilter(size, k);
double success = 0;
for(uint32_t i=0; i<INSERT_NUM; ++i)
{
std::string strUrl = (boost::format("http://voanews.com/article/%u") % i).str();
if(bf.Contains(strUrl))
break;
++success;
//printf("crawl url[%s]...\n", strUrl.c_str());
bf.Add(strUrl);
}
printf("success count: %u[size:%lu, k:%lu]\n", (uint32_t)success, size, k);
// dump bloomfilter bitmap buffer
// bf.Dump();
bf.Delete();
return 0;
}
示例4: loadSeqr
void loadSeqr(BloomFilter & myFilter, const string & seq) {
if (seq.size() < opt::kmerLen) return;
uint64_t fhVal, rhVal;
myFilter.insert(seq.c_str(), fhVal, rhVal);
for (size_t i = 1; i < seq.size() - opt::kmerLen + 1; i++) {
myFilter.insert(fhVal, rhVal, seq[i-1], seq[i+opt::kmerLen-1]);
}
}
示例5: main
int main(int argc, char *argv[]) {
ifstream fpStrPool(argv[1]);
ifstream fpCheckedStr(argv[2]);
ofstream fpResult(argv[3]);
clock_t begin = clock();
BloomFilter b;
b.bfCheck(fpStrPool, fpCheckedStr, fpResult);
clock_t end = clock();
fpResult << (double)(end - begin) / CLOCKS_PER_SEC;
fpResult << "s" << endl;
fpResult << "------------------bfend---------------------- ";
return 0;
}
示例6: main
int main()
{
BloomFilter bf;
bf.add("hoge");
bf.add("fuga");
cout << (bf.exist("hoge") ? "true" : "false") << endl;
cout << (bf.exist("fuga") ? "true" : "false") << endl;
cout << (bf.exist("kuso") ? "true" : "false") << endl;
return 0;
}
示例7: main
int main(){
BloomFilter *bf = new BloomFilter(1024);
string st1 = "this";
string st2 = "is";
string st3 = "a";
string st4 = "test";
bf->add(st1.c_str(),st1.length());
bf->add(st2.c_str(),st2.length());
cout<<"bloom filter contains \""<<st1 <<"\"" <<":"<< bf->contains(st1.c_str(), st1.length()) << endl;
cout<<"bloom filter contains \""<<st2 <<"\"" <<":"<< bf->contains(st2.c_str(), st2.length()) << endl;
cout<<"bloom filter contains \""<<st3 <<"\"" <<":"<< bf->contains(st3.c_str(), st3.length()) << endl;
cout<<"bloom filter contains \""<<st4 <<"\"" <<":"<< bf->contains(st4.c_str(), st4.length()) << endl;
}
示例8: loadSeqx
void loadSeqx(BloomFilter & myFilter, const string & seq) {
if (seq.size() < opt::kmerLen) return;
for (size_t i = 0; i < seq.size() - opt::kmerLen + 1; i++) {
string kmer = seq.substr(i, opt::kmerLen);
getCanon(kmer);
myFilter.insertXxh(kmer.c_str());
}
}
示例9: log_trace
bool FilterHandler::operator()(Peer* origin, Message& msg) {
log_trace("args: origin: %s, msg: %s", origin->endpoint().toString(), msg.command());
if (origin->version() == 0) {
throw OriginNotReady();
}
if (msg.command() == "filterload") {
BloomFilter filter;
istringstream is(msg.payload());
is >> filter;
if (filter.isWithinSizeConstraints()) {
origin->filter = filter;
origin->filter.updateEmptyFull();
}
origin->relayTxes = true;
return true;
}
示例10: querySeqr
void querySeqr(BloomFilter & myFilter, const string & seq, size_t & fHit) {
if (seq.size() < opt::kmerLen) return;
uint64_t fhVal, rhVal;
if(myFilter.contains(seq.c_str(), fhVal, rhVal)) {
#ifdef _OPENMP
#pragma omp atomic
#endif
++fHit;
}
for (size_t i = 1; i < seq.size() - opt::kmerLen + 1; i++) {
if(myFilter.contains(fhVal, rhVal, seq[i-1], seq[i+opt::kmerLen-1])) {
#ifdef _OPENMP
#pragma omp atomic
#endif
++fHit;
}
}
}
示例11: loadSeqr
void loadSeqr(BloomFilter & BloomFilterFilter, const string & seq) {
if (seq.size() < opt::kmerLen) return;
string kmer = seq.substr(0,opt::kmerLen);
RollingHashIterator itr(seq, opt::kmerLen, opt::nhash);
while (itr != itr.end()) {
BloomFilterFilter.insert(*itr);
itr++;
}
}
示例12: TEST
TEST(BloomFilterTest, JsonDeserialize3rdParty)
{
// A bloom filter that conforms to the JSON API but was generated by an
// independent 3rd party implementation. It contains the strings "Kermit" and
// "MissPiggy".
const std::string json =
"{\"bitmap\":\"J+i5Mg==\",\"total_bits\":32,\"bits_per_entry\":12,"
"\"hash0\":{\"k0\":6547054200929830170,\"k1\":9813628641652032020},"
"\"hash1\":{\"k0\":15888472079188754020,\"k1\":14822504794822470401}}";
BloomFilter* bf = BloomFilter::from_json(json);
EXPECT_NE(bf, nullptr);
EXPECT_TRUE(bf->check("Kermit"));
EXPECT_TRUE(bf->check("MissPiggy"));
EXPECT_FALSE(bf->check("Gonzo"));
EXPECT_FALSE(bf->check("Animal"));
delete bf; bf = nullptr;
}
示例13: querySeq
void querySeq(BloomFilter & myFilter, const string & seq, size_t & fHit) {
if (seq.size() < opt::kmerLen) return;
for (size_t i = 0; i < seq.size() - opt::kmerLen + 1; i++) {
if(myFilter.contains(seq.c_str()+i)) {
#ifdef _OPENMP
#pragma omp atomic
#endif
++fHit;
}
}
}
示例14: transactions
vector<uint256> Claims::claims(BloomFilter& filter) const {
int64_t fee;
vector<Transaction> txns = transactions(fee);
vector<uint256> hashes;
for (vector<Transaction>::const_iterator tx = txns.begin(); tx != txns.end(); ++tx) {
if (filter.isRelevantAndUpdate(*tx))
hashes.push_back(tx->getHash());
}
return hashes;
}
示例15: _eIntersect
double _eIntersect(BloomFilter &b)
{
double dot = 0;
//cout << fsize << "==" << filter.size() << endl;
for (size_t i =0; i < fsize; i++)
if (filter[i] == 1 || b.filter[i] == 1)
dot ++;
double union_size = _eUnion(b);
double e = _esize() + b._esize() - union_size;
return e;
}