Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a Bloom Filter Data Structure #667

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Akshat-Shu
Copy link

Fixes #666

Bloom Filter data structure for efficient probabilistic membership testing. The implementation is based on a fixed-size bit array and can support multiple hash functions from hashlib. This Bloom Filter allows users to insert elements and check for membership with a low false positive rate.

Changes Implemented

  • BitArray Class: Implements a compact bit array with efficient bit manipulation.
  • BloomFilter Class:
    • Supports insertion of elements.
    • Provides a probabilistic membership check.
    • Uses multiple hash functions (sha256, md5, etc.) for uniform bit distribution.
  • Dynamic Calculation of Parameters: Computes the optimal bit array size and number of hash functions based on expected capacity and false positive rate.
  • Serialization of keys to support multiple data types
  • Unit Tests: Tests basic insertion and membership queries as well as BitArray functioning

Copy link

codecov bot commented Mar 22, 2025

Codecov Report

Attention: Patch coverage is 91.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 97.204%. Comparing base (f4c1677) to head (9bb7346).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ucts/miscellaneous_data_structures/bloom_filter.py 90.816% 9 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              main      #667       +/-   ##
=============================================
- Coverage   97.345%   97.204%   -0.142%     
=============================================
  Files           36        37        +1     
  Lines         4445      4650      +205     
=============================================
+ Hits          4327      4520      +193     
- Misses         118       130       +12     
Files with missing lines Coverage Δ
...astructs/miscellaneous_data_structures/__init__.py 100.000% <100.000%> (ø)
...ucts/miscellaneous_data_structures/bloom_filter.py 90.816% <90.816%> (ø)

... and 4 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Bloom Filter
1 participant