Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create simple example_test.go
  • Loading branch information
Kz Ho committed Jan 20, 2023
commit 573b53733a32cd6eecd3bd8b1707fb60d9d1abc3
20 changes: 20 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package bloom_test

import (
"fmt"
"github.com/bits-and-blooms/bloom/v3"
)

func Example() {
filter := bloom.NewWithEstimates(1000000, 0.01)
filter.Add([]byte("Love"))
fmt.Println(filter.Test([]byte("Love")))

var n uint = 1_000_000
fmt.Println(bloom.EstimateFalsePositiveRate(20*n, 5, n) > 0.001)

expectedFpRate := 0.01
m, k := bloom.EstimateParameters(n, expectedFpRate)
actualFpRate := bloom.EstimateFalsePositiveRate(m, k, n)
fmt.Printf("expectedFpRate=%v, actualFpRate=%v\n", expectedFpRate, actualFpRate)
}