vkdb
A time series database engine in C++.
Loading...
Searching...
No Matches
vkdb::BloomFilter Class Reference

Bloom filter for time series keys. More...

#include <bloom_filter.h>

Public Types

using key_type = TimeSeriesKey
 
using size_type = uint64_t
 

Public Member Functions

 BloomFilter ()=delete
 Deleted default constructor.
 
 BloomFilter (std::string &&str) noexcept
 Construct a new BloomFilter object from the given string.
 
 BloomFilter (uint64_t expected_no_of_elems, double false_positive_rate)
 Construct a new BloomFilter object from the given expected number of elements and false positive rate.
 
 ~BloomFilter () noexcept=default
 Destroy the BloomFilter object.
 
 BloomFilter (BloomFilter &&) noexcept=default
 Move-construct a BloomFilter object.
 
BloomFilteroperator= (BloomFilter &&) noexcept=default
 Move-assign a BloomFilter object.
 
 BloomFilter (const BloomFilter &)=delete
 Deleted copy constructor.
 
BloomFilteroperator= (const BloomFilter &)=delete
 Deleted copy assignment operator.
 
void insert (const key_type &key) noexcept
 Insert a key into the Bloom filter.
 
bool mayContain (const key_type &key) const noexcept
 Check if the Bloom filter may contain a key.
 
std::string str () const noexcept
 Get the string representation of the Bloom filter.
 

Static Public Attributes

static constexpr double MIN_FALSE_POSITIVE_RATE {0.0}
 Minimum (exclusive) false positive rate.
 
static constexpr double MAX_FALSE_POSITIVE_RATE {1.0}
 Maximum (exclusive) false positive rate.
 

Detailed Description

Bloom filter for time series keys.

Definition at line 16 of file bloom_filter.h.

Member Typedef Documentation

◆ key_type

Definition at line 18 of file bloom_filter.h.

◆ size_type

using vkdb::BloomFilter::size_type = uint64_t

Definition at line 19 of file bloom_filter.h.

Constructor & Destructor Documentation

◆ BloomFilter() [1/2]

vkdb::BloomFilter::BloomFilter ( std::string && str)
noexcept

Construct a new BloomFilter object from the given string.

Parameters
strThe string representation of the Bloom filter.

Definition at line 5 of file bloom_filter.cpp.

◆ BloomFilter() [2/2]

vkdb::BloomFilter::BloomFilter ( uint64_t expected_no_of_elems,
double false_positive_rate )
explicit

Construct a new BloomFilter object from the given expected number of elements and false positive rate.

Parameters
expected_no_of_elemsThe expected number of elements.
false_positive_rateThe false positive rate.
Exceptions
std::invalid_argumentIf the expected number of elements is zero or the false positive rate is not in range (MIN_FALSE_POSITIVE_RATE, MAX_FALSE_POSITIVE_RATE).

Definition at line 25 of file bloom_filter.cpp.

Member Function Documentation

◆ insert()

void vkdb::BloomFilter::insert ( const key_type & key)
noexcept

Insert a key into the Bloom filter.

Parameters
keyThe key to insert.

Definition at line 55 of file bloom_filter.cpp.

◆ mayContain()

bool vkdb::BloomFilter::mayContain ( const key_type & key) const
nodiscardnoexcept

Check if the Bloom filter may contain a key.

Parameters
keyThe key to check.
Returns
true if the Bloom filter may contain the key.
false if the Bloom filter does not contain the key.

Definition at line 61 of file bloom_filter.cpp.

◆ str()

std::string vkdb::BloomFilter::str ( ) const
nodiscardnoexcept

Get the string representation of the Bloom filter.

Returns
std::string The string representation of the Bloom filter.

Definition at line 70 of file bloom_filter.cpp.

Member Data Documentation

◆ MAX_FALSE_POSITIVE_RATE

double vkdb::BloomFilter::MAX_FALSE_POSITIVE_RATE {1.0}
staticconstexpr

Maximum (exclusive) false positive rate.

Definition at line 31 of file bloom_filter.h.

◆ MIN_FALSE_POSITIVE_RATE

double vkdb::BloomFilter::MIN_FALSE_POSITIVE_RATE {0.0}
staticconstexpr

Minimum (exclusive) false positive rate.

Definition at line 25 of file bloom_filter.h.


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