Move stalness check into a function

pull/2752/head
Brian Brazil 8 years ago
parent 80b40e6d91
commit a5cf25743c

@ -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
}

@ -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})
}

@ -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

Loading…
Cancel
Save