Live data from Hacker News

How to write a Bloom filter in C++

blog.michaelschmatz.com

11–20 of 21 posts

Re: How to write a Bloom filter in C++

#15
Learned something today. Thanks for the article.

Minor nit: it will save readers time if you call out that "p is the false positive error rate". (You reference the error rate, but don't attach a variable name to it.) I had to go to an external reference to figure that out, which meant I learned something else of course.

Re: How to write a Bloom filter in C++

#16
post #14

I feel the use of vector is an iffy choice. The Bitcoin codebase has a simple Bloom filter implementation you can take a look at that has been in use for some time https://github.com/bitcoin/bitcoin/blob/master/src/bloom.h https://github.com/bitcoin/bitcoin/blob/master/src/bloom.cpp

std::bitset is also a good choice if the number of desired bits is known at compile time

Re: How to write a Bloom filter in C++

#18
post #14

I feel the use of vector is an iffy choice. The Bitcoin codebase has a simple Bloom filter implementation you can take a look at that has been in use for some time https://github.com/bitcoin/bitcoin/blob/master/src/bloom.h https://github.com/bitcoin/bitcoin/blob/master/src/bloom.cpp

What's wrong with vector (other than its name)? The interface is exactly what you need to implement a bit-level abstraction in a language where this isn't a first-class primitive.

Re: How to write a Bloom filter in C++

#19

Learned something today. Thanks for the article. Minor nit: it will save readers time if you call out that "p is the false positive error rate". (You reference the error rate, but don't attach a variable name to it.) I had to go to an external reference to figure that out, which meant I learned something else of course.

Great suggestion, thanks! I've updated the article accordingly :)

Re: How to write a Bloom filter in C++

#20
post #14

I feel the use of vector is an iffy choice. The Bitcoin codebase has a simple Bloom filter implementation you can take a look at that has been in use for some time https://github.com/bitcoin/bitcoin/blob/master/src/bloom.h https://github.com/bitcoin/bitcoin/blob/master/src/bloom.cpp

std::bitset is also a good choice if the number of desired bits is known at compile time

I think this would probably be the best choice after templating the filter
Post reply on HN