Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theodesp/go-blooms
Simple and efficient bloom filter implementations in Go
https://github.com/theodesp/go-blooms
bloom-filter data-structures probabilistic-data-structures
Last synced: 2 months ago
JSON representation
Simple and efficient bloom filter implementations in Go
- Host: GitHub
- URL: https://github.com/theodesp/go-blooms
- Owner: theodesp
- License: mit
- Created: 2017-12-16T18:53:11.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-26T14:30:59.000Z (about 6 years ago)
- Last Synced: 2024-10-03T07:23:36.357Z (3 months ago)
- Topics: bloom-filter, data-structures, probabilistic-data-structures
- Language: Go
- Homepage: https://godoc.org/github.com/theodesp/go-blooms
- Size: 7.81 KB
- Stars: 8
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
go-blooms
---From Wiki
>Bloom Filter: A space-efficient probabilistic data structure that is used to test whether an element is a member of
a set. False positive matches are possible, but false negatives are not; i.e. a query returns either "possibly in set"
or "definitely not in set". Elements can be added to the set, but not removed.This bloom filter implementation is backed by bool slice for simplicity.
And the hashing functions used are fnv and murmur both 64 bit versions.
## Installation
```go
go get -u github.com/theodesp/go-blooms
```## Usage
```go
package example
import "github.com/theodesp/go-blooms"const (
size = 64 * 1024
)bf := go_blooms.New(size, go_blooms.DefaultHashFunctions)
value := "hello"
bf.Add([]byte(value)) // we accept only a byte slice
if bf.Test([]byte(value)) { // probably true, could be false
// whatever
}anotherValue := "world"
if bf.Test([]byte(anotherValue) { // Bloom filter guarantees that anotherValue is not in the set
panic("This should never happen")
}```
## Complexity
**Time**
If we are using a bloom filter with bits and hash function,
insertion and search will both take time.
In both cases, we just need to run the input through all of
the hash functions. Then we just check the output bits.| Operation | Complexity |
|---|---|
| insertion | O(k) |
| search | O(k) |**Space**
The space of the actual data structure (what holds the data).| Complexity |
|---|
| O(m) |Where `m` is the size of the slice.
## Benchmarks
m=1024, k=3
```bash
PASS: bloomFilter_test.go:66: MySuite.BenchmarkAdd 10000000 231 ns/op
PASS: bloomFilter_test.go:74: MySuite.BenchmarkTest 10000000 231 ns/op
```## License
Copyright © 2017 Theo Despoudis
MIT license