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

Commit 260c7eb

Browse files
committed
sean feedback 2
1 parent 7198dfb commit 260c7eb

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

api/query_engine.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,20 @@ func planLowestResForMDPMulti(now, from, to uint32, reqs []models.Req) ([]models
258258

259259
var validIntervalss [][]uint32
260260

261-
for i := range reqs {
262-
req := &reqs[i]
261+
// first, find the unique set of retentions we're dealing with.
262+
retentions := make(map[uint16]struct{})
263+
for _, req := range reqs {
264+
retentions[req.SchemaId] = struct{}{}
265+
}
266+
267+
// now, extract the set of valid intervals from each retention
268+
// if a retention has no valid intervals, we can't satisfy the request
269+
for schemaID := range retentions {
263270
var ok bool
264-
rets := getRetentions(*req)
271+
rets := mdata.Schemas.Get(schemaID).Retentions.Rets
265272
var validIntervals []uint32
266273
for _, ret := range rets {
267-
if ret.Ready <= from && req.TTL >= minTTL {
274+
if ret.Ready <= from && ret.MaxRetention() >= int(minTTL) {
268275
ok = true
269276
validIntervals = append(validIntervals, uint32(ret.SecondsPerPoint))
270277
}
@@ -285,6 +292,12 @@ func planLowestResForMDPMulti(now, from, to uint32, reqs []models.Req) ([]models
285292
}
286293
}
287294

295+
// now, we need to pick a combination of intervals from each interval set.
296+
// for each possibly combination of intervals, we compute the LCM interval.
297+
// if if the LCM interval honors maxInterval, we compute the score
298+
// the interval with the highest score wins.
299+
// note : we can probably make this more performant by iterating over
300+
// the retentions, instead of over individual requests
288301
combos := util.AllCombinationsUint32(validIntervalss)
289302
var maxScore int
290303

devdocs/render-request-handling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* finds all series by fanning out the query patterns to all other shards.
1313
this gives basically idx.Node back. has the path, leaf, metricdefinition, schema/aggregation(rollup) settings, for each series, as well as on which node it can be found.
1414
* construct models.Req objects for each serie. this uses the MKey to identify series, also sets from/to, maxdatapoints, etc.
15-
* `planRequests`: this plans at all models.Req objects, which means decide which archive to read from, whether to apply normalization, etc
15+
* `planRequests`: this plans all models.Req objects, deciding which archive to read from, whether to apply normalization, etc.
1616
(see NOTES in expr directory for more info)
1717
* `getTargets`: gets the data from the local node and peer nodes based on the models.Req objects
1818
* `mergeSeries`: if there's multiple series with same name/tags, from, to and consolidator (e.g. because there's multiple series because users switched intervals), merge them together into one series

0 commit comments

Comments
 (0)