https://github.com/long-gong/open-bloom-filter-wrapper
Open Bloom Filter (Python Wrapper)
https://github.com/long-gong/open-bloom-filter-wrapper
bloom-filter python python-wrapper
Last synced: 4 months ago
JSON representation
Open Bloom Filter (Python Wrapper)
- Host: GitHub
- URL: https://github.com/long-gong/open-bloom-filter-wrapper
- Owner: long-gong
- Created: 2020-06-05T13:08:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-05T13:58:43.000Z (over 5 years ago)
- Last Synced: 2025-01-17T08:15:04.108Z (10 months ago)
- Topics: bloom-filter, python, python-wrapper
- Language: C++
- Homepage: https://github.com/long-gong/open-bloom-filter-wrapper
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Open Bloom Filter
[Open Bloom Filter](https://github.com/long-gong/open-bloom-filter-wrapper) is a Python wrapper for [C++ Bloom Filter Library](https://github.com/ArashPartow/bloom).
## Install
```bash
make install
```
## Usage
```python
from open_bloom_filter import BloomFilter
if __name__ == "__main__":
entries = 1000000
fpr = 0.01
bf = BloomFilter(entries, fpr)
print(
"size (number of bits): %i, number of hash functions: %i"
% (len(bf), bf.num_hashes())
)
print(f"{entries}")
for i in range(entries):
bf.add(i)
for i in range(entries):
assert i in bf
cf = 0
ct = 0
for i in range(entries, 2 * entries):
if i in bf:
cf += 1
ct += 1
print(f"fpr: {100.0 * cf / ct}%")
```