Skip to content

Commit 5aaad72

Browse files
committed
Use constants for not-seen
1 parent 3225af5 commit 5aaad72

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

storage/prometheus/matrix_selector.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"github.com/prometheus/prometheus/util/annotations"
2929
)
3030

31+
const notSeenSentinel int64 = math.MinInt64
32+
3133
type matrixScanner struct {
3234
labels labels.Labels
3335
signature uint64
@@ -241,9 +243,9 @@ func (o *matrixSelector) loadSeries(ctx context.Context) error {
241243
labels: lbls,
242244
signature: s.Signature,
243245
iterator: s.Iterator(nil),
244-
lastSample: ringbuffer.Sample{T: math.MinInt64},
246+
lastSample: ringbuffer.Sample{T: notSeenSentinel},
245247
buffer: o.newBuffer(ctx),
246-
metricAppearedTs: math.MinInt64,
248+
metricAppearedTs: notSeenSentinel,
247249
}
248250
o.series[i] = lbls
249251
}
@@ -322,16 +324,15 @@ func (m *matrixScanner) selectPoints(
322324
mint = maxInt64(mint, m.buffer.MaxT()+1)
323325
if m.lastSample.T > mint {
324326
m.buffer.Push(m.lastSample.T, m.lastSample.V)
325-
m.lastSample.T = math.MinInt64
327+
m.lastSample.T = notSeenSentinel
326328
mint = maxInt64(mint, m.buffer.MaxT()+1)
327329
}
328330

329331
var (
330332
// The sample that we add for x-functions, -1 is a canary value for the situation
331333
// where we have no sample in the extended lookback delta
332-
extSample = ringbuffer.Sample{T: -1}
334+
extSample = ringbuffer.Sample{T: notSeenSentinel}
333335
)
334-
335336
for valType := m.iterator.Next(); valType != chunkenc.ValNone; valType = m.iterator.Next() {
336337
switch valType {
337338
case chunkenc.ValHistogram, chunkenc.ValFloatHistogram:
@@ -360,17 +361,17 @@ func (m *matrixScanner) selectPoints(
360361
if value.IsStaleNaN(v) {
361362
continue
362363
}
363-
if m.metricAppearedTs == math.MinInt64 {
364+
if m.metricAppearedTs == notSeenSentinel {
364365
m.metricAppearedTs = t
365366
}
366367
if t > maxt {
367368
m.lastSample.T, m.lastSample.V.F, m.lastSample.V.H = t, v, nil
368369
return nil
369370
}
370371
if t > mint {
371-
if extSample.T != -1 && isExtFunction {
372+
if extSample.T != notSeenSentinel && isExtFunction {
372373
m.buffer.Push(extSample.T, ringbuffer.Value{F: extSample.V.F})
373-
extSample.T = -1
374+
extSample.T = notSeenSentinel
374375
}
375376
m.buffer.Push(t, ringbuffer.Value{F: v})
376377
continue

0 commit comments

Comments
 (0)