Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 6dbebae

Browse files
committed
PR feedback
1 parent 2a8e41c commit 6dbebae

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

mdata/cache/accnt/flat_accnt.go

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ func (a *FlatAccnt) HitChunk(metric schema.AMKey, ts uint32) {
137137
a.act(evnt_hit_chnk, &HitPayload{metric, ts})
138138
}
139139
func (a *FlatAccnt) HitChunks(metric schema.AMKey, chunks []chunk.IterGen) {
140+
if len(chunks) == 0 {
141+
return
142+
}
140143
a.act(evnt_hit_chnks, &HitsPayload{metric, chunks})
141144
}
142145

mdata/cache/ccache_metric.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (mc *CCacheMetric) AddRange(prev uint32, itergens []chunk.IterGen) {
154154
if _, ok := mc.chunks[ts]; !ok {
155155

156156
// if nextTs() can't figure out the end date it returns ts
157-
next := mc.nextTsCore(itergen, ts, prev, 0)
157+
next := mc.nextTsCore(itergen, prev, 0)
158158
if next == ts {
159159
next = 0
160160
} else {
@@ -231,12 +231,7 @@ func (mc *CCacheMetric) Add(prev uint32, itergen chunk.IterGen) {
231231
}
232232
}
233233

234-
mc.addKey(ts)
235-
236-
return
237-
}
238-
239-
func (mc *CCacheMetric) addKey(ts uint32) {
234+
// assure key is added to mc.keys
240235

241236
// if no keys yet, just add it and it's sorted
242237
if len(mc.keys) == 0 {
@@ -266,17 +261,17 @@ func (mc *CCacheMetric) generateKeys() {
266261
// assumes we already have at least a read lock
267262
func (mc *CCacheMetric) nextTs(ts uint32) uint32 {
268263
chunk := mc.chunks[ts]
269-
return mc.nextTsCore(chunk.Itgen, chunk.Ts, chunk.Prev, chunk.Next)
264+
return mc.nextTsCore(chunk.Itgen, chunk.Prev, chunk.Next)
270265
}
271266

272267
// nextTsCore returns the ts of the next chunk, given a chunks key properties
273268
// (to the extent we know them). It guesses if necessary.
274269
// assumes we already have at least a read lock
275-
func (mc *CCacheMetric) nextTsCore(itgen chunk.IterGen, ts, prev, next uint32) uint32 {
270+
func (mc *CCacheMetric) nextTsCore(itgen chunk.IterGen, prev, next uint32) uint32 {
276271
span := itgen.Span
277272
if span > 0 {
278273
// if the chunk is span-aware we don't need anything else
279-
return ts + span
274+
return itgen.Ts + span
280275
}
281276

282277
// if chunk has a next chunk, then that's the ts we need
@@ -285,10 +280,10 @@ func (mc *CCacheMetric) nextTsCore(itgen chunk.IterGen, ts, prev, next uint32) u
285280
}
286281
// if chunk has no next chunk, but has a previous one, we assume the length of this one is same as the previous one
287282
if prev != 0 {
288-
return ts + (ts - prev)
283+
return itgen.Ts + (itgen.Ts - prev)
289284
}
290285
// if a chunk has no next and no previous chunk we have to assume it's length is 0
291-
return ts
286+
return itgen.Ts
292287
}
293288

294289
// lastTs returns the last Ts of this metric cache

0 commit comments

Comments
 (0)