Compute total db size from stats

pull/7/head
Martin Boehm 2018-06-04 13:24:40 +02:00
parent 4f42d2f1d6
commit cea1df9365
2 changed files with 11 additions and 1 deletions

View File

@ -178,7 +178,7 @@ func main() {
if err != nil {
glog.Error("internalState: ", err)
}
glog.Info("DB size on disk: ", index.DatabaseSizeOnDisk())
glog.Info("DB size on disk: ", index.DatabaseSizeOnDisk(), ", DB size as computed: ", internalState.DBSizeTotal())
return
}

View File

@ -113,6 +113,16 @@ func (is *InternalState) SetDBColumnStats(c int, rowsDiff int64, keysSumDiff int
is.DbColumns[c].ValuesSum = valuesSumDiff
}
func (is *InternalState) DBSizeTotal() int64 {
is.mux.Lock()
defer is.mux.Unlock()
total := int64(0)
for _, c := range is.DbColumns {
total += c.KeysSum + c.ValuesSum
}
return total
}
func (is *InternalState) Pack() ([]byte, error) {
is.mux.Lock()
defer is.mux.Unlock()