From c75c8f8329758f82279d62b483a50c2fae00c283 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 24 Jun 2024 21:06:50 +0100 Subject: [PATCH] Refactoring: extract getSeriesChunks Signed-off-by: Bryan Boreham --- tsdb/head_read.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tsdb/head_read.go b/tsdb/head_read.go index c8b394be8..ff9345fa0 100644 --- a/tsdb/head_read.go +++ b/tsdb/head_read.go @@ -200,9 +200,15 @@ func (h *headIndexReader) Series(ref storage.SeriesRef, builder *labels.ScratchB *chks = (*chks)[:0] + getSeriesChunks(s, h.mint, h.maxt, chks) + + return nil +} + +func getSeriesChunks(s *memSeries, mint, maxt int64, chks *[]chunks.Meta) { for i, c := range s.mmappedChunks { // Do not expose chunks that are outside of the specified range. - if !c.OverlapsClosedInterval(h.mint, h.maxt) { + if !c.OverlapsClosedInterval(mint, maxt) { continue } *chks = append(*chks, chunks.Meta{ @@ -223,7 +229,7 @@ func (h *headIndexReader) Series(ref storage.SeriesRef, builder *labels.ScratchB } else { maxTime = chk.maxTime } - if chk.OverlapsClosedInterval(h.mint, h.maxt) { + if chk.OverlapsClosedInterval(mint, maxt) { *chks = append(*chks, chunks.Meta{ MinTime: chk.minTime, MaxTime: maxTime, @@ -233,8 +239,6 @@ func (h *headIndexReader) Series(ref storage.SeriesRef, builder *labels.ScratchB j++ } } - - return nil } // headChunkID returns the HeadChunkID referred to by the given position.