首次提交代码
This commit is contained in:
38
info.go
Normal file
38
info.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log/slog"
|
||||
|
||||
"git.algo.com.cn/public/bloomtool/internal/bloom"
|
||||
)
|
||||
|
||||
func RunInfo(args ...string) error {
|
||||
fs := flag.NewFlagSet("info", flag.ExitOnError)
|
||||
|
||||
bmpFile := fs.String("b", "", "bitmap filename")
|
||||
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
} else if fs.NArg() > 0 || *bmpFile == "" {
|
||||
fs.Usage()
|
||||
return nil
|
||||
}
|
||||
|
||||
return info(*bmpFile)
|
||||
}
|
||||
|
||||
func info(bmpFile string) error {
|
||||
|
||||
slog.Info("load bitmap file", "filename", bmpFile)
|
||||
bfile, err := bloom.LoadFromFile(bmpFile, true)
|
||||
if err != nil {
|
||||
slog.Error("open bitmap file error", "err", err)
|
||||
return err
|
||||
}
|
||||
|
||||
stat := bfile.GetStat()
|
||||
slog.Info("bitmap info", "stat", stat)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user