head: Rename highTimestamp to maxt

`maxt` seems more consistent with `mint` and other uses of `maxt`
elsewhere in the code, if I've understand the intent correctly.
This commit is contained in:
Matt Bostock 2018-02-21 16:01:12 +00:00
parent 494acd3070
commit 55ea5ae6b1

13
head.go
View file

@ -451,8 +451,8 @@ func (h *Head) appender() *headAppender {
return &headAppender{ return &headAppender{
head: h, head: h,
mint: h.MaxTime() - h.chunkRange/2, mint: h.MaxTime() - h.chunkRange/2,
maxt: math.MinInt64,
samples: h.getAppendBuffer(), samples: h.getAppendBuffer(),
highTimestamp: math.MinInt64,
} }
} }
@ -470,11 +470,10 @@ func (h *Head) putAppendBuffer(b []RefSample) {
type headAppender struct { type headAppender struct {
head *Head head *Head
mint int64 mint, maxt int64
series []RefSeries series []RefSeries
samples []RefSample samples []RefSample
highTimestamp int64
} }
func (a *headAppender) Add(lset labels.Labels, t int64, v float64) (uint64, error) { func (a *headAppender) Add(lset labels.Labels, t int64, v float64) (uint64, error) {
@ -508,8 +507,8 @@ func (a *headAppender) AddFast(ref uint64, t int64, v float64) error {
if t < a.mint { if t < a.mint {
return ErrOutOfBounds return ErrOutOfBounds
} }
if t > a.highTimestamp { if t > a.maxt {
a.highTimestamp = t a.maxt = t
} }
a.samples = append(a.samples, RefSample{ a.samples = append(a.samples, RefSample{
@ -551,10 +550,10 @@ func (a *headAppender) Commit() error {
for { for {
ht := a.head.MaxTime() ht := a.head.MaxTime()
if a.highTimestamp <= ht { if a.maxt <= ht {
break break
} }
if atomic.CompareAndSwapInt64(&a.head.maxTime, ht, a.highTimestamp) { if atomic.CompareAndSwapInt64(&a.head.maxTime, ht, a.maxt) {
break break
} }
} }