Ejemplo n.º 1
0
func NewBloomWrap(capSize uint) BloomWrap {
	wrap := []bloom.Bloom{}
	newFilter := func(h hash.Hash) {
		filter := standard.New(capSize)
		filter.SetHasher(h)
		wrap = append(wrap, filter)
	}
	newFilter(cityhash.New64())
	newFilter(fnv.New64())
	newFilter(md5.New())
	log.Println("bloomLen: ", len(wrap))
	return wrap
}
Ejemplo n.º 2
0
func generateGarbage() {
	var capSize uint = 1000000000
	filter := standard.New(capSize)
	filter.SetHasher(cityhash.New64())
	v := []byte("Love")
	b := filter.Add(v).Check(v)
	log.Println("check @v:", b)
	bad := 0
	for i := 0; i < 1000000000; i++ {
		if i%1000000 == 0 {
			log.Println(i)
			debug.FreeOSMemory()
		}
		d := []byte(fmt.Sprint("data", i))
		if filter.Check(d) == true {
			bad++
			//			panic(fmt.Sprint("should not exist @d:",string(d)))
		}
		if flag := filter.Add(d).Check(d); flag == false {
			panic(d)
		}
	}
	log.Println("====>>That is all @bad:", bad)
}