Great read Theofanis, I've been meaning to refresh on bloom filters for a while :D.
Question, why not just generatek from the length of hashfns? I have played with Go minimally so maybe this is a gap in my understanding of constructors.
Daniel, this was just for convenience. While it is possible to have tons of hash functions, you only need a few of them. The real case with the k parameter is that you need to calculate the optimal value of it based on the error rate you would like to achieve.
Most of the times k > len(hasnFuncs) so you need to feed the item in all functions k times in a predictable manner.
That means you have to create a function with no side-effects that get a byte array parameter, hashes k times with the hasnFuncs and returns an integer for the position.
Great read Theofanis, I've been meaning to refresh on bloom filters for a while :D.
Question, why not just generate
k
from the length ofhashfns
? I have played with Go minimally so maybe this is a gap in my understanding of constructors.Daniel, this was just for convenience. While it is possible to have tons of hash functions, you only need a few of them. The real case with the
k
parameter is that you need to calculate the optimal value of it based on the error rate you would like to achieve.Most of the times
k > len(hasnFuncs)
so you need to feed the item in all functionsk
times in a predictable manner.That means you have to create a function with no side-effects that get a byte array parameter, hashes k times with the hasnFuncs and returns an integer for the position.
Thanks Theofanis, makes sense!