diff --git a/storage/interface.go b/storage/interface.go index 9df4b75f5..22d3b4186 100644 --- a/storage/interface.go +++ b/storage/interface.go @@ -248,7 +248,8 @@ type GetRef interface { // Returns reference number that can be used to pass to Appender.Append(), // and a set of labels that will not cause another copy when passed to Appender.Append(). // 0 means the appender does not have a reference to this series. - GetRef(lset labels.Labels) (SeriesRef, labels.Labels) + // hash should be a hash of lset. + GetRef(lset labels.Labels, hash uint64) (SeriesRef, labels.Labels) } // ExemplarAppender provides an interface for adding samples to exemplar storage, which diff --git a/tsdb/db.go b/tsdb/db.go index def4442f5..d18f4fee6 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -998,9 +998,9 @@ type dbAppender struct { var _ storage.GetRef = dbAppender{} -func (a dbAppender) GetRef(lset labels.Labels) (storage.SeriesRef, labels.Labels) { +func (a dbAppender) GetRef(lset labels.Labels, hash uint64) (storage.SeriesRef, labels.Labels) { if g, ok := a.Appender.(storage.GetRef); ok { - return g.GetRef(lset) + return g.GetRef(lset, hash) } return 0, nil } diff --git a/tsdb/head_append.go b/tsdb/head_append.go index a3b5027ea..8de71114f 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -98,9 +98,9 @@ func (h *Head) initTime(t int64) { h.maxTime.CompareAndSwap(math.MinInt64, t) } -func (a *initAppender) GetRef(lset labels.Labels) (storage.SeriesRef, labels.Labels) { +func (a *initAppender) GetRef(lset labels.Labels, hash uint64) (storage.SeriesRef, labels.Labels) { if g, ok := a.app.(storage.GetRef); ok { - return g.GetRef(lset) + return g.GetRef(lset, hash) } return 0, nil } @@ -647,8 +647,8 @@ func checkHistogramBuckets(buckets []int64) (uint64, error) { var _ storage.GetRef = &headAppender{} -func (a *headAppender) GetRef(lset labels.Labels) (storage.SeriesRef, labels.Labels) { - s := a.head.series.getByHash(lset.Hash(), lset) +func (a *headAppender) GetRef(lset labels.Labels, hash uint64) (storage.SeriesRef, labels.Labels) { + s := a.head.series.getByHash(hash, lset) if s == nil { return 0, nil }