MCPcopy Create free account
hub / github.com/cortexproject/cortex / getSortValueFromPair

Function getSortValueFromPair

pkg/querier/tripperware/merge.go:280–286  ·  view source on GitHub ↗

getSortValueFromPair gets the float value used for sorting from samples. If float sample, use sample value. If histogram sample, use histogram sum. This is the same behavior as Prometheus https://github.com/prometheus/prometheus/blob/v2.53.0/promql/functions.go#L1595.

(samples []*pair, i int)

Source from the content-addressed store, hash-verified

278// If float sample, use sample value. If histogram sample, use histogram sum.
279// This is the same behavior as Prometheus https://github.com/prometheus/prometheus/blob/v2.53.0/promql/functions.go#L1595.
280func getSortValueFromPair(samples []*pair, i int) float64 {
281 if samples[i].s.Histogram != nil {
282 return samples[i].s.Histogram.Histogram.Sum
283 }
284 // Impossible to have both histogram and sample nil.
285 return samples[i].s.Sample.Value
286}
287
288func sortPlanForQuery(q string) (sortPlan, error) {
289 expr, err := cortexparser.ParseExpr(q)

Callers 1

vectorMergeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected