Move stalness check into a function

This commit is contained in:
Brian Brazil 2017-04-19 11:54:38 +01:00
parent 80b40e6d91
commit a5cf25743c
3 changed files with 13 additions and 4 deletions

View File

@ -13,7 +13,15 @@
package value
var (
import (
"math"
)
const (
NormalNaN uint64 = 0x7ff8000000000001 // A quiet NaN. This is also math.NaN().
StaleNaN uint64 = 0x7ff4000000000000 // A signalling NaN, starting 01 to allow for expansion.
)
func IsStaleNaN(v float64) bool {
return math.Float64bits(v) == StaleNaN
}

View File

@ -757,7 +757,7 @@ func (ev *evaluator) vectorSelector(node *VectorSelector) Vector {
continue
}
}
if math.Float64bits(v) == value.StaleNaN {
if value.IsStaleNaN(v) {
continue
}
vec = append(vec, Sample{
@ -830,7 +830,7 @@ func (ev *evaluator) matrixSelector(node *MatrixSelector) Matrix {
buf := it.Buffer()
for buf.Next() {
t, v := buf.At()
if math.Float64bits(v) == value.StaleNaN {
if value.IsStaleNaN(v) {
continue
}
// Values in the buffer are guaranteed to be smaller than maxt.
@ -840,7 +840,7 @@ func (ev *evaluator) matrixSelector(node *MatrixSelector) Matrix {
}
// The seeked sample might also be in the range.
t, v = it.Values()
if t == maxt && math.Float64bits(v) != value.StaleNaN {
if t == maxt && !value.IsStaleNaN(v) {
allPoints = append(allPoints, Point{T: t, V: v})
}

View File

@ -423,6 +423,7 @@ type scrapeLoop struct {
appender func() storage.Appender
reportAppender func() storage.Appender
// TODO: Keep only the values from the last scrape to avoid a memory leak.
refCache map[string]uint64 // Parsed string to ref.
lsetCache map[uint64]lsetCacheEntry // Ref to labelset and string
samplesInPreviousScrape map[string]labels.Labels