@@ -37,6 +37,7 @@ func (mc *CCacheMetric) Init(MKey schema.MKey, prev uint32, itergen chunk.IterGe
37
37
mc .MKey = MKey
38
38
}
39
39
40
+ // Del deletes chunks for the given timestamp
40
41
func (mc * CCacheMetric ) Del (ts uint32 ) int {
41
42
mc .Lock ()
42
43
defer mc .Unlock ()
@@ -121,7 +122,7 @@ func (mc *CCacheMetric) Add(prev uint32, itergen chunk.IterGen) {
121
122
return
122
123
}
123
124
124
- // generate sorted slice of all chunk timestamps
125
+ // generateKeys generates sorted slice of all chunk timestamps
125
126
// assumes we have at least read lock
126
127
func (mc * CCacheMetric ) generateKeys () {
127
128
keys := make ([]uint32 , 0 , len (mc .chunks ))
@@ -242,20 +243,21 @@ func (mc *CCacheMetric) searchBackward(from, until uint32, res *CCSearchResult)
242
243
}
243
244
}
244
245
246
+ // Search searches for the given metric
247
+ //
245
248
// the idea of this method is that we first look for the chunks where the
246
249
// "from" and "until" ts are in. then we seek from the "from" towards "until"
247
250
// and add as many cunks as possible to the result, if this did not result
248
251
// in all chunks necessary to serve the request we do the same in the reverse
249
252
// order from "until" to "from"
250
253
// if the first seek in chronological direction already ends up with all the
251
254
// chunks we need to serve the request, the second one can be skipped.
252
-
255
+ //
253
256
// EXAMPLE:
254
257
// from ts: |
255
258
// until ts: |
256
259
// cache: |---|---|---| | | | | |---|---|---|---|---|---|
257
260
// chunks returned: |---| |---|---|---|
258
- //
259
261
func (mc * CCacheMetric ) Search (ctx context.Context , metric schema.AMKey , res * CCSearchResult , from , until uint32 ) {
260
262
mc .RLock ()
261
263
defer mc .RUnlock ()
0 commit comments