Code Monkey home page Code Monkey logo

bloomfilter's Issues

结果不准确

基于内存的模式添加500万数据,拿任何数据,碰撞得出的结果都是存在。

func TestMemoryFilter(t *testing.T) {
	bf := bloomfilter.NewMemoryFilter(make([]byte, 10240), bloomfilter.DefaultHash[:5]...)
	bf.Clear()

	//file, err := os.Open("./1.txt")
	file, err := os.Open("/Users/pandy/go/src/go-sdk/data/domain.txt")
	defer file.Close()
	if err != nil {
		fmt.Printf("Error: %s\n", err)
		return
	}

	reader := bufio.NewReader(file)
	countWrite := 0
	for {
		a, _, c := reader.ReadLine()
		if c == io.EOF {
			break
		}

		bf.Push(a)
		countWrite++
	}

	bf.Write()
	t.Log("write num:", countWrite)

	// 入数据之后 进行碰撞检测
	countRead := 0
	//file2, err := os.Open("/Users/pandy/go/src/go-sdk/data/domain_read.txt")
	file2, err := os.Open("./2.txt")
	defer file.Close()
	if err != nil {
		fmt.Printf("Error: %s\n", err)
		return
	}

	reader2 := bufio.NewReader(file2)
	for {
		a, _, c := reader2.ReadLine()
		if c == io.EOF {
			break
		}

		if bf.Exists(a) {
			countRead++
		} else {
			t.Log("not hash", string(a))
		}
	}

	t.Log("hashed num:", countRead)

	bf.Clear()
	bf.Close()
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.