HOG2
BloomFilter.h
Go to the documentation of this file.
1 //
2 // bloom_filter.h
3 // hog2 glut
4 //
5 // Created by Nathan Sturtevant on 1/20/14.
6 // Copyright (c) 2014 University of Denver. All rights reserved.
7 //
8 
9 /*
10  *********************************************************************
11  * *
12  * Open Bloom Filter *
13  * *
14  * Author: Arash Partow - 2000 *
15  * URL: http://www.partow.net *
16  * URL: http://www.partow.net/programming/hashfunctions/index.html *
17  * *
18  * Copyright notice: *
19  * Free use of the Open Bloom Filter Library is permitted under the *
20  * guidelines and in accordance with the most current version of the *
21  * Common Public License. *
22  * http://www.opensource.org/licenses/cpl1.0.php *
23  * *
24  *********************************************************************
25  */
26 
27 
28 #ifndef INCLUDE_BLOOM_FILTER_HPP
29 #define INCLUDE_BLOOM_FILTER_HPP
30 
31 #include <algorithm>
32 #include <cmath>
33 #include <cstddef>
34 #include <iterator>
35 #include <limits>
36 #include <string>
37 #include <vector>
38 
39 
40 static const std::size_t bits_per_char = 0x08; // 8 bits in 1 char(unsigned)
41 static const unsigned char bit_mask[bits_per_char] = {
42  0x01, //00000001
43  0x02, //00000010
44  0x04, //00000100
45  0x08, //00001000
46  0x10, //00010000
47  0x20, //00100000
48  0x40, //01000000
49  0x80 //10000000
50 };
51 
53 {
54 public:
55 
57  : minimum_size(1),
58  maximum_size(std::numeric_limits<unsigned long long int>::max()),
60  maximum_number_of_hashes(std::numeric_limits<unsigned int>::max()),
63  random_seed(0xA5A5A5A55A5A5A5AULL)
64  {}
65 
67  {}
68 
69  inline bool operator!()
70  {
71  return (minimum_size > maximum_size) ||
74  (0 == maximum_number_of_hashes) ||
75  (0 == projected_element_count) ||
77  (std::numeric_limits<double>::infinity() == std::abs(false_positive_probability)) ||
78  (0 == random_seed) ||
79  (0xFFFFFFFFFFFFFFFFULL == random_seed);
80  }
81 
82  //Allowed min/max size of the bloom filter in bits
83  unsigned long long int minimum_size;
84  unsigned long long int maximum_size;
85 
86  //Allowed min/max number of hash functions
89 
90  //The approximate number of elements to be inserted
91  //into the bloom filter, should be within one order
92  //of magnitude. The default is 10000.
93  unsigned long long int projected_element_count;
94 
95  //The approximate false positive probability expected
96  //from the bloom filter. The default is the reciprocal
97  //of the projected_element_count.
99 
100  unsigned long long int random_seed;
101 
103  {
105  : number_of_hashes(0),
106  table_size(0)
107  {}
108 
109  unsigned int number_of_hashes;
110  unsigned long long int table_size;
111  };
112 
114 
116  {
117  /*
118  Note:
119  The following will attempt to find the number of hash functions
120  and minimum amount of storage bits required to construct a bloom
121  filter consistent with the user defined false positive probability
122  and estimated element insertion count.
123  */
124 
125  if (!(*this))
126  return false;
127 
128  double min_m = std::numeric_limits<double>::infinity();
129  double min_k = 0.0;
130  double curr_m = 0.0;
131  double k = 1.0;
132 
133  while (k < 1000.0)
134  {
135  double numerator = (- k * projected_element_count);
136  double denominator = std::log(1.0 - std::pow(false_positive_probability, 1.0 / k));
137  curr_m = numerator / denominator;
138  if (curr_m < min_m)
139  {
140  min_m = curr_m;
141  min_k = k;
142  }
143  k += 1.0;
144  }
145 
147 
148  optp.number_of_hashes = static_cast<unsigned int>(min_k);
149  optp.table_size = static_cast<unsigned long long int>(min_m);
150  optp.table_size += (((optp.table_size % bits_per_char) != 0) ? (bits_per_char - (optp.table_size % bits_per_char)) : 0);
151 
156 
157  if (optp.table_size < minimum_size)
158  optp.table_size = minimum_size;
159  else if (optp.table_size > maximum_size)
160  optp.table_size = maximum_size;
161 
162  return true;
163  }
164 
165 };
166 
168 {
169 protected:
170 
171  typedef unsigned int bloom_type;
172  typedef unsigned char cell_type;
173 
174 public:
175 
177  : bit_table_(0),
178  salt_count_(0),
179  table_size_(0),
180  raw_table_size_(0),
183  random_seed_(0),
185  {}
186 
188  : bit_table_(0),
189  projected_element_count_(p.projected_element_count),
191  random_seed_((p.random_seed * 0xA5A5A5A5) + 1),
192  desired_false_positive_probability_(p.false_positive_probability)
193  {
198  bit_table_ = new cell_type[static_cast<std::size_t>(raw_table_size_)];
199  std::fill_n(bit_table_,raw_table_size_,0x00);
200  }
201 
202  bloom_filter(const bloom_filter& filter)
203  {
204  this->operator=(filter);
205  }
206 
207  inline bool operator == (const bloom_filter& f) const
208  {
209  if (this != &f)
210  {
211  return
212  (salt_count_ == f.salt_count_) &&
213  (table_size_ == f.table_size_) &&
217  (random_seed_ == f.random_seed_) &&
219  (salt_ == f.salt_) &&
221  }
222  else
223  return true;
224  }
225 
226  inline bool operator != (const bloom_filter& f) const
227  {
228  return !operator==(f);
229  }
230 
232  {
233  if (this != &f)
234  {
242  delete[] bit_table_;
243  bit_table_ = new cell_type[static_cast<std::size_t>(raw_table_size_)];
245  salt_ = f.salt_;
246  }
247  return *this;
248  }
249 
250  virtual ~bloom_filter()
251  {
252  delete[] bit_table_;
253  }
254 
255  inline bool operator!() const
256  {
257  return (0 == table_size_);
258  }
259 
260  inline void clear()
261  {
262  std::fill_n(bit_table_,raw_table_size_,0x00);
264  }
265 
266  inline void insert(const unsigned char* key_begin, const std::size_t& length)
267  {
268  std::size_t bit_index = 0;
269  std::size_t bit = 0;
270  for (std::size_t i = 0; i < salt_.size(); ++i)
271  {
272  compute_indices(hash_ap(key_begin,length,salt_[i]),bit_index,bit);
273  bit_table_[bit_index / bits_per_char] |= bit_mask[bit];
274  }
276  }
277 
278  template<typename T>
279  inline void insert(const T& t)
280  {
281  // Note: T must be a C++ POD type.
282  insert(reinterpret_cast<const unsigned char*>(&t),sizeof(T));
283  }
284 
285  inline void insert(const std::string& key)
286  {
287  insert(reinterpret_cast<const unsigned char*>(key.c_str()),key.size());
288  }
289 
290  inline void insert(const char* data, const std::size_t& length)
291  {
292  insert(reinterpret_cast<const unsigned char*>(data),length);
293  }
294 
295  template<typename InputIterator>
296  inline void insert(const InputIterator begin, const InputIterator end)
297  {
298  InputIterator itr = begin;
299  while (end != itr)
300  {
301  insert(*(itr++));
302  }
303  }
304 
305  inline virtual bool contains(const unsigned char* key_begin, const std::size_t length) const
306  {
307  std::size_t bit_index = 0;
308  std::size_t bit = 0;
309  for (std::size_t i = 0; i < salt_.size(); ++i)
310  {
311  compute_indices(hash_ap(key_begin,length,salt_[i]),bit_index,bit);
312  if ((bit_table_[bit_index / bits_per_char] & bit_mask[bit]) != bit_mask[bit])
313  {
314  return false;
315  }
316  }
317  return true;
318  }
319 
320  template<typename T>
321  inline bool contains(const T& t) const
322  {
323  return contains(reinterpret_cast<const unsigned char*>(&t),static_cast<std::size_t>(sizeof(T)));
324  }
325 
326  inline bool contains(const std::string& key) const
327  {
328  return contains(reinterpret_cast<const unsigned char*>(key.c_str()),key.size());
329  }
330 
331  inline bool contains(const char* data, const std::size_t& length) const
332  {
333  return contains(reinterpret_cast<const unsigned char*>(data),length);
334  }
335 
336  template<typename InputIterator>
337  inline InputIterator contains_all(const InputIterator begin, const InputIterator end) const
338  {
339  InputIterator itr = begin;
340  while (end != itr)
341  {
342  if (!contains(*itr))
343  {
344  return itr;
345  }
346  ++itr;
347  }
348  return end;
349  }
350 
351  template<typename InputIterator>
352  inline InputIterator contains_none(const InputIterator begin, const InputIterator end) const
353  {
354  InputIterator itr = begin;
355  while (end != itr)
356  {
357  if (contains(*itr))
358  {
359  return itr;
360  }
361  ++itr;
362  }
363  return end;
364  }
365 
366  inline virtual unsigned long long int size() const
367  {
368  return table_size_;
369  }
370 
371  inline std::size_t element_count() const
372  {
374  }
375 
376  inline double effective_fpp() const
377  {
378  /*
379  Note:
380  The effective false positive probability is calculated using the
381  designated table size and hash function count in conjunction with
382  the current number of inserted elements - not the user defined
383  predicated/expected number of inserted elements.
384  */
385  return std::pow(1.0 - std::exp(-1.0 * salt_.size() * inserted_element_count_ / size()), 1.0 * salt_.size());
386  }
387 
389  {
390  /* intersection */
391  if (
392  (salt_count_ == f.salt_count_) &&
393  (table_size_ == f.table_size_) &&
395  )
396  {
397  for (std::size_t i = 0; i < raw_table_size_; ++i)
398  {
399  bit_table_[i] &= f.bit_table_[i];
400  }
401  }
402  return *this;
403  }
404 
406  {
407  /* union */
408  if (
409  (salt_count_ == f.salt_count_) &&
410  (table_size_ == f.table_size_) &&
412  )
413  {
414  for (std::size_t i = 0; i < raw_table_size_; ++i)
415  {
416  bit_table_[i] |= f.bit_table_[i];
417  }
418  }
419  return *this;
420  }
421 
423  {
424  /* difference */
425  if (
426  (salt_count_ == f.salt_count_) &&
427  (table_size_ == f.table_size_) &&
429  )
430  {
431  for (std::size_t i = 0; i < raw_table_size_; ++i)
432  {
433  bit_table_[i] ^= f.bit_table_[i];
434  }
435  }
436  return *this;
437  }
438 
439  inline const cell_type* table() const
440  {
441  return bit_table_;
442  }
443 
444  inline std::size_t hash_count()
445  {
446  return salt_.size();
447  }
448 
449 protected:
450 
451  inline virtual void compute_indices(const bloom_type& hash, std::size_t& bit_index, std::size_t& bit) const
452  {
453  bit_index = hash % table_size_;
454  bit = bit_index % bits_per_char;
455  }
456 
458  {
459  /*
460  Note:
461  A distinct hash function need not be implementation-wise
462  distinct. In the current implementation "seeding" a common
463  hash function with different values seems to be adequate.
464  */
465  const unsigned int predef_salt_count = 128;
466  static const bloom_type predef_salt[predef_salt_count] =
467  {
468  0xAAAAAAAA, 0x55555555, 0x33333333, 0xCCCCCCCC,
469  0x66666666, 0x99999999, 0xB5B5B5B5, 0x4B4B4B4B,
470  0xAA55AA55, 0x55335533, 0x33CC33CC, 0xCC66CC66,
471  0x66996699, 0x99B599B5, 0xB54BB54B, 0x4BAA4BAA,
472  0xAA33AA33, 0x55CC55CC, 0x33663366, 0xCC99CC99,
473  0x66B566B5, 0x994B994B, 0xB5AAB5AA, 0xAAAAAA33,
474  0x555555CC, 0x33333366, 0xCCCCCC99, 0x666666B5,
475  0x9999994B, 0xB5B5B5AA, 0xFFFFFFFF, 0xFFFF0000,
476  0xB823D5EB, 0xC1191CDF, 0xF623AEB3, 0xDB58499F,
477  0xC8D42E70, 0xB173F616, 0xA91A5967, 0xDA427D63,
478  0xB1E8A2EA, 0xF6C0D155, 0x4909FEA3, 0xA68CC6A7,
479  0xC395E782, 0xA26057EB, 0x0CD5DA28, 0x467C5492,
480  0xF15E6982, 0x61C6FAD3, 0x9615E352, 0x6E9E355A,
481  0x689B563E, 0x0C9831A8, 0x6753C18B, 0xA622689B,
482  0x8CA63C47, 0x42CC2884, 0x8E89919B, 0x6EDBD7D3,
483  0x15B6796C, 0x1D6FDFE4, 0x63FF9092, 0xE7401432,
484  0xEFFE9412, 0xAEAEDF79, 0x9F245A31, 0x83C136FC,
485  0xC3DA4A8C, 0xA5112C8C, 0x5271F491, 0x9A948DAB,
486  0xCEE59A8D, 0xB5F525AB, 0x59D13217, 0x24E7C331,
487  0x697C2103, 0x84B0A460, 0x86156DA9, 0xAEF2AC68,
488  0x23243DA5, 0x3F649643, 0x5FA495A8, 0x67710DF8,
489  0x9A6C499E, 0xDCFB0227, 0x46A43433, 0x1832B07A,
490  0xC46AFF3C, 0xB9C8FFF0, 0xC9500467, 0x34431BDF,
491  0xB652432B, 0xE367F12B, 0x427F4C1B, 0x224C006E,
492  0x2E7E5A89, 0x96F99AA5, 0x0BEB452A, 0x2FD87C39,
493  0x74B2E1FB, 0x222EFD24, 0xF357F60C, 0x440FCB1E,
494  0x8BBE030F, 0x6704DC29, 0x1144D12F, 0x948B1355,
495  0x6D8FD7E9, 0x1C11A014, 0xADD1592F, 0xFB3C712E,
496  0xFC77642F, 0xF9C4CE8C, 0x31312FB9, 0x08B0DD79,
497  0x318FA6E7, 0xC040D23D, 0xC0589AA7, 0x0CA5C075,
498  0xF874B172, 0x0CF914D5, 0x784D3280, 0x4E8CFEBC,
499  0xC569F575, 0xCDB2A091, 0x2CC016B4, 0x5C5F4421
500  };
501 
502  if (salt_count_ <= predef_salt_count)
503  {
504  std::copy(predef_salt,
505  predef_salt + salt_count_,
506  std::back_inserter(salt_));
507  for (unsigned int i = 0; i < salt_.size(); ++i)
508  {
509  /*
510  Note:
511  This is done to integrate the user defined random seed,
512  so as to allow for the generation of unique bloom filter
513  instances.
514  */
515  salt_[i] = salt_[i] * salt_[(i + 3) % salt_.size()] + static_cast<bloom_type>(random_seed_);
516  }
517  }
518  else
519  {
520  std::copy(predef_salt,predef_salt + predef_salt_count,std::back_inserter(salt_));
521  srand(static_cast<unsigned int>(random_seed_));
522  while (salt_.size() < salt_count_)
523  {
524  bloom_type current_salt = static_cast<bloom_type>(rand()) * static_cast<bloom_type>(rand());
525  if (0 == current_salt) continue;
526  if (salt_.end() == std::find(salt_.begin(), salt_.end(), current_salt))
527  {
528  salt_.push_back(current_salt);
529  }
530  }
531  }
532  }
533 
534  inline bloom_type hash_ap(const unsigned char* begin, std::size_t remaining_length, bloom_type hash) const
535  {
536  const unsigned char* itr = begin;
537  unsigned int loop = 0;
538  while (remaining_length >= 8)
539  {
540  const unsigned int& i1 = *(reinterpret_cast<const unsigned int*>(itr)); itr += sizeof(unsigned int);
541  const unsigned int& i2 = *(reinterpret_cast<const unsigned int*>(itr)); itr += sizeof(unsigned int);
542  hash ^= (hash << 7) ^ i1 * (hash >> 3) ^
543  (~((hash << 11) + (i2 ^ (hash >> 5))));
544  remaining_length -= 8;
545  }
546  if (remaining_length)
547  {
548  if (remaining_length >= 4)
549  {
550  const unsigned int& i = *(reinterpret_cast<const unsigned int*>(itr));
551  if (loop & 0x01)
552  hash ^= (hash << 7) ^ i * (hash >> 3);
553  else
554  hash ^= (~((hash << 11) + (i ^ (hash >> 5))));
555  ++loop;
556  remaining_length -= 4;
557  itr += sizeof(unsigned int);
558  }
559  if (remaining_length >= 2)
560  {
561  const unsigned short& i = *(reinterpret_cast<const unsigned short*>(itr));
562  if (loop & 0x01)
563  hash ^= (hash << 7) ^ i * (hash >> 3);
564  else
565  hash ^= (~((hash << 11) + (i ^ (hash >> 5))));
566  ++loop;
567  remaining_length -= 2;
568  itr += sizeof(unsigned short);
569  }
570  if (remaining_length)
571  {
572  hash += ((*itr) ^ (hash * 0xA5A5A5A5)) + loop;
573  }
574  }
575  return hash;
576  }
577 
578  std::vector<bloom_type> salt_;
579  unsigned char* bit_table_;
580  unsigned int salt_count_;
581  unsigned long long int table_size_;
582  unsigned long long int raw_table_size_;
583  unsigned long long int projected_element_count_;
585  unsigned long long int random_seed_;
587 };
588 
590 {
591  bloom_filter result = a;
592  result &= b;
593  return result;
594 }
595 
597 {
598  bloom_filter result = a;
599  result |= b;
600  return result;
601 }
602 
604 {
605  bloom_filter result = a;
606  result ^= b;
607  return result;
608 }
609 
611 {
612 public:
613 
615  : bloom_filter(p)
616  {
617  size_list.push_back(table_size_);
618  }
619 
620  inline unsigned long long int size() const
621  {
622  return size_list.back();
623  }
624 
625  inline bool compress(const double& percentage)
626  {
627  if ((0.0 >= percentage) || (percentage >= 100.0))
628  {
629  return false;
630  }
631 
632  unsigned long long int original_table_size = size_list.back();
633  unsigned long long int new_table_size = static_cast<unsigned long long int>((size_list.back() * (1.0 - (percentage / 100.0))));
634  new_table_size -= (((new_table_size % bits_per_char) != 0) ? (new_table_size % bits_per_char) : 0);
635 
636  if ((bits_per_char > new_table_size) || (new_table_size >= original_table_size))
637  {
638  return false;
639  }
640 
642  cell_type* tmp = new cell_type[static_cast<std::size_t>(new_table_size / bits_per_char)];
643  std::copy(bit_table_, bit_table_ + (new_table_size / bits_per_char), tmp);
644  cell_type* itr = bit_table_ + (new_table_size / bits_per_char);
645  cell_type* end = bit_table_ + (original_table_size / bits_per_char);
646  cell_type* itr_tmp = tmp;
647 
648  while (end != itr)
649  {
650  *(itr_tmp++) |= (*itr++);
651  }
652 
653  delete[] bit_table_;
654  bit_table_ = tmp;
655  size_list.push_back(new_table_size);
656 
657  return true;
658  }
659 
660 private:
661 
662  inline void compute_indices(const bloom_type& hash, std::size_t& bit_index, std::size_t& bit) const
663  {
664  bit_index = hash;
665  for (std::size_t i = 0; i < size_list.size(); ++i)
666  {
667  bit_index %= size_list[i];
668  }
669  bit = bit_index % bits_per_char;
670  }
671 
672  std::vector<unsigned long long int> size_list;
673 };
674 
675 #endif
676 
677 
678 /*
679  Note 1:
680  If it can be guaranteed that bits_per_char will be of the form 2^n then
681  the following optimization can be used:
682 
683  hash_table[bit_index >> n] |= bit_mask[bit_index & (bits_per_char - 1)];
684 
685  Note 2:
686  For performance reasons where possible when allocating memory it should
687  be aligned (aligned_alloc) according to the architecture being used.
688  */
689 
bloom_filter::operator==
bool operator==(const bloom_filter &f) const
Definition: BloomFilter.h:207
bloom_filter::effective_fpp
double effective_fpp() const
Definition: BloomFilter.h:376
bloom_parameters::optimal_parameters_t::optimal_parameters_t
optimal_parameters_t()
Definition: BloomFilter.h:104
bloom_filter::bloom_filter
bloom_filter(const bloom_parameters &p)
Definition: BloomFilter.h:187
bloom_filter::element_count
std::size_t element_count() const
Definition: BloomFilter.h:371
bloom_parameters::maximum_size
unsigned long long int maximum_size
Definition: BloomFilter.h:84
bloom_filter::~bloom_filter
virtual ~bloom_filter()
Definition: BloomFilter.h:250
operator^
bloom_filter operator^(const bloom_filter &a, const bloom_filter &b)
Definition: BloomFilter.h:603
bit_mask
static const unsigned char bit_mask[bits_per_char]
Definition: BloomFilter.h:41
bloom_filter::operator|=
bloom_filter & operator|=(const bloom_filter &f)
Definition: BloomFilter.h:405
bloom_parameters::compute_optimal_parameters
virtual bool compute_optimal_parameters()
Definition: BloomFilter.h:115
bloom_parameters::minimum_size
unsigned long long int minimum_size
Definition: BloomFilter.h:83
bloom_filter::operator!=
bool operator!=(const bloom_filter &f) const
Definition: BloomFilter.h:226
bloom_filter::contains_none
InputIterator contains_none(const InputIterator begin, const InputIterator end) const
Definition: BloomFilter.h:352
compressible_bloom_filter::size_list
std::vector< unsigned long long int > size_list
Definition: BloomFilter.h:672
bloom_filter::salt_
std::vector< bloom_type > salt_
Definition: BloomFilter.h:578
bloom_filter::insert
void insert(const T &t)
Definition: BloomFilter.h:279
bloom_filter::insert
void insert(const char *data, const std::size_t &length)
Definition: BloomFilter.h:290
bloom_parameters::optimal_parameters_t::table_size
unsigned long long int table_size
Definition: BloomFilter.h:110
bloom_filter::bloom_filter
bloom_filter()
Definition: BloomFilter.h:176
bloom_filter::bit_table_
unsigned char * bit_table_
Definition: BloomFilter.h:579
bloom_parameters::projected_element_count
unsigned long long int projected_element_count
Definition: BloomFilter.h:93
compressible_bloom_filter::compressible_bloom_filter
compressible_bloom_filter(const bloom_parameters &p)
Definition: BloomFilter.h:614
bloom_filter::insert
void insert(const InputIterator begin, const InputIterator end)
Definition: BloomFilter.h:296
bloom_parameters::optimal_parameters_t
Definition: BloomFilter.h:102
bloom_parameters::operator!
bool operator!()
Definition: BloomFilter.h:69
bloom_filter::table_size_
unsigned long long int table_size_
Definition: BloomFilter.h:581
bloom_filter::random_seed_
unsigned long long int random_seed_
Definition: BloomFilter.h:585
bloom_parameters::optimal_parameters
optimal_parameters_t optimal_parameters
Definition: BloomFilter.h:113
bloom_filter::salt_count_
unsigned int salt_count_
Definition: BloomFilter.h:580
bloom_filter
Definition: BloomFilter.h:167
bloom_filter::operator&=
bloom_filter & operator&=(const bloom_filter &f)
Definition: BloomFilter.h:388
bloom_filter::hash_ap
bloom_type hash_ap(const unsigned char *begin, std::size_t remaining_length, bloom_type hash) const
Definition: BloomFilter.h:534
bloom_filter::bloom_filter
bloom_filter(const bloom_filter &filter)
Definition: BloomFilter.h:202
operator|
bloom_filter operator|(const bloom_filter &a, const bloom_filter &b)
Definition: BloomFilter.h:596
bloom_filter::generate_unique_salt
void generate_unique_salt()
Definition: BloomFilter.h:457
bloom_filter::contains
bool contains(const std::string &key) const
Definition: BloomFilter.h:326
bloom_filter::cell_type
unsigned char cell_type
Definition: BloomFilter.h:172
bloom_filter::hash_count
std::size_t hash_count()
Definition: BloomFilter.h:444
bloom_parameters::false_positive_probability
double false_positive_probability
Definition: BloomFilter.h:98
compressible_bloom_filter
Definition: BloomFilter.h:610
bloom_filter::projected_element_count_
unsigned long long int projected_element_count_
Definition: BloomFilter.h:583
bloom_filter::insert
void insert(const unsigned char *key_begin, const std::size_t &length)
Definition: BloomFilter.h:266
compressible_bloom_filter::compute_indices
void compute_indices(const bloom_type &hash, std::size_t &bit_index, std::size_t &bit) const
Definition: BloomFilter.h:662
bloom_filter::clear
void clear()
Definition: BloomFilter.h:260
bloom_filter::desired_false_positive_probability_
double desired_false_positive_probability_
Definition: BloomFilter.h:586
bloom_filter::table
const cell_type * table() const
Definition: BloomFilter.h:439
bloom_filter::raw_table_size_
unsigned long long int raw_table_size_
Definition: BloomFilter.h:582
max
#define max(a, b)
Definition: MinimalSectorAbstraction.cpp:40
bloom_filter::size
virtual unsigned long long int size() const
Definition: BloomFilter.h:366
bits_per_char
static const std::size_t bits_per_char
Definition: BloomFilter.h:40
bloom_filter::operator^=
bloom_filter & operator^=(const bloom_filter &f)
Definition: BloomFilter.h:422
operator&
bloom_filter operator&(const bloom_filter &a, const bloom_filter &b)
Definition: BloomFilter.h:589
bloom_parameters::maximum_number_of_hashes
unsigned int maximum_number_of_hashes
Definition: BloomFilter.h:88
bloom_parameters::minimum_number_of_hashes
unsigned int minimum_number_of_hashes
Definition: BloomFilter.h:87
bloom_filter::contains
bool contains(const T &t) const
Definition: BloomFilter.h:321
std
Definition: CanonicalGraphEnvironment.h:26
bloom_filter::inserted_element_count_
unsigned int inserted_element_count_
Definition: BloomFilter.h:584
bloom_filter::contains_all
InputIterator contains_all(const InputIterator begin, const InputIterator end) const
Definition: BloomFilter.h:337
bloom_filter::operator=
bloom_filter & operator=(const bloom_filter &f)
Definition: BloomFilter.h:231
bloom_parameters::random_seed
unsigned long long int random_seed
Definition: BloomFilter.h:100
bloom_filter::insert
void insert(const std::string &key)
Definition: BloomFilter.h:285
bloom_parameters
Definition: BloomFilter.h:52
bloom_filter::bloom_type
unsigned int bloom_type
Definition: BloomFilter.h:171
bloom_parameters::bloom_parameters
bloom_parameters()
Definition: BloomFilter.h:56
bloom_filter::contains
bool contains(const char *data, const std::size_t &length) const
Definition: BloomFilter.h:331
bloom_filter::compute_indices
virtual void compute_indices(const bloom_type &hash, std::size_t &bit_index, std::size_t &bit) const
Definition: BloomFilter.h:451
bloom_parameters::~bloom_parameters
virtual ~bloom_parameters()
Definition: BloomFilter.h:66
bloom_filter::operator!
bool operator!() const
Definition: BloomFilter.h:255
bloom_parameters::optimal_parameters_t::number_of_hashes
unsigned int number_of_hashes
Definition: BloomFilter.h:109
compressible_bloom_filter::size
unsigned long long int size() const
Definition: BloomFilter.h:620
bloom_filter::contains
virtual bool contains(const unsigned char *key_begin, const std::size_t length) const
Definition: BloomFilter.h:305
compressible_bloom_filter::compress
bool compress(const double &percentage)
Definition: BloomFilter.h:625