Skip to content

Commit

Permalink
Including the IO stats as part of metadata (#1774)
Browse files Browse the repository at this point in the history
* setting the total bytes written as an internal key in bolt

* bug fix, nil pointer deref
  • Loading branch information
Thejas-bhat authored Mar 17, 2023
1 parent cde1967 commit ebf9a6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index/scorch/persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ebf9a6d

Please sign in to comment.