From e555469ba1f718498eb1a816772d22bdb1adbeac Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar Date: Wed, 28 Dec 2022 14:31:55 +0530 Subject: [PATCH] tsdb: Remove isHistogramSeries from memSeries Signed-off-by: Ganesh Vernekar --- tsdb/head.go | 4 ---- tsdb/head_append.go | 15 ++++++++++----- tsdb/head_wal.go | 2 -- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/tsdb/head.go b/tsdb/head.go index 37e12d8a4..8ec8a010d 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -1862,10 +1862,6 @@ type memSeries struct { // txs is nil if isolation is disabled. txs *txRing - // TODO(beorn7): The only reason we track this is to create a staleness - // marker as either histogram or float sample. Perhaps there is a better way. - isHistogramSeries bool - pendingCommit bool // Whether there are samples waiting to be committed to this series. } diff --git a/tsdb/head_append.go b/tsdb/head_append.go index e541f013f..72a57af3c 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -350,7 +350,7 @@ func (a *headAppender) Append(ref storage.SeriesRef, lset labels.Labels, t int64 } } - if value.IsStaleNaN(v) && s.isHistogramSeries { + if value.IsStaleNaN(v) && s.lastHistogramValue != nil { // TODO(marctc): do we have do to the same for float histograms? return a.AppendHistogram(ref, lset, t, &histogram.Histogram{Sum: v}, nil) } @@ -555,8 +555,12 @@ func (a *headAppender) AppendHistogram(ref storage.SeriesRef, lset labels.Labels if err != nil { return 0, err } - s.isHistogramSeries = true if created { + if h != nil { + s.lastHistogramValue = &histogram.Histogram{} + } else if fh != nil { + s.lastFloatHistogramValue = &histogram.FloatHistogram{} + } a.series = append(a.series, record.RefSeries{ Ref: s.ref, Labels: lset, @@ -1115,11 +1119,12 @@ func (s *memSeries) append(t int64, v float64, appendID uint64, chunkDiskMapper return sampleInOrder, chunkCreated } s.app.Append(t, v) - s.isHistogramSeries = false c.maxTime = t s.lastValue = v + s.lastHistogramValue = nil + s.lastFloatHistogramValue = nil if appendID > 0 { s.txs.add(appendID) @@ -1184,11 +1189,11 @@ func (s *memSeries) appendHistogram(t int64, h *histogram.Histogram, appendID ui } s.app.AppendHistogram(t, h) - s.isHistogramSeries = true c.maxTime = t s.lastHistogramValue = h + s.lastFloatHistogramValue = nil if appendID > 0 { s.txs.add(appendID) @@ -1252,11 +1257,11 @@ func (s *memSeries) appendFloatHistogram(t int64, fh *histogram.FloatHistogram, } s.app.AppendFloatHistogram(t, fh) - s.isHistogramSeries = true c.maxTime = t s.lastFloatHistogramValue = fh + s.lastHistogramValue = nil if appendID > 0 { s.txs.add(appendID) diff --git a/tsdb/head_wal.go b/tsdb/head_wal.go index df1896b25..97f2dcc14 100644 --- a/tsdb/head_wal.go +++ b/tsdb/head_wal.go @@ -605,7 +605,6 @@ func (wp *walSubsetProcessor) processWALSamples(h *Head, mmappedChunks, oooMmapp if s.T <= ms.mmMaxTime { continue } - ms.isHistogramSeries = false if s.T <= ms.mmMaxTime { continue } @@ -634,7 +633,6 @@ func (wp *walSubsetProcessor) processWALSamples(h *Head, mmappedChunks, oooMmapp unknownHistogramRefs++ continue } - ms.isHistogramSeries = true if s.t <= ms.mmMaxTime { continue }