Bloom Filter Structure implementation in Go
A Bloom filter is a space-efficient probabilistic data structure, conceived by Burton Howard Bloom in 1970, that is used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not โ in other words, a query returns either "possibly in set" or "definitely not in set".
With a correctly configured Go toolchain:
go get -u github.com/ecorreiax/gobfs
Create a hash for a specif string and then add this index into the bitset array
func myFunction() {
h := sha1.New()
a := [3]string{"apple", "grape", "mango"}
for _, s := range a {
idx, _ := hash.CreateHash(h, s)
hash.AddHash(idx)
}
}
Check if a specific string is definitely not in the bitset array
func checkString() {
s := "coconut"
found := gobfs.Check(u)
if found {
// possibly in bitset
}
// definitely not in bitset
}
Possibly in bitset means that is not possible to be sure, since differents words after hashed can result in the same index.
This project is under MIT License.