https://github.com/accelbyte/bloom
Go bloom filter with Murmur3 hash
https://github.com/accelbyte/bloom
Last synced: 6 months ago
JSON representation
Go bloom filter with Murmur3 hash
- Host: GitHub
- URL: https://github.com/accelbyte/bloom
- Owner: AccelByte
- License: apache-2.0
- Created: 2018-09-15T19:57:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-15T20:28:25.000Z (over 7 years ago)
- Last Synced: 2024-06-21T06:17:19.943Z (almost 2 years ago)
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bloom
This project bloom filter implementation using Murmur3 hash by [github.com/spaolacci/murmur3](github.com/spaolacci/murmur3).
## Usage
### Importing package
```go
import "github.com/AccelByte/bloom"
```
### Creating new bloom filter
```go
// create new filter with size of 100
// with default Murmur3 hashing strategy
// and 1.e-5 expected false positive probability
b := bloom.New(100)
```
### Putting item into bloom filter
```go
b.Put([]byte("an_item"))
```
### Checking if an item exists
```gp
b.MightContain([]byte("an_item"))
```
### Exporting bloom filter to JSON
```go
exported, _ := b.MarshalJSON()
```
### Constructing bloom filter from exported JSON
```go
bloomFilterJSON := &bloom.FilterJSON{}
json.Unmarshal(exported, bloomFilterJSON)
newB := bloom.From(bloomFilterJSON.B, bloomFilterJSON.K)
```