hugh2632 / bloomfilter Goto Github PK
View Code? Open in Web Editor NEWgolang bloomfilter 布隆过滤器
License: MIT License
golang bloomfilter 布隆过滤器
License: MIT License
基于内存的模式添加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()
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.