Skip to content

Commit ef6b960

Browse files
committed
update readme
1 parent 4fdc74e commit ef6b960

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

readme.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,31 @@ go get github.com/dsa0x/sprout
3535

3636
### Usage
3737

38-
sprout contains implementation of both the normal and scalable bloom filter via the methods below:
38+
Sprout contains implementation of both the normal and scalable bloom filter via the methods below:
3939

4040
```go
4141
opts := &sprout.BloomOptions{
4242
Err_rate: 0.001,
4343
Capacity: 100000,
4444
}
45-
45+
// Normal Bloom Filter
4646
bf := sprout.NewBloom(opts)
47+
48+
// Scalable Bloom Filter
4749
sbf := sprout.NewScalableBloom(opts)
4850
```
4951

5052
#### With a persistent store
5153

52-
sprout supports boltdb and badgerdb as persistent store. Using them is very simple. sprout exposes methods that initializes the database and then they can be attached to the bloom filter
54+
Sprout supports boltdb and badgerdb as persistent storage. Using them is very simple. Sprout exposes methods that initializes the database and then they can be attached to the bloom filter.
5355

54-
##### Using Boltdb
56+
**Using Boltdb**
5557

5658
```go
5759
// initialize boltdb
5860
db := sprout.NewBolt("/tmp/test.db", 0600)
5961

60-
// you can also setup options supported by bolt to configure your store
62+
// the bolt store can be configured as defined in the boltdb documentations
6163
opts := bbolt.Options{
6264
Timeout: 10 * time.Second,
6365
}
@@ -72,13 +74,6 @@ opts := &sprout.BloomOptions{
7274
bf := sprout.NewBloom(opts)
7375
```
7476

75-
#### Using Scalable bloom filter
76-
77-
```go
78-
// initialize badgerdb
79-
sbf := sprout.NewScalableBloom(sprout.DefaultOptions("/tmp/test.db"))
80-
```
81-
8277
### Example
8378

8479
```go
@@ -100,19 +95,21 @@ func main() {
10095
}
10196
bf := sprout.NewBloom(opts)
10297
defer bf.Close()
103-
bf.Add([]byte("foo"), []byte("bar"))
98+
bf.Add([]byte("foo"))
10499
fmt.Println(bf.Contains([]byte("foo")))
105100

106101
// with a persistent store
107-
opts := badger.DefaultOptions("/tmp/store.db")
108-
db := sprout.NewBadger(opts)
109-
bf := sprout.NewScalableBloom(0.9, 100, db)
102+
badgerOpts := badger.DefaultOptions("/tmp/store.db")
103+
db := sprout.NewBadger(badgerOpts)
104+
opts.Database = db
105+
bf := sprout.NewScalableBloom(opts)
110106

111-
bf.Add([]byte("key"), []byte("bar"))
107+
bf.Put([]byte("key"), []byte("bar"))
112108
fmt.Printf("%s\n", bf.Get([]byte("key")))
113109
}
114110
```
115111

116112
#### References
117113

118114
1. [P. Almeida, C.Baquero, N. Preguiça, D. Hutchison](https://haslab.uminho.pt/cbm/files/dbloom.pdf)
115+
2. [Austin Appleby Murmur hash Source Code](https://github.com/aappleby/smhasher)

0 commit comments

Comments
 (0)