-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.go
More file actions
34 lines (28 loc) · 784 Bytes
/
stats.go
File metadata and controls
34 lines (28 loc) · 784 Bytes
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
package riverdb
// Stats represents a simple statistics information of db at a moment
type Stats struct {
// number of key in db
KeyNums int64
// number of values in db, due to bitcask model is append-only, it usually greater than KeyNums.
// normally, result of RecordNums / KeyNums can be used to determine if is needed to merge the wal files
RecordNums int64
// real data size
DataSize int64
// hint file size
HintSize int64
}
func (db *DB) Stats() Stats {
if db.flag.Check(closed) {
return Stats{}
}
if !db.mu.TryRLock() {
return Stats{}
}
defer db.mu.RUnlock()
var stats Stats
stats.KeyNums = int64(db.index.Size())
stats.RecordNums = db.numOfRecord
stats.DataSize = db.data.Stat().SizeOfWal
stats.HintSize = db.hint.Stat().SizeOfWal
return stats
}