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

Request: Counting bloom filter function to get current value #3

Closed
glmcdona opened this issue Feb 12, 2023 · 3 comments
Closed

Request: Counting bloom filter function to get current value #3

glmcdona opened this issue Feb 12, 2023 · 3 comments

Comments

@glmcdona
Copy link

glmcdona commented Feb 12, 2023

Another request if possible. For the counting bloom filter, is it possible add a function to get the current count?

Eg:

cbf.add("asdf")
cbf.add("asdf")
print(cbf.count("asdf")) --> 2
print(cbf.count("abcd")) --> 0

Not sure if this is possible since I'm not a bloom filter expert. I think looking at the code it uses 4 bits for the counting, so will be encoding a count between 0 and 15 to track the count, right?

@yankun1992
Copy link
Owner

It is possible to provide an api to return the count, but due to the principle of the counting bloom filter itself, this count is not an accurate statistic, but only a rough estimate, and if too much elements are inserted to this bloom filter, the more inaccurate this estimate will be. Does this meet your needs?

@glmcdona
Copy link
Author

Yes, that works for the scenario I am working on. And the current 4 bits of counting works perfect for my scenario. Appreciate it @yankun1992!

@yankun1992
Copy link
Owner

In CountingBloomFilter, add methods estimate_count and counter_at to support this fearure.
Usage examples can be find at https://github.com/yankun1992/fastbloom/blob/main/py_tests/test_counting_bloom_filter.py#L96

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

No branches or pull requests

2 participants