Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
zncleon committed Sep 18, 2023
1 parent 5bd0f53 commit 62ddcb5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/types/bloom_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ StatusOr<BlockSplitBloomFilter> CreateBlockSplitBloomFilter(std::string& bitset)
bool BlockSplitBloomFilter::FindHash(uint64_t hash) const {
const auto bucket_index = static_cast<uint32_t>(((hash >> 32) * (data_.size() / kBytesPerFilterBlock)) >> 32);
const auto key = static_cast<uint32_t>(hash);
const auto* bitset32 = reinterpret_cast<const uint32_t*>(data_view_.data());
const auto* bitset32 = reinterpret_cast<const uint32_t*>(data_.data());

for (int i = 0; i < kBitsSetPerBlock; ++i) {
// Calculate mask for key in the given bitset.
Expand All @@ -83,10 +83,6 @@ void BlockSplitBloomFilter::InsertHash(uint64_t hash) {
const uint32_t mask = UINT32_C(0x1) << ((key * SALT[i]) >> 27);
bitset32[bucket_index * kBitsSetPerBlock + i] |= mask;
}
data_view_ = data_;
}

uint64_t BlockSplitBloomFilter::Hash(const char* data, size_t length) { return XXH64(data, length, /*seed=*/0); }

BlockSplitBloomFilter::BlockSplitBloomFilter(const std::string& bitset)
: data_view_(bitset), num_bytes_(bitset.size()) {}
3 changes: 0 additions & 3 deletions src/types/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ class BlockSplitBloomFilter {
static uint64_t Hash(const char* data, size_t length);

private:
// The private constructor of BlockSplitBloomFilter. It's only used for CreateReadOnlyBloomFilter
explicit BlockSplitBloomFilter(const std::string& bitset);

// Bytes in a tiny Bloom filter block.
static constexpr int kBytesPerFilterBlock = 32;

Expand Down
6 changes: 2 additions & 4 deletions src/types/redis_bloom_chain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,11 @@ void BloomChain::bloomAdd(const Slice &item, std::string *bf_data) {
block_split_bloom_filter.InsertHash(h);
}


bool BloomChain::bloomCheck(const Slice &item, std::string &bf_data) {
std::unique_ptr<const BlockSplitBloomFilter> bloom_filter_read_only =
BlockSplitBloomFilter::CreateReadOnlyBloomFilter(bf_data);
BlockSplitBloomFilter block_split_bloom_filter(bf_data);

uint64_t h = BlockSplitBloomFilter::Hash(item.data(), item.size());
return bloom_filter_read_only->FindHash(h);
return block_split_bloom_filter.FindHash(h);
}

rocksdb::Status BloomChain::Reserve(const Slice &user_key, uint32_t capacity, double error_rate, uint16_t expansion) {
Expand Down

0 comments on commit 62ddcb5

Please sign in to comment.