-
Notifications
You must be signed in to change notification settings - Fork 5
/
info.go
executable file
·50 lines (39 loc) · 985 Bytes
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sisyphus
import (
"github.com/boltdb/bolt"
"github.com/retailnext/hllpp"
)
// Info produces statistics
func Info(db *bolt.DB) (gTotal, jTotal, gWords, jWords uint64) {
_ = db.View(func(tx *bolt.Tx) error {
p := tx.Bucket([]byte("Statistics"))
gRaw := p.Get([]byte("ProcessedGood"))
if len(gRaw) > 0 {
var gHLL *hllpp.HLLPP
gHLL, _ = hllpp.Unmarshal(gRaw)
gTotal = gHLL.Count()
}
jRaw := p.Get([]byte("ProcessedJunk"))
if len(jRaw) > 0 {
var jHLL *hllpp.HLLPP
jHLL, _ = hllpp.Unmarshal(jRaw)
jTotal = jHLL.Count()
}
return nil
})
_ = db.View(func(tx *bolt.Tx) error {
p := tx.Bucket([]byte("Wordlists"))
pj := p.Bucket([]byte("Junk"))
stats := pj.Stats()
jWords = uint64(stats.KeyN)
return nil
})
_ = db.View(func(tx *bolt.Tx) error {
p := tx.Bucket([]byte("Wordlists"))
pg := p.Bucket([]byte("Good"))
stats := pg.Stats()
gWords = uint64(stats.KeyN)
return nil
})
return gTotal, jTotal, gWords, jWords
}