value.go
func (vlog *valueLog) populateDiscardStats() error {
	discardStatsKey := y.KeyWithTs(lfDiscardStatsKey, math.MaxUint64)
	vs, err := vlog.db.get(discardStatsKey)
	if err != nil {
		return err
	}

	// check if value is Empty
	if vs.Value == nil || len(vs.Value) == 0 {
		vlog.lfDiscardStats = &lfDiscardStats{m: make(map[uint32]int64)}
		return nil
	}

	var statsMap map[uint32]int64
	if err := json.Unmarshal(vs.Value, &statsMap); err != nil {
		return err
	}
	vlog.opt.Debugf("Value Log Discard stats: %v", statsMap)
	vlog.lfDiscardStats = &lfDiscardStats{m: statsMap}
	return nil
}
func (vlog *valueLog) populateDiscardStats() error {
	discardStatsKey := y.KeyWithTs(lfDiscardStatsKey, math.MaxUint64)
	vs, err := vlog.db.get(discardStatsKey)
	if err != nil {
		return err
	}

	// check if value is Empty
	if vs.Value == nil || len(vs.Value) == 0 {
		vlog.lfDiscardStats = &lfDiscardStats{m: make(map[uint32]int64)}
		return nil
	}

	var statsMap map[uint32]int64
	if err := json.Unmarshal(vs.Value, &statsMap); err != nil {
		return err
	}
	vlog.opt.Debugf("Value Log Discard stats: %v", statsMap)
	vlog.lfDiscardStats = &lfDiscardStats{m: statsMap}
	return nil
}
func ( vlog * valueLog ) populateDiscardStats ( ) error { discardStatsKey := y . KeyWithTs ( lfDiscardStatsKey , math . MaxUint64 ) vs , err := vlog . db . get ( discardStatsKey ) if err != nil { return err } // check if value is Empty if vs . Value == nil || len ( vs . Value ) == 0 { vlog . lfDiscardStats = & lfDiscardStats { m : make ( map [ uint32 ] int64 ) } return nil } var statsMap map [ uint32 ] int64 if err := json . Unmarshal ( vs . Value , & statsMap ) ; err != nil { return err } vlog . opt . Debugf ( " " , statsMap ) vlog . lfDiscardStats = & lfDiscardStats { m : statsMap } return nil }
// populateDiscardStats populates vlog.lfDiscardStats
// This function will be called while initializing valueLog
populateDiscardStats populates vlog . lfDiscardStats This function will be called while initializing valueLog