Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::bloom_parameters Class Reference

#include <bloom_filter.hpp>

Collaboration diagram for fc::bloom_parameters:

Classes

struct  optimal_parameters_t
 

Public Member Functions

 bloom_parameters ()
 
virtual ~bloom_parameters ()
 
bool operator! ()
 
virtual bool compute_optimal_parameters ()
 

Public Attributes

unsigned long long int minimum_size
 
unsigned long long int maximum_size
 
unsigned int minimum_number_of_hashes
 
unsigned int maximum_number_of_hashes
 
unsigned long long int projected_element_count
 
double false_positive_probability
 
unsigned long long int random_seed
 
optimal_parameters_t optimal_parameters
 

Detailed Description

Definition at line 46 of file bloom_filter.hpp.

Constructor & Destructor Documentation

◆ bloom_parameters()

fc::bloom_parameters::bloom_parameters ( )
inline

Definition at line 50 of file bloom_filter.hpp.

51 : minimum_size(1),
52 maximum_size(std::numeric_limits<unsigned long long int>::max()),
54 maximum_number_of_hashes(std::numeric_limits<unsigned int>::max()),
57 random_seed(0xA5A5A5A55A5A5A5AULL)
58 {}
unsigned long long int maximum_size
unsigned long long int random_seed
unsigned long long int projected_element_count
unsigned int maximum_number_of_hashes
unsigned int minimum_number_of_hashes
unsigned long long int minimum_size

◆ ~bloom_parameters()

virtual fc::bloom_parameters::~bloom_parameters ( )
inlinevirtual

Definition at line 60 of file bloom_filter.hpp.

61 {}

Member Function Documentation

◆ compute_optimal_parameters()

virtual bool fc::bloom_parameters::compute_optimal_parameters ( )
inlinevirtual

Definition at line 109 of file bloom_filter.hpp.

110 {
111 /*
112 Note:
113 The following will attempt to find the number of hash functions
114 and minimum amount of storage bits required to construct a bloom
115 filter consistent with the user defined false positive probability
116 and estimated element insertion count.
117 */
118
119 if (!(*this))
120 return false;
121
122 double min_m = std::numeric_limits<double>::infinity();
123 double min_k = 0.0;
124 double curr_m = 0.0;
125 double k = 1.0;
126
127 while (k < 1000.0)
128 {
129 double numerator = (- k * projected_element_count);
130 double denominator = std::log(1.0 - std::pow(false_positive_probability, 1.0 / k));
131 curr_m = numerator / denominator;
132 if (curr_m < min_m)
133 {
134 min_m = curr_m;
135 min_k = k;
136 }
137 k += 1.0;
138 }
139
140 optimal_parameters_t& optp = optimal_parameters;
141
142 optp.number_of_hashes = static_cast<unsigned int>(min_k);
143 optp.table_size = static_cast<unsigned long long int>(min_m);
144 optp.table_size += (((optp.table_size % bits_per_char) != 0) ? (bits_per_char - (optp.table_size % bits_per_char)) : 0);
145
146 if (optp.number_of_hashes < minimum_number_of_hashes)
147 optp.number_of_hashes = minimum_number_of_hashes;
148 else if (optp.number_of_hashes > maximum_number_of_hashes)
149 optp.number_of_hashes = maximum_number_of_hashes;
150
151 if (optp.table_size < minimum_size)
152 optp.table_size = minimum_size;
153 else if (optp.table_size > maximum_size)
154 optp.table_size = maximum_size;
155
156 return true;
157 }
optimal_parameters_t optimal_parameters

◆ operator!()

bool fc::bloom_parameters::operator! ( )
inline

Definition at line 63 of file bloom_filter.hpp.

64 {
65 return (minimum_size > maximum_size) ||
71 (std::numeric_limits<double>::infinity() == std::abs(false_positive_probability)) ||
72 (0 == random_seed) ||
73 (0xFFFFFFFFFFFFFFFFULL == random_seed);
74 }

Member Data Documentation

◆ false_positive_probability

double fc::bloom_parameters::false_positive_probability

Definition at line 92 of file bloom_filter.hpp.

◆ maximum_number_of_hashes

unsigned int fc::bloom_parameters::maximum_number_of_hashes

Definition at line 82 of file bloom_filter.hpp.

◆ maximum_size

unsigned long long int fc::bloom_parameters::maximum_size

Definition at line 78 of file bloom_filter.hpp.

◆ minimum_number_of_hashes

unsigned int fc::bloom_parameters::minimum_number_of_hashes

Definition at line 81 of file bloom_filter.hpp.

◆ minimum_size

unsigned long long int fc::bloom_parameters::minimum_size

Definition at line 77 of file bloom_filter.hpp.

◆ optimal_parameters

optimal_parameters_t fc::bloom_parameters::optimal_parameters

Definition at line 107 of file bloom_filter.hpp.

◆ projected_element_count

unsigned long long int fc::bloom_parameters::projected_element_count

Definition at line 87 of file bloom_filter.hpp.

◆ random_seed

unsigned long long int fc::bloom_parameters::random_seed

Definition at line 94 of file bloom_filter.hpp.


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