C++ Bloom Filter Library  release
Public Member Functions | List of all members
compressible_bloom_filter Class Reference

#include <bloom_filter.hpp>

Inheritance diagram for compressible_bloom_filter:
[legend]
Collaboration diagram for compressible_bloom_filter:
[legend]

Public Member Functions

 compressible_bloom_filter (const bloom_parameters &p)
 
unsigned long long int size () const
 
bool compress (const double &percentage)
 
- Public Member Functions inherited from bloom_filter
 bloom_filter ()
 
 bloom_filter (const bloom_parameters &p)
 
 bloom_filter (const bloom_filter &filter)
 
bool operator== (const bloom_filter &f) const
 
bool operator!= (const bloom_filter &f) const
 
bloom_filteroperator= (const bloom_filter &f)
 
virtual ~bloom_filter ()
 
bool operator! () const
 
void clear ()
 
void insert (const unsigned char *key_begin, const std::size_t &length)
 
template<typename T >
void insert (const T &t)
 
void insert (const std::string &key)
 
void insert (const char *data, const std::size_t &length)
 
template<typename InputIterator >
void insert (const InputIterator begin, const InputIterator end)
 
virtual bool contains (const unsigned char *key_begin, const std::size_t length) const
 
template<typename T >
bool contains (const T &t) const
 
bool contains (const std::string &key) const
 
bool contains (const char *data, const std::size_t &length) const
 
template<typename InputIterator >
InputIterator contains_all (const InputIterator begin, const InputIterator end) const
 
template<typename InputIterator >
InputIterator contains_none (const InputIterator begin, const InputIterator end) const
 
unsigned long long int element_count () const
 
double effective_fpp () const
 
bloom_filteroperator&= (const bloom_filter &f)
 
bloom_filteroperator|= (const bloom_filter &f)
 
bloom_filteroperator^= (const bloom_filter &f)
 
const cell_typetable () const
 
std::size_t hash_count ()
 

Additional Inherited Members

- Protected Types inherited from bloom_filter
typedef unsigned int bloom_type
 
typedef unsigned char cell_type
 
typedef std::vector< unsigned char > table_type
 
- Protected Member Functions inherited from bloom_filter
void generate_unique_salt ()
 
bloom_type hash_ap (const unsigned char *begin, std::size_t remaining_length, bloom_type hash) const
 
- Protected Attributes inherited from bloom_filter
std::vector< bloom_typesalt_
 
std::vector< unsigned char > bit_table_
 
unsigned int salt_count_
 
unsigned long long int table_size_
 
unsigned long long int projected_element_count_
 
unsigned long long int inserted_element_count_
 
unsigned long long int random_seed_
 
double desired_false_positive_probability_
 

Detailed Description

Definition at line 641 of file bloom_filter.hpp.

Constructor & Destructor Documentation

◆ compressible_bloom_filter()

compressible_bloom_filter::compressible_bloom_filter ( const bloom_parameters p)
inline

Definition at line 645 of file bloom_filter.hpp.

646  : bloom_filter(p)
647  {
648  size_list.push_back(table_size_);
649  }
unsigned long long int table_size_

Member Function Documentation

◆ compress()

bool compressible_bloom_filter::compress ( const double &  percentage)
inline

Definition at line 656 of file bloom_filter.hpp.

References bits_per_char.

Referenced by main().

657  {
658  if (
659  (percentage < 0.0) ||
660  (percentage >= 100.0)
661  )
662  {
663  return false;
664  }
665 
666  unsigned long long int original_table_size = size_list.back();
667  unsigned long long int new_table_size = static_cast<unsigned long long int>((size_list.back() * (1.0 - (percentage / 100.0))));
668 
669  new_table_size -= new_table_size % bits_per_char;
670 
671  if (
672  (bits_per_char > new_table_size) ||
673  (new_table_size >= original_table_size)
674  )
675  {
676  return false;
677  }
678 
680 
681  const unsigned long long int new_tbl_raw_size = new_table_size / bits_per_char;
682 
683  table_type tmp(new_tbl_raw_size);
684 
685  std::copy(bit_table_.begin(), bit_table_.begin() + new_tbl_raw_size, tmp.begin());
686 
687  typedef table_type::iterator itr_t;
688 
689  itr_t itr = bit_table_.begin() + (new_table_size / bits_per_char);
690  itr_t end = bit_table_.begin() + (original_table_size / bits_per_char);
691  itr_t itr_tmp = tmp.begin();
692 
693  while (end != itr)
694  {
695  *(itr_tmp++) |= (*itr++);
696  }
697 
698  std::swap(bit_table_, tmp);
699 
700  size_list.push_back(new_table_size);
701 
702  return true;
703  }
static const std::size_t bits_per_char
std::vector< unsigned char > table_type
std::vector< unsigned char > bit_table_
double effective_fpp() const
double desired_false_positive_probability_
Here is the caller graph for this function:

◆ size()

unsigned long long int compressible_bloom_filter::size ( ) const
inlinevirtual

Reimplemented from bloom_filter.

Definition at line 651 of file bloom_filter.hpp.

Referenced by main().

652  {
653  return size_list.back();
654  }
Here is the caller graph for this function:

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