mirror of https://github.com/prometheus/prometheus
Remove leaky Appender abstraction for hashedAppend
parent
87d270fe11
commit
50791a412e
15
db.go
15
db.go
|
@ -459,19 +459,6 @@ func (a *dbAppender) Add(lset labels.Labels, t int64, v float64) (uint64, error)
|
|||
return ref | (uint64(h.generation) << 40), nil
|
||||
}
|
||||
|
||||
func (a *dbAppender) hashedAdd(hash uint64, lset labels.Labels, t int64, v float64) (uint64, error) {
|
||||
h, err := a.appenderFor(t)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
ref, err := h.hashedAdd(hash, lset, t, v)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
a.samples++
|
||||
return ref | (uint64(h.generation) << 40), nil
|
||||
}
|
||||
|
||||
func (a *dbAppender) AddFast(ref uint64, t int64, v float64) error {
|
||||
// We store the head generation in the 4th byte and use it to reject
|
||||
// stale references.
|
||||
|
@ -809,7 +796,7 @@ func (a *partitionedAppender) Add(lset labels.Labels, t int64, v float64) (uint6
|
|||
h := lset.Hash()
|
||||
p := h >> (64 - a.db.partitionPow)
|
||||
|
||||
ref, err := a.partitions[p].hashedAdd(h, lset, t, v)
|
||||
ref, err := a.partitions[p].Add(lset, t, v)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
4
head.go
4
head.go
|
@ -223,10 +223,8 @@ type refdSample struct {
|
|||
}
|
||||
|
||||
func (a *headAppender) Add(lset labels.Labels, t int64, v float64) (uint64, error) {
|
||||
return a.hashedAdd(lset.Hash(), lset, t, v)
|
||||
}
|
||||
hash := lset.Hash()
|
||||
|
||||
func (a *headAppender) hashedAdd(hash uint64, lset labels.Labels, t int64, v float64) (uint64, error) {
|
||||
if ms := a.get(hash, lset); ms != nil {
|
||||
return uint64(ms.ref), a.AddFast(uint64(ms.ref), t, v)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue