Codebase list golang-github-dcso-bloom / 2901687
Import upstream version 0.2.3+git20201124.1.9240e18 Debian Janitor 2 years ago
2 changed file(s) with 16 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
00 language: go
11 sudo: false
2 arch:
3 - AMD64
4 - ppc64le
25 before_script:
3 - go get -t ./...
4 - go vet ./...
6 - go get -t ./...
7 - go vet ./...
58 script: make release test
69 deploy:
710 provider: releases
2020 type BloomFilter struct {
2121 //bit array
2222 v []uint64
23
2324 //desired maximum number of elements
2425 n uint64
26
2527 //desired false positive probability
2628 p float64
29
2730 //number of hash functions
2831 k uint64
32
2933 //number of bits
3034 m uint64
35
3136 //number of elements in the filter
3237 N uint64
38
3339 //number of 64-bit integers (generated automatically)
3440 M uint64
41
3542 //arbitrary data that we can attach to the filter
3643 Data []byte
3744 }
290297 // Initialize returns a new, empty Bloom filter with the given capacity (n)
291298 // and FP probability (p).
292299 func Initialize(n uint64, p float64) BloomFilter {
300 m := math.Abs(math.Ceil(float64(n) * math.Log(p) / math.Pow(math.Log(2.0), 2.0)))
293301 var bf BloomFilter
294302 bf.n = n
295303 bf.p = p
296 bf.m = uint64(math.Abs(math.Ceil(float64(n) * math.Log(float64(p)) / (math.Pow(math.Log(2.0), 2.0)))))
297 bf.M = uint64(math.Ceil(float64(bf.m) / 64.0))
298 bf.k = uint64(math.Ceil(math.Log(2) * float64(bf.m) / float64(n)))
304 bf.m = uint64(m)
305 bf.M = uint64(math.Ceil(m / 64.0))
306 bf.k = uint64(math.Ceil(math.Log(2) * m / float64(n)))
299307 bf.v = make([]uint64, bf.M)
300308 return bf
301309 }