bloom_filter: fix index calculation to work on int, not uint

Java uses long, so we should use int64_t. Using uint64_t causes the wrong
indexes to be calculated, and therefore, the filter to respond incorrectly
to a given key.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This commit is contained in:
Glauber Costa
2015-05-20 17:54:42 -04:00
committed by Tomasz Grabiec
parent 601bb48fe7
commit ba60176d4d
2 changed files with 2 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ namespace utils {
namespace filter {
static thread_local auto reusable_indexes = std::vector<long>();
void bloom_filter::set_indexes(uint64_t base, uint64_t inc, int count, long max, std::vector<long>& results) {
void bloom_filter::set_indexes(int64_t base, int64_t inc, int count, long max, std::vector<long>& results) {
for (int i = 0; i < count; i++) {
results[i] = abs(base % max);
base += inc;

View File

@@ -43,7 +43,7 @@ private:
bitmap _bitset;
int _hash_count;
void set_indexes(uint64_t base, uint64_t inc, int count, long max, std::vector<long>& results);
void set_indexes(int64_t base, int64_t inc, int count, long max, std::vector<long>& results);
std::vector<long> get_hash_buckets(const bytes_view& key, int hash_count, long max);
std::vector<long> indexes(const bytes_view& key);