]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Move internal bloom cmds to dht repo
authorMatt Joiner <anacrolix@gmail.com>
Fri, 25 May 2018 08:36:59 +0000 (18:36 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 25 May 2018 08:36:59 +0000 (18:36 +1000)
internal/cmd/bloom-estimate/main.go [deleted file]
internal/cmd/bloom-false-positives/main.go [deleted file]

diff --git a/internal/cmd/bloom-estimate/main.go b/internal/cmd/bloom-estimate/main.go
deleted file mode 100644 (file)
index 5cdb41c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package main
-
-import (
-       "flag"
-       "fmt"
-
-       "github.com/willf/bloom"
-)
-
-func main() {
-       n := flag.Int("n", 0, "expected number of items")
-       falsePositiveRate := flag.Float64("fpr", 0, "false positive rate")
-       flag.Parse()
-       filter := bloom.NewWithEstimates(uint(*n), *falsePositiveRate)
-       fmt.Printf("m: %d, k: %d\n", filter.Cap(), filter.K())
-}
diff --git a/internal/cmd/bloom-false-positives/main.go b/internal/cmd/bloom-false-positives/main.go
deleted file mode 100644 (file)
index 456e210..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package main
-
-import (
-       "bufio"
-       "fmt"
-       "os"
-
-       "github.com/anacrolix/tagflag"
-       "github.com/willf/bloom"
-)
-
-func main() {
-       var args struct {
-               M uint `help:"num bits"`
-               K uint `help:"num hashing functions"`
-       }
-       tagflag.Parse(&args, tagflag.Description("adds lines from stdin to a bloom filter with the given configuration, and gives collision stats at EOF"))
-       filter := bloom.New(args.M, args.K)
-       scanner := bufio.NewScanner(os.Stdin)
-       n := 0
-       collisions := 0
-       for scanner.Scan() {
-               if filter.TestAndAdd(scanner.Bytes()) {
-                       collisions++
-               }
-               n++
-       }
-       if err := scanner.Err(); err != nil {
-               fmt.Fprintf(os.Stderr, "error reading stdin: %s", err)
-               os.Exit(1)
-       }
-       fmt.Printf("collisions %d/%d (%f)\n", collisions, n, float64(collisions)/float64(n)*100)
-}