mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-12 16:44:05 -08:00
GetRefByhash will query a label's ref with hash value rather than lset.Hash().
Signed-off-by: tanghengjian <1040104807@qq.com>
This commit is contained in:
parent
a5feccae6e
commit
982007ecab
|
@ -237,7 +237,8 @@ type GetRef interface {
|
||||||
// Returns reference number that can be used to pass to Appender.Append(),
|
// 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().
|
// 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.
|
// 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
|
// ExemplarAppender provides an interface for adding samples to exemplar storage, which
|
||||||
|
|
|
@ -983,9 +983,9 @@ type dbAppender struct {
|
||||||
|
|
||||||
var _ storage.GetRef = dbAppender{}
|
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 {
|
if g, ok := a.Appender.(storage.GetRef); ok {
|
||||||
return g.GetRef(lset)
|
return g.GetRef(lset, hash)
|
||||||
}
|
}
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,9 +86,9 @@ func (h *Head) initTime(t int64) {
|
||||||
h.maxTime.CompareAndSwap(math.MinInt64, t)
|
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 {
|
if g, ok := a.app.(storage.GetRef); ok {
|
||||||
return g.GetRef(lset)
|
return g.GetRef(lset, hash)
|
||||||
}
|
}
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
@ -455,8 +455,8 @@ func (a *headAppender) UpdateMetadata(ref storage.SeriesRef, lset labels.Labels,
|
||||||
|
|
||||||
var _ storage.GetRef = &headAppender{}
|
var _ storage.GetRef = &headAppender{}
|
||||||
|
|
||||||
func (a *headAppender) GetRef(lset labels.Labels) (storage.SeriesRef, labels.Labels) {
|
func (a *headAppender) GetRef(lset labels.Labels, hash uint64) (storage.SeriesRef, labels.Labels) {
|
||||||
s := a.head.series.getByHash(lset.Hash(), lset)
|
s := a.head.series.getByHash(hash, lset)
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue