-
Notifications
You must be signed in to change notification settings - Fork 1
/
BloomUtil.hpp
76 lines (70 loc) · 1.66 KB
/
BloomUtil.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef BloomUtil_H
#define BloomUtil_H
#include "BloomFilter.hpp"
#include <stdint.h>
class bloom_util
{
private:
uint64_t bf_size;
bloom_parameters bf_para;
bloom_filter bf;
int nb_threads;
public:
bloom_util(double fprate=0.01): bf_size(10000003),bf_para(10000003,fprate), bf(bf_para),nb_threads(1){}
bloom_util(uint64_t bf_size,double fprate=0.01): bf_size(bf_size),bf_para(bf_size,fprate), bf(bf_para),nb_threads(1){}
double get_occupancy()
{
return bf.occupancy();
}
double get_false_positive_rate()
{
return bf.GetActualFP();
}
#ifdef largeintlib
int add(kmercode_length &val,bool flag=false)
{
if(nb_threads>=1&&flag&&(bf.contains(val)))
return 0;
bf.insert(val);
return 1;
}
#endif
#ifdef _LP64
int add(__uint128_t &val,bool flag=false)
{
if(nb_threads>=1&&flag&&(bf.contains(val)))
return 0;
bf.insert(val);
return 1;
}
#endif
int add(uint64_t &val,bool flag=false)
{
if(nb_threads>=1&&flag&&(bf.contains(val)))
return 0;
bf.insert(val);
return 1;
}
#ifdef largeintlib
bool contain(LargeInt<kmer_precision> &val)
{
return bf.contains(val) ;
}
#endif
#ifdef _LP64
bool contain(__uint128_t &val)
{
return bf.contains(val) ;
}
#endif
bool contain(uint64_t &val)
{
return bf.contains(val) ;
}
void set_nb_threads( int nb_t)
{
nb_threads = nb_t ;
bf.SetNumOfThreads( nb_t ) ;
}
};
#endif