Return empty string to signal non-caching
This commit is contained in:
parent
3410559c1b
commit
1e74c155eb
4
db.go
4
db.go
|
@ -80,6 +80,7 @@ type Appender interface {
|
|||
// Returned reference numbers are ephemeral and may be rejected in calls
|
||||
// to AddFast() at any point. Adding the sample via Add() returns a new
|
||||
// reference number.
|
||||
// If the reference is the empty string it must not be used for caching.
|
||||
Add(l labels.Labels, t int64, v float64) (string, error)
|
||||
|
||||
// Add adds a sample pair for the referenced series. It is generally faster
|
||||
|
@ -616,6 +617,9 @@ func (a *dbAppender) Add(lset labels.Labels, t int64, v float64) (string, error)
|
|||
}
|
||||
a.samples++
|
||||
|
||||
if ref == "" {
|
||||
return "", nil
|
||||
}
|
||||
return string(append(h.meta.ULID[:], ref...)), nil
|
||||
}
|
||||
|
||||
|
|
6
head.go
6
head.go
|
@ -450,7 +450,7 @@ func (a *headAppender) Add(lset labels.Labels, t int64, v float64) (string, erro
|
|||
// XXX(fabxc): there's no fast path for multiple samples for the same new series
|
||||
// in the same transaction. We always return the invalid empty ref. It's has not
|
||||
// been a relevant use case so far and is not worth the trouble.
|
||||
return nullRef, a.AddFast(string(refb), t, v)
|
||||
return "", a.AddFast(string(refb), t, v)
|
||||
}
|
||||
|
||||
// The series is completely new.
|
||||
|
@ -471,11 +471,9 @@ func (a *headAppender) Add(lset labels.Labels, t int64, v float64) (string, erro
|
|||
a.newHashes[hash] = ref
|
||||
binary.BigEndian.PutUint64(refb, ref)
|
||||
|
||||
return nullRef, a.AddFast(string(refb), t, v)
|
||||
return "", a.AddFast(string(refb), t, v)
|
||||
}
|
||||
|
||||
var nullRef = string([]byte{0, 0, 0, 0, 0, 0, 0, 0})
|
||||
|
||||
func (a *headAppender) AddFast(ref string, t int64, v float64) error {
|
||||
if len(ref) != 8 {
|
||||
return errors.Wrap(ErrNotFound, "invalid ref length")
|
||||
|
|
Loading…
Reference in New Issue