mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: fix reuse pendingMetricRow (#4049)
This commit is contained in:
parent
286697b8b6
commit
03bde173b7
1 changed files with 10 additions and 5 deletions
|
@ -1959,7 +1959,8 @@ type pendingMetricRows struct {
|
|||
}
|
||||
|
||||
func (pmrs *pendingMetricRows) reset() {
|
||||
for _, pmr := range pmrs.pmrs {
|
||||
for i := range pmrs.pmrs {
|
||||
pmr := &pmrs.pmrs[i]
|
||||
pmr.MetricName = nil
|
||||
pmr.mr = nil
|
||||
}
|
||||
|
@ -1983,10 +1984,14 @@ func (pmrs *pendingMetricRows) addRow(mr *MetricRow) error {
|
|||
pmrs.lastMetricName = pmrs.metricNamesBuf[metricNamesBufLen:]
|
||||
pmrs.lastMetricNameRaw = mr.MetricNameRaw
|
||||
}
|
||||
pmrs.pmrs = append(pmrs.pmrs, pendingMetricRow{
|
||||
MetricName: pmrs.lastMetricName,
|
||||
mr: mr,
|
||||
})
|
||||
if cap(pmrs.pmrs) > len(pmrs.pmrs) {
|
||||
pmrs.pmrs = pmrs.pmrs[:len(pmrs.pmrs)+1]
|
||||
} else {
|
||||
pmrs.pmrs = append(pmrs.pmrs, pendingMetricRow{})
|
||||
}
|
||||
pmr := &pmrs.pmrs[len(pmrs.pmrs)-1]
|
||||
pmr.MetricName = pmrs.lastMetricName
|
||||
pmr.mr = mr
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue