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
BloomFilter & | operator= (const BloomFilter &)=delete
BloomFilter & | operator= (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

## BloomFilter() [1/3]

btllib::BloomFilter::BloomFilter | ( |  | ) |

inline

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

## BloomFilter() [2/3]

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

Construct an empty Bloom filter of given size.

Parameters

  bytes | Filter size in bytes.
  hash_num | Number of hash values per element.
  hash_fn | Name of the hash function used. Used for metadata. Optional.

## BloomFilter() [3/3]

btllib::BloomFilter::BloomFilter | ( | const std::string & | path | ) |

explicit

Load a Bloom filter from a file.

Parameters

  path | Filepath to load from.

## Member Function Documentation

## contains() [1/2]

bool btllib::BloomFilter::contains | ( | const std::vector< uint64_t > & | hashes | ) | const

inline

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

Parameters

  hashes | Integer vector of hash values.

Returns
  True if present, false otherwise.

## contains() [2/2]

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

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

Parameters

  hashes | Integer 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.

## contains_insert() [1/2]

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

  hashes | Integer vector of hash values.

Returns
  True if present before insertion, false otherwise.

## contains_insert() [2/2]

bool btllib::BloomFilter::contains_insert | ( | const uint64_t * | hashes | ) |

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

Parameters

  hashes | Integer 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.

## get_bytes()

size_t btllib::BloomFilter::get_bytes | ( |  | ) | const

inline

Get filter size in bytes.

## get_fpr()

double btllib::BloomFilter::get_fpr | ( |  | ) | const

Get the query false positive rate.

## get_hash_fn()

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

inline

Get the name of the hash function used.

## get_hash_num()

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

inline

Get the number of hash values per element.

## get_occupancy()

double btllib::BloomFilter::get_occupancy | ( |  | ) | const

Get the fraction of the filter occupied by 1 bits.

## get_pop_cnt()

uint64_t btllib::BloomFilter::get_pop_cnt | ( |  | ) | const

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

## insert() [1/2]

void btllib::BloomFilter::insert | ( | const std::vector< uint64_t > & | hashes | ) |

inline

Insert an element's hash values.

Parameters

  hashes | Integer vector of hash values.

## insert() [2/2]

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

Insert an element's hash values.

Parameters

  hashes | Integer array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.

## is_bloom_file()

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

  path | Filepath to check.

## save()

void btllib::BloomFilter::save | ( | const std::string & | path | ) |

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

Parameters

  path | Filepath to store filter at.

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

- include/btllib/bloom_filter.hpp