btllib
 All Classes Namespaces Functions Variables
Public Member Functions | Static Public Member Functions | Friends | List of all members
btllib::BloomFilter Class Reference

Public Member Functions

 BloomFilter ()
 
 BloomFilter (size_t bytes, unsigned hash_num, std::string hash_fn="")
 
 BloomFilter (const std::string &path)
 
 BloomFilter (const BloomFilter &)=delete
 
 BloomFilter (BloomFilter &&)=delete
 
BloomFilteroperator= (const BloomFilter &)=delete
 
BloomFilteroperator= (BloomFilter &&)=delete
 
void insert (const uint64_t *hashes)
 
void insert (const std::vector< uint64_t > &hashes)
 
bool contains (const uint64_t *hashes) const
 
bool contains (const std::vector< uint64_t > &hashes) const
 
bool contains_insert (const uint64_t *hashes)
 
bool contains_insert (const std::vector< uint64_t > &hashes)
 
size_t get_bytes () const
 
uint64_t get_pop_cnt () const
 
double get_occupancy () const
 
unsigned get_hash_num () const
 
double get_fpr () const
 
const std::string & get_hash_fn () const
 
void save (const std::string &path)
 

Static Public Member Functions

static void save (const std::string &path, const cpptoml::table &table, const char *data, size_t n)
 
static bool is_bloom_file (const std::string &path)
 
static bool check_file_signature (const std::string &path, const std::string &signature)
 

Friends

class KmerBloomFilter
 
class SeedBloomFilter
 

Constructor & Destructor Documentation

btllib::BloomFilter::BloomFilter ( )
inline

Construct a dummy Bloom filter (e.g. as a default argument).

btllib::BloomFilter::BloomFilter ( size_t  bytes,
unsigned  hash_num,
std::string  hash_fn = "" 
)

Construct an empty Bloom filter of given size.

Parameters
bytesFilter size in bytes.
hash_numNumber of hash values per element.
hash_fnName of the hash function used. Used for metadata. Optional.
btllib::BloomFilter::BloomFilter ( const std::string &  path)
explicit

Load a Bloom filter from a file.

Parameters
pathFilepath to load from.

Member Function Documentation

bool btllib::BloomFilter::contains ( const uint64_t *  hashes) const

Check for the presence of an element's hash values.

Parameters
hashesInteger array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.
Returns
True if present, false otherwise.
bool btllib::BloomFilter::contains ( const std::vector< uint64_t > &  hashes) const
inline

Check for the presence of an element's hash values.

Parameters
hashesInteger vector of hash values.
Returns
True if present, false otherwise.
bool btllib::BloomFilter::contains_insert ( const uint64_t *  hashes)

Check for the presence of an element's hash values and insert if missing.

Parameters
hashesInteger array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.
Returns
True if present before insertion, false otherwise.
bool btllib::BloomFilter::contains_insert ( const std::vector< uint64_t > &  hashes)
inline

Check for the presence of an element's hash values and insert if missing.

Parameters
hashesInteger vector of hash values.
Returns
True if present before insertion, false otherwise.
size_t btllib::BloomFilter::get_bytes ( ) const
inline

Get filter size in bytes.

double btllib::BloomFilter::get_fpr ( ) const

Get the query false positive rate.

const std::string& btllib::BloomFilter::get_hash_fn ( ) const
inline

Get the name of the hash function used.

unsigned btllib::BloomFilter::get_hash_num ( ) const
inline

Get the number of hash values per element.

double btllib::BloomFilter::get_occupancy ( ) const

Get the fraction of the filter occupied by 1 bits.

uint64_t btllib::BloomFilter::get_pop_cnt ( ) const

Get population count, i.e. the number of 1 bits in the filter.

void btllib::BloomFilter::insert ( const uint64_t *  hashes)

Insert an element's hash values.

Parameters
hashesInteger array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.
void btllib::BloomFilter::insert ( const std::vector< uint64_t > &  hashes)
inline

Insert an element's hash values.

Parameters
hashesInteger vector of hash values.
static bool btllib::BloomFilter::is_bloom_file ( const std::string &  path)
inlinestatic

Check whether the file at the given path is a saved Bloom filter.

Parameters
pathFilepath to check.
void btllib::BloomFilter::save ( const std::string &  path)

Save the Bloom filter to a file that can be loaded in the future.

Parameters
pathFilepath to store filter at.

The documentation for this class was generated from the following file: