Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fedragon/gloom
https://github.com/fedragon/gloom
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/fedragon/gloom
- Owner: fedragon
- Created: 2022-11-03T22:09:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T04:38:28.000Z (about 2 years ago)
- Last Synced: 2024-12-17T22:07:21.441Z (8 days ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gloom
Bloom filters implementation in Go.
## Context
Bloom filters are probabilistic data structures with a predetermined size and false positives' rate. They are space efficient and have a fixed `O(k)` cost to add an item or check if it's present, where `k` is the number of hashing functions used by the filter.
## Usage
```go
import "github.com/fedragon/gloom"// create a bloom filter which can store 10.000 elements with a 1% rate of false positives
bf := gloom.NewFilter(10000, 0.01)// insert a value in the filter
if err := bf.Insert("a"); err != nil {
return err
}...
// is this value in the filter?
if ok, err := bf.Contains("b"); err != nil {
return err
// if so, do something
if ok {
...
}
}
```