From ebf9a6dd16db731f925ec9f63efa4c05e05f63b2 Mon Sep 17 00:00:00 2001 From: Thejas-bhat <35959007+Thejas-bhat@users.noreply.github.com> Date: Fri, 17 Mar 2023 22:05:40 +0530 Subject: [PATCH] Including the IO stats as part of metadata (#1774) * setting the total bytes written as an internal key in bolt * bug fix, nil pointer deref --- index/scorch/persister.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index/scorch/persister.go b/index/scorch/persister.go index e82e441e6..b90899f25 100644 --- a/index/scorch/persister.go +++ b/index/scorch/persister.go @@ -543,6 +543,13 @@ func prepareBoltSnapshot(snapshot *IndexSnapshot, tx *bolt.Tx, path string, } } + if snapshot.parent != nil { + val := make([]byte, 8) + bytesWritten := atomic.LoadUint64(&snapshot.parent.stats.TotBytesWrittenAtIndexTime) + binary.LittleEndian.PutUint64(val, bytesWritten) + internalBucket.Put(TotBytesWrittenKey, val) + } + var filenames []string newSegmentPaths := make(map[uint64]string) @@ -697,6 +704,7 @@ var boltMetaDataKey = []byte{'m'} var boltMetaDataSegmentTypeKey = []byte("type") var boltMetaDataSegmentVersionKey = []byte("version") var boltMetaDataTimeStamp = []byte("timeStamp") +var TotBytesWrittenKey = []byte("TotBytesWritten") func (s *Scorch) loadFromBolt() error { return s.rootBolt.View(func(tx *bolt.Tx) error {