36 : salt_count_(salt_count)
47 return ( provider.salt_count_ == salt_count_);
57 _salt.push_back(hash);
67 std::list<bloom_type> hashes;
69 for (std::vector<bloom_type>::const_iterator iter = _salt.begin(); iter != _salt.end(); ++iter)
71 hashes.push_back(hash_ap(begin, remaining_length, (*iter)));
78 void DefaultHashProvider::generate_salt()
80 const unsigned int predef_salt_count = 64;
81 static const bloom_type predef_salt[predef_salt_count] =
83 0xAAAAAAAA, 0x55555555, 0x33333333, 0xCCCCCCCC,
84 0x66666666, 0x99999999, 0xB5B5B5B5, 0x4B4B4B4B,
85 0xAA55AA55, 0x55335533, 0x33CC33CC, 0xCC66CC66,
86 0x66996699, 0x99B599B5, 0xB54BB54B, 0x4BAA4BAA,
87 0xAA33AA33, 0x55CC55CC, 0x33663366, 0xCC99CC99,
88 0x66B566B5, 0x994B994B, 0xB5AAB5AA, 0xAAAAAA33,
89 0x555555CC, 0x33333366, 0xCCCCCC99, 0x666666B5,
90 0x9999994B, 0xB5B5B5AA, 0xFFFFFFFF, 0xFFFF0000,
91 0xB823D5EB, 0xC1191CDF, 0xF623AEB3, 0xDB58499F,
92 0xC8D42E70, 0xB173F616, 0xA91A5967, 0xDA427D63,
93 0xB1E8A2EA, 0xF6C0D155, 0x4909FEA3, 0xA68CC6A7,
94 0xC395E782, 0xA26057EB, 0x0CD5DA28, 0x467C5492,
95 0xF15E6982, 0x61C6FAD3, 0x9615E352, 0x6E9E355A,
96 0x689B563E, 0x0C9831A8, 0x6753C18B, 0xA622689B,
97 0x8CA63C47, 0x42CC2884, 0x8E89919B, 0x6EDBD7D3,
98 0x15B6796C, 0x1D6FDFE4, 0x63FF9092, 0xE7401432
101 if (salt_count_ > predef_salt_count)
106 for(
unsigned int i = 0; i < salt_count_; ++i)
112 bloom_type DefaultHashProvider::hash_ap(
const unsigned char* begin, std::size_t remaining_length,
bloom_type hash)
const
114 const unsigned char* it = begin;
115 while(remaining_length >= 2)
117 hash ^= (hash << 7) ^ (*it++) * (hash >> 3);
118 hash ^= (~((hash << 11) + ((*it++) ^ (hash >> 5))));
119 remaining_length -= 2;
121 if (remaining_length)
123 hash ^= (hash << 7) ^ (*it) * (hash >> 3);
140 : _hashp(salt_count), table_size_(table_size), _itemcount(0), salt_count_(salt_count)
152 : _hashp(filter._hashp), table_size_(filter.table_size_), _itemcount(filter._itemcount), salt_count_(filter.salt_count_)
186 std::size_t bit_index = 0;
189 std::list<bloom_type> hashes =
_hashp.
hash(key_begin, length);
191 for (std::list<bloom_type>::iterator iter = hashes.begin(); iter != hashes.end(); ++iter)
202 insert(reinterpret_cast<const unsigned char*>(key.c_str()),key.size());
207 insert(reinterpret_cast<const unsigned char*>(data),length);
212 std::size_t bit_index = 0;
215 const std::list<bloom_type> hashes =
_hashp.
hash(key_begin, length);
217 for (std::list<bloom_type>::const_iterator iter = hashes.begin(); iter != hashes.end(); ++iter)
231 return contains(reinterpret_cast<const unsigned char*>(key.c_str()),key.size());
236 return contains(reinterpret_cast<const unsigned char*>(data),length);
323 return pow(1 - pow(1 - (1 / m), k * n), k);