https://github.com/mtchavez/countmin
CountMin sketching algorithm in golang
https://github.com/mtchavez/countmin
count-min-sketch go golang sketching-algorithm
Last synced: 3 months ago
JSON representation
CountMin sketching algorithm in golang
- Host: GitHub
- URL: https://github.com/mtchavez/countmin
- Owner: mtchavez
- License: mit
- Created: 2014-06-20T03:42:27.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-07-26T13:48:19.000Z (almost 7 years ago)
- Last Synced: 2025-02-04T15:32:40.495Z (5 months ago)
- Topics: count-min-sketch, go, golang, sketching-algorithm
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# CountMin
[](https://github.com/mtchavez/countmin/releases)
[](https://travis-ci.org/mtchavez/countmin)
[](http://godoc.org/github.com/mtchavez/countmin)
[](https://goreportcard.com/report/github.com/mtchavez/countmin)
[](https://codeclimate.com/github/mtchavez/countmin/maintainability)
[](https://codeclimate.com/github/mtchavez/countmin/test_coverage)CountMin sketching algorithm.
## Install
Install package
`go get -u github.com/mtchavez/countmin`
## Usage
```go
package mainimport (
"fmt""github.com/mtchavez/countmin"
)func main() {
cm := countmin.New(10, 100000000)
for _, i := range []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1} {
cm.Add([]byte(fmt.Sprintf("%d", i)), int64(i))
}
fmt.Printf("Estimate of %d is %d\n", 1, cm.Count([]byte("1")))
fmt.Printf("Estimate of %d is %d\n", 3, cm.Count([]byte("3")))
fmt.Printf("Estimate of %d is %d\n", 9, cm.Count([]byte("9")))
fmt.Println("Size: ", cm.Size())
fmt.Println("Err: ", cm.RelativeError())
fmt.Println("Confidence: ", cm.Confidence())
}
```## Tests
Run using `go test ./... --cover`
Run benchmarks `go test --bench=.*`
## TODO
* Serialize/Deserialize
* TCP / HTTP server wrappers