mirror of https://github.com/hak5/bolt.git
Copy the free pages stats from the receiver
parent
d1a77a9c82
commit
8c386e72f3
4
db.go
4
db.go
|
@ -579,6 +579,10 @@ func (s *Stats) Sub(other *Stats) Stats {
|
|||
return *s
|
||||
}
|
||||
var diff Stats
|
||||
diff.FreePageN = s.FreePageN
|
||||
diff.PendingPageN = s.PendingPageN
|
||||
diff.FreeAlloc = s.FreeAlloc
|
||||
diff.FreelistInuse = s.FreelistInuse
|
||||
diff.TxN = other.TxN - s.TxN
|
||||
diff.TxStats = s.TxStats.Sub(&other.TxStats)
|
||||
return diff
|
||||
|
|
|
@ -354,9 +354,13 @@ func TestDB_String(t *testing.T) {
|
|||
func TestDBStats_Sub(t *testing.T) {
|
||||
var a, b Stats
|
||||
a.TxStats.PageCount = 3
|
||||
a.FreePageN = 4
|
||||
b.TxStats.PageCount = 10
|
||||
b.FreePageN = 14
|
||||
diff := b.Sub(&a)
|
||||
assert.Equal(t, 7, diff.TxStats.PageCount)
|
||||
// free page stats are copied from the receiver and not subtracted
|
||||
assert.Equal(t, 14, diff.FreePageN)
|
||||
}
|
||||
|
||||
// Ensure that meta with bad magic is invalid.
|
||||
|
|
Loading…
Reference in New Issue