diff --git a/db/memtable.cc b/db/memtable.cc index 58683e2f6..5c405071f 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -110,10 +110,10 @@ MemTable::MemTable(const InternalKeyComparator& cmp, assert(!ShouldScheduleFlush()); if (prefix_extractor_ && moptions_.memtable_prefix_bloom_bits > 0) { - prefix_bloom_.reset(new DynamicBloom( - &arena_, moptions_.memtable_prefix_bloom_bits, ioptions.bloom_locality, - 6 /* hard coded 6 probes */, nullptr, moptions_.memtable_huge_page_size, - ioptions.info_log)); + prefix_bloom_.reset( + new DynamicBloom(&arena_, moptions_.memtable_prefix_bloom_bits, + ioptions.bloom_locality, 6 /* hard coded 6 probes */, + moptions_.memtable_huge_page_size, ioptions.info_log)); } } diff --git a/table/bloom_block.h b/table/bloom_block.h index 9ff610bad..483fa25d9 100644 --- a/table/bloom_block.h +++ b/table/bloom_block.h @@ -15,8 +15,7 @@ class BloomBlockBuilder { public: static const std::string kBloomBlock; - explicit BloomBlockBuilder(uint32_t num_probes = 6) - : bloom_(num_probes, nullptr) {} + explicit BloomBlockBuilder(uint32_t num_probes = 6) : bloom_(num_probes) {} void SetTotalBits(Allocator* allocator, uint32_t total_bits, uint32_t locality, size_t huge_page_tlb_size, diff --git a/table/plain_table_reader.cc b/table/plain_table_reader.cc index ae656763c..9dc50a525 100644 --- a/table/plain_table_reader.cc +++ b/table/plain_table_reader.cc @@ -104,7 +104,7 @@ PlainTableReader::PlainTableReader( user_key_len_(static_cast(table_properties->fixed_key_len)), prefix_extractor_(prefix_extractor), enable_bloom_(false), - bloom_(6, nullptr), + bloom_(6), file_info_(std::move(file), storage_options, static_cast(table_properties->data_size)), ioptions_(ioptions), diff --git a/util/dynamic_bloom.cc b/util/dynamic_bloom.cc index 635dd98af..8e90efd89 100644 --- a/util/dynamic_bloom.cc +++ b/util/dynamic_bloom.cc @@ -32,20 +32,13 @@ uint32_t GetTotalBitsForLocality(uint32_t total_bits) { DynamicBloom::DynamicBloom(Allocator* allocator, uint32_t total_bits, uint32_t locality, uint32_t num_probes, - uint32_t (*hash_func)(const Slice& key), - size_t huge_page_tlb_size, - Logger* logger) - : DynamicBloom(num_probes, hash_func) { + size_t huge_page_tlb_size, Logger* logger) + : DynamicBloom(num_probes) { SetTotalBits(allocator, total_bits, locality, huge_page_tlb_size, logger); } -DynamicBloom::DynamicBloom(uint32_t num_probes, - uint32_t (*hash_func)(const Slice& key)) - : kTotalBits(0), - kNumBlocks(0), - kNumProbes(num_probes), - hash_func_(hash_func == nullptr ? &BloomHash : hash_func), - data_(nullptr) {} +DynamicBloom::DynamicBloom(uint32_t num_probes) + : kTotalBits(0), kNumBlocks(0), kNumProbes(num_probes), data_(nullptr) {} void DynamicBloom::SetRawData(unsigned char* raw_data, uint32_t total_bits, uint32_t num_blocks) { diff --git a/util/dynamic_bloom.h b/util/dynamic_bloom.h index 398222b1d..654bc9ad5 100644 --- a/util/dynamic_bloom.h +++ b/util/dynamic_bloom.h @@ -10,6 +10,7 @@ #include "rocksdb/slice.h" #include "port/port.h" +#include "util/hash.h" #include #include @@ -35,12 +36,10 @@ class DynamicBloom { explicit DynamicBloom(Allocator* allocator, uint32_t total_bits, uint32_t locality = 0, uint32_t num_probes = 6, - uint32_t (*hash_func)(const Slice& key) = nullptr, size_t huge_page_tlb_size = 0, Logger* logger = nullptr); - explicit DynamicBloom(uint32_t num_probes = 6, - uint32_t (*hash_func)(const Slice& key) = nullptr); + explicit DynamicBloom(uint32_t num_probes = 6); void SetTotalBits(Allocator* allocator, uint32_t total_bits, uint32_t locality, size_t huge_page_tlb_size, @@ -86,7 +85,6 @@ class DynamicBloom { uint32_t kNumBlocks; const uint32_t kNumProbes; - uint32_t (*hash_func_)(const Slice& key); std::atomic* data_; // or_func(ptr, mask) should effect *ptr |= mask with the appropriate @@ -95,10 +93,10 @@ class DynamicBloom { void AddHash(uint32_t hash, const OrFunc& or_func); }; -inline void DynamicBloom::Add(const Slice& key) { AddHash(hash_func_(key)); } +inline void DynamicBloom::Add(const Slice& key) { AddHash(BloomHash(key)); } inline void DynamicBloom::AddConcurrently(const Slice& key) { - AddHashConcurrently(hash_func_(key)); + AddHashConcurrently(BloomHash(key)); } inline void DynamicBloom::AddHash(uint32_t hash) { @@ -122,7 +120,7 @@ inline void DynamicBloom::AddHashConcurrently(uint32_t hash) { } inline bool DynamicBloom::MayContain(const Slice& key) const { - return (MayContainHash(hash_func_(key))); + return (MayContainHash(BloomHash(key))); } #if defined(_MSC_VER)