From ba60176d4d6d65ea3536eb7f504eb577e60398d5 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 20 May 2015 17:54:42 -0400 Subject: [PATCH] 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 --- utils/bloom_filter.cc | 2 +- utils/bloom_filter.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/bloom_filter.cc b/utils/bloom_filter.cc index 74c3a2e56d..f441fc9e43 100644 --- a/utils/bloom_filter.cc +++ b/utils/bloom_filter.cc @@ -36,7 +36,7 @@ namespace utils { namespace filter { static thread_local auto reusable_indexes = std::vector(); -void bloom_filter::set_indexes(uint64_t base, uint64_t inc, int count, long max, std::vector& results) { +void bloom_filter::set_indexes(int64_t base, int64_t inc, int count, long max, std::vector& results) { for (int i = 0; i < count; i++) { results[i] = abs(base % max); base += inc; diff --git a/utils/bloom_filter.hh b/utils/bloom_filter.hh index 0589cee94d..ca2b1cb578 100644 --- a/utils/bloom_filter.hh +++ b/utils/bloom_filter.hh @@ -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& results); + void set_indexes(int64_t base, int64_t inc, int count, long max, std::vector& results); std::vector get_hash_buckets(const bytes_view& key, int hash_count, long max); std::vector indexes(const bytes_view& key);