google / google/leveldb

Modification of Bit Manipulation in Bloom Filter

Open
#1,217 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

File: util/bloom.cc
Line: 50: array[bitpos / 8] |= (1 << (bitpos % 8));
This line sets the bit at position n by shifting 1 left by the remainder of n divided by 8. However, it does not set the nth bit directly; instead, it sets the bit at position (n / 8) * 8 + (8 - n % 8).
According to standard Bloom filter logic, we should set the nth bit (where n is calculated by hashing the key). While the current implementation functions correctly, aligning with traditional Bloom filter logic could enhance clarity. However, if this is changed to align with the original implementation of Bloom filters, existing databases may encounter issues such as data loss or incorrect results.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.