Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
carrieedwards committed Oct 18, 2023
1 parent 02e37db commit 31e8dc0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
7 changes: 4 additions & 3 deletions tsdb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7323,19 +7323,20 @@ func requireEqualSamples(t *testing.T, expected, actual map[string][]chunks.Samp
expectedSample := s
actualSample := actualItem[i]
require.Equal(t, expectedSample.Type().String(), actualSample.Type().String(), "Different types for %s[%d]", name, i)
if s.H() != nil {
switch {
case s.H() != nil:
expectedHist := expectedSample.H()
actualHist := actualSample.H()
expectedHist.CounterResetHint = histogram.UnknownCounterReset
actualHist.CounterResetHint = histogram.UnknownCounterReset
require.Equal(t, expectedHist, actualHist, "Unexpected sample for %s[%d]", name, i)
} else if s.FH() != nil {
case s.FH() != nil:
expectedHist := expectedSample.FH()
actualHist := actualSample.FH()
expectedHist.CounterResetHint = histogram.UnknownCounterReset
actualHist.CounterResetHint = histogram.UnknownCounterReset
require.Equal(t, expectedHist, actualHist, "Unexpected sample for %s[%d]", name, i)
} else {
default:
require.Equal(t, expectedSample, expectedSample, "Unexpected sample for %s[%d]", name, i)
}
}
Expand Down
10 changes: 8 additions & 2 deletions tsdb/head_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,18 @@ func GetBytes(encoding chunkenc.Encoding, it chunkenc.Iterator) []byte {
prevHApp, _ := app.(*chunkenc.HistogramAppender)
t, v := it.AtHistogram()
// TODO(carrieedwards): check if logic for new chunk allocation is needed (see ToEncodedChunks method)
app.AppendHistogram(prevHApp, t, v, false)
_, _, _, err := app.AppendHistogram(prevHApp, t, v, false)
if err != nil {
panic(err)
}
case chunkenc.ValFloatHistogram:
prevHApp, _ := app.(*chunkenc.FloatHistogramAppender)
t, v := it.AtFloatHistogram()
// TODO(carrieedwards): check if logic for new chunk allocation is needed (see ToEncodedChunks method)
app.AppendFloatHistogram(prevHApp, t, v, false)
_, _, _, err := app.AppendFloatHistogram(prevHApp, t, v, false)
if err != nil {
panic(err)
}
}
}
return xc.Bytes()
Expand Down
8 changes: 5 additions & 3 deletions tsdb/head_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ package tsdb

import (
"fmt"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/tsdb/tsdbutil"
"github.com/stretchr/testify/require"
"sync"
"testing"

"github.com/stretchr/testify/require"

"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/tsdb/tsdbutil"

"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/tsdb/chunkenc"
"github.com/prometheus/prometheus/tsdb/chunks"
Expand Down
10 changes: 5 additions & 5 deletions tsdb/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5127,7 +5127,7 @@ func TestOOOAppendWithNoSeries(t *testing.T) {
}
}

func testOOOAppendWithNoSeries(t *testing.T, appendFunc func(appender storage.Appender, lbls labels.Labels, ts int64, value int64) (storage.SeriesRef, error, sample)) {
func testOOOAppendWithNoSeries(t *testing.T, appendFunc func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, error, sample)) {
dir := t.TempDir()
wal, err := wlog.NewSize(nil, nil, filepath.Join(dir, "wal"), 32768, wlog.CompressionSnappy)
require.NoError(t, err)
Expand Down Expand Up @@ -5702,14 +5702,14 @@ func TestHeadDetectsDuplicateSampleAtSizeLimit(t *testing.T) {

type sampleTypeScenario struct {
sampleType string
appendFunc func(appender storage.Appender, lbls labels.Labels, ts int64, value int64) (storage.SeriesRef, error, sample)
appendFunc func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, error, sample)
sampleFunc func(ts, value int64) sample
}

var sampleTypeScenarios = map[string]sampleTypeScenario{
"float": {
sampleType: sampleMetricTypeFloat,
appendFunc: func(appender storage.Appender, lbls labels.Labels, ts int64, value int64) (storage.SeriesRef, error, sample) {
appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, error, sample) {
s := sample{t: ts, f: float64(value)}
ref, err := appender.Append(0, lbls, ts, s.f)
return ref, err, s
Expand All @@ -5720,7 +5720,7 @@ var sampleTypeScenarios = map[string]sampleTypeScenario{
},
"integer histogram": {
sampleType: sampleMetricTypeHistogram,
appendFunc: func(appender storage.Appender, lbls labels.Labels, ts int64, value int64) (storage.SeriesRef, error, sample) {
appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, error, sample) {
s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))}
ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil)
return ref, err, s
Expand All @@ -5731,7 +5731,7 @@ var sampleTypeScenarios = map[string]sampleTypeScenario{
},
"float histogram": {
sampleType: sampleMetricTypeHistogram,
appendFunc: func(appender storage.Appender, lbls labels.Labels, ts int64, value int64) (storage.SeriesRef, error, sample) {
appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, error, sample) {
s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))}
ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh)
return ref, err, s
Expand Down
4 changes: 2 additions & 2 deletions tsdb/head_wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ func (h *Head) loadWBL(r *wlog.Reader, multiRef map[chunks.HeadSeriesRef]chunks.
}
samples = samples[m:]
}
histogramSamplesPool.Put(v)
histogramSamplesPool.Put(&v)
case []record.RefFloatHistogramSample:
samples := v
// We split up the samples into chunks of 5000 samples or less.
Expand Down Expand Up @@ -893,7 +893,7 @@ func (h *Head) loadWBL(r *wlog.Reader, multiRef map[chunks.HeadSeriesRef]chunks.
}
samples = samples[m:]
}
floatHistogramSamplesPool.Put(v)
floatHistogramSamplesPool.Put(&v)
default:
panic(fmt.Errorf("unexpected decodedCh type: %T", d))
}
Expand Down
3 changes: 2 additions & 1 deletion tsdb/ooo_head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
package tsdb

import (
"github.com/prometheus/prometheus/tsdb/tsdbutil"
"testing"

"github.com/prometheus/prometheus/tsdb/tsdbutil"

"github.com/stretchr/testify/require"
)

Expand Down

0 comments on commit 31e8dc0

Please sign in to comment.