From fe4e31ef552ce64acd5fb23b2581aed5b71274d7 Mon Sep 17 00:00:00 2001 From: Carrie Edwards Date: Tue, 5 May 2026 09:52:50 -0700 Subject: [PATCH] Linting Signed-off-by: Carrie Edwards --- tsdb/chunkenc/float_histogram_st.go | 20 ++++++++++---------- tsdb/chunkenc/float_histogram_st_test.go | 2 +- tsdb/chunkenc/histogram_st.go | 15 ++++++++------- tsdb/chunkenc/histogram_st_test.go | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tsdb/chunkenc/float_histogram_st.go b/tsdb/chunkenc/float_histogram_st.go index 62f01598e0..87b801115c 100644 --- a/tsdb/chunkenc/float_histogram_st.go +++ b/tsdb/chunkenc/float_histogram_st.go @@ -77,10 +77,10 @@ func (c *FloatHistogramSTChunk) Appender() (Appender, error) { if len(c.b.stream) == histogramSTHeaderSize { return &FloatHistogramSTAppender{ FloatHistogramAppender: FloatHistogramAppender{ - b: &c.b, - t: math.MinInt64, - sum: xorValue{leading: 0xff}, - cnt: xorValue{leading: 0xff}, + b: &c.b, + t: math.MinInt64, + sum: xorValue{leading: 0xff}, + cnt: xorValue{leading: 0xff}, zCnt: xorValue{leading: 0xff}, }, }, nil @@ -183,8 +183,8 @@ type FloatHistogramSTAppender struct { func (a *FloatHistogramSTAppender) encodeST(prevT, st int64) { num := binary.BigEndian.Uint16(a.b.bytes()) - switch { - case num == 1: // First sample (count was just incremented from 0). + switch num { + case 1: // First sample (count was just incremented from 0). if st != 0 { buf := make([]byte, binary.MaxVarintLen64) for _, b := range buf[:binary.PutVarint(buf, a.t-st)] { @@ -193,7 +193,7 @@ func (a *FloatHistogramSTAppender) encodeST(prevT, st int64) { a.firstSTKnown = true writeHeaderFirstSTKnown(a.b.bytes()[histogramSTHeaderSize-1:]) } - case num == 2: // Second sample. + case 2: // Second sample. if st != a.st { stDiff := prevT - st a.firstSTChangeOn = 1 @@ -476,8 +476,8 @@ func (it *floatHistogramSTIterator) Seek(t int64) ValueType { // numRead is the number of samples read so far (already incremented by floatHistogramIterator.Next()). // prevT is the timestamp of the previous sample (before floatHistogramIterator.Next() updated it.t). func (it *floatHistogramSTIterator) decodeST(numRead uint16, prevT int64) error { - switch { - case numRead == 1: // After sample 0. + switch numRead { + case 1: // After sample 0. if it.firstSTKnown { stDiff, err := it.br.readVarint() if err != nil { @@ -486,7 +486,7 @@ func (it *floatHistogramSTIterator) decodeST(numRead uint16, prevT int64) error it.stDiff = stDiff it.st = it.t - stDiff } - case numRead == 2: // After sample 1. + case 2: // After sample 1. if it.firstSTChangeOn == 1 { sdod, err := readVarbitInt(&it.br) if err != nil { diff --git a/tsdb/chunkenc/float_histogram_st_test.go b/tsdb/chunkenc/float_histogram_st_test.go index 43b038d3f2..6b0d82cee5 100644 --- a/tsdb/chunkenc/float_histogram_st_test.go +++ b/tsdb/chunkenc/float_histogram_st_test.go @@ -390,7 +390,7 @@ func TestFloatHistogramSTChunkStaleSamples(t *testing.T) { require.NoError(t, err) _, _, app, err = app.AppendFloatHistogram(nil, 200, 2000, stale1, false) require.NoError(t, err) - _, _, app, err = app.AppendFloatHistogram(nil, 0, 3000, stale2, false) + _, _, _, err = app.AppendFloatHistogram(nil, 0, 3000, stale2, false) require.NoError(t, err) it := c.Iterator(nil) diff --git a/tsdb/chunkenc/histogram_st.go b/tsdb/chunkenc/histogram_st.go index 60f98465c4..a45cc7ee02 100644 --- a/tsdb/chunkenc/histogram_st.go +++ b/tsdb/chunkenc/histogram_st.go @@ -80,7 +80,8 @@ func (c *HistogramSTChunk) Appender() (Appender, error) { HistogramAppender: HistogramAppender{ b: &c.b, t: math.MinInt64, - leading: 0xff}, + leading: 0xff, + }, }, nil } @@ -172,8 +173,8 @@ type HistogramSTAppender struct { func (a *HistogramSTAppender) encodeST(prevT, st int64) { num := binary.BigEndian.Uint16(a.b.bytes()) - switch { - case num == 1: // First sample (count was just incremented from 0). + switch num { + case 1: // First sample (count was just incremented from 0). if st != 0 { buf := make([]byte, binary.MaxVarintLen64) for _, b := range buf[:binary.PutVarint(buf, a.t-st)] { @@ -182,7 +183,7 @@ func (a *HistogramSTAppender) encodeST(prevT, st int64) { a.firstSTKnown = true writeHeaderFirstSTKnown(a.b.bytes()[histogramSTHeaderSize-1:]) } - case num == 2: // Second sample. + case 2: // Second sample. if st != a.st { stDiff := prevT - st a.firstSTChangeOn = 1 @@ -465,8 +466,8 @@ func (it *histogramSTIterator) Seek(t int64) ValueType { // numRead is the number of samples read so far (already incremented by histogramIterator.Next()). // prevT is the timestamp of the previous sample (before histogramIterator.Next() updated it.t). func (it *histogramSTIterator) decodeST(numRead uint16, prevT int64) error { - switch { - case numRead == 1: // After sample 0. + switch numRead { + case 1: // After sample 0. if it.firstSTKnown { stDiff, err := it.br.readVarint() if err != nil { @@ -475,7 +476,7 @@ func (it *histogramSTIterator) decodeST(numRead uint16, prevT int64) error { it.stDiff = stDiff it.st = it.t - stDiff } - case numRead == 2: // After sample 1. + case 2: // After sample 1. if it.firstSTChangeOn == 1 { sdod, err := readVarbitInt(&it.br) if err != nil { diff --git a/tsdb/chunkenc/histogram_st_test.go b/tsdb/chunkenc/histogram_st_test.go index ee8f68730b..4853fcb647 100644 --- a/tsdb/chunkenc/histogram_st_test.go +++ b/tsdb/chunkenc/histogram_st_test.go @@ -387,7 +387,7 @@ func TestHistogramSTChunkStaleSamples(t *testing.T) { require.NoError(t, err) _, _, app, err = app.AppendHistogram(nil, 200, 2000, stale1, false) require.NoError(t, err) - _, _, app, err = app.AppendHistogram(nil, 0, 3000, stale2, false) + _, _, _, err = app.AppendHistogram(nil, 0, 3000, stale2, false) require.NoError(t, err) it := c.Iterator(nil)