Example #1
0
func (this *ScalableBloom) addBloomFilter() {
	var bf bloom.Bloom
	if this.bfc == nil {
		bf = partitioned.New(this.n)
	} else {
		bf = this.bfc(this.n)
	}

	e := this.e * math.Pow(float64(this.r), float64(len(this.bfs)))

	bf.SetHasher(this.h)
	bf.SetErrorProbability(e)
	bf.Reset()

	this.bfs = append(this.bfs, bf)
	//fmt.Println("Added new bloom filter")
}
Example #2
0
func testBloomFilter(t *testing.T, bf bloom.Bloom) {
	fn, fp := 0, 0

	for l := range web2 {
		if !(bf.Add([]byte(web2[l])).Check([]byte(web2[l]))) {
			fn++
		}
	}

	bf.PrintStats()

	for l := range web2a {
		if bf.Check([]byte(web2a[l])) {
			//fmt.Println("False Positive:", web2a[l])
			fp++
		}
	}

	fmt.Printf("Total false negatives: %d (%.4f%%)\n", fn, (float32(fn) / float32(len(web2)) * 100))
	fmt.Printf("Total false positives: %d (%.4f%%)\n", fp, (float32(fp) / float32(len(web2a)) * 100))
}