From 278add90096c19b700bebee3dd5085e5fc4208e0 Mon Sep 17 00:00:00 2001 From: Jeanette Tan Date: Wed, 30 Aug 2023 01:43:20 +0800 Subject: [PATCH] Change float series custom trackers into maps as well --- pkg/ingester/activeseries/active_series.go | 25 ++++------------------ 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/pkg/ingester/activeseries/active_series.go b/pkg/ingester/activeseries/active_series.go index 209a0d5a1c5..45c1ff3e96c 100644 --- a/pkg/ingester/activeseries/active_series.go +++ b/pkg/ingester/activeseries/active_series.go @@ -66,7 +66,7 @@ type seriesStripe struct { mu sync.RWMutex refs map[storage.SeriesRef]seriesEntry active uint32 // Number of active entries in this stripe. Only decreased during purge or clear. - activeMatching []uint32 // Number of active entries in this stripe matching each matcher of the configured Matchers. + activeMatching map[uint16]uint32 // Number of active entries in this stripe matching each matcher of the configured Matchers. activeNativeHistograms uint32 // Number of active entries (only native histograms) in this stripe. Only decreased during purge or clear. activeMatchingNativeHistograms map[uint16]uint32 // Number of active entries (only native histograms) in this stripe matching each matcher of the configured Matchers. activeNativeHistogramBuckets uint32 // Number of buckets in active native histogram entries in this stripe. Only decreased during purge or clear. @@ -375,9 +375,7 @@ func (s *seriesStripe) clear() { s.active = 0 s.activeNativeHistograms = 0 s.activeNativeHistogramBuckets = 0 - for i := range s.activeMatching { - s.activeMatching[i] = 0 - } + s.activeMatching = reinitMap() s.activeMatchingNativeHistograms = reinitMap() s.activeMatchingNativeHistogramBuckets = reinitMap() } @@ -394,7 +392,7 @@ func (s *seriesStripe) reinitialize(asm *Matchers, deleted *deletedSeries) { s.activeNativeHistograms = 0 s.activeNativeHistogramBuckets = 0 s.matchers = asm - s.activeMatching = resizeAndClear(len(asm.MatcherNames()), s.activeMatching) + s.activeMatching = reinitMap() s.activeMatchingNativeHistograms = reinitMap() s.activeMatchingNativeHistogramBuckets = reinitMap() } @@ -412,7 +410,7 @@ func (s *seriesStripe) purge(keepUntil time.Time) { s.active = 0 s.activeNativeHistograms = 0 s.activeNativeHistogramBuckets = 0 - s.activeMatching = resizeAndClear(len(s.activeMatching), s.activeMatching) + s.activeMatching = reinitMap() s.activeMatchingNativeHistograms = reinitMap() s.activeMatchingNativeHistogramBuckets = reinitMap() @@ -488,21 +486,6 @@ func (s *seriesStripe) remove(ref storage.SeriesRef) { delete(s.refs, ref) } -func resizeAndClear(l int, prev []uint32) []uint32 { - if cap(prev) < l { - if l == 0 { - return nil - } - return make([]uint32, l) - } - - p := prev[:l] - for i := 0; i < l; i++ { - p[i] = 0 - } - return p -} - func reinitMap() map[uint16]uint32 { return make(map[uint16]uint32) }