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

Function MatrixFromSeriesSet

pkg/ingester/client/compat.go:73–96  ·  view source on GitHub ↗

MatrixFromSeriesSet unpacks a SeriesSet to a model.Matrix.

(set storage.SeriesSet)

Source from the content-addressed store, hash-verified

71
72// MatrixFromSeriesSet unpacks a SeriesSet to a model.Matrix.
73func MatrixFromSeriesSet(set storage.SeriesSet) (model.Matrix, error) {
74 m := make(model.Matrix, 0)
75 for set.Next() {
76 s := set.At()
77 var ss model.SampleStream
78 ss.Metric = cortexpb.FromLabelAdaptersToMetric(cortexpb.FromLabelsToLabelAdapters(s.Labels()))
79 ss.Values = make([]model.SamplePair, 0)
80 it := s.Iterator(nil)
81 for it.Next() != chunkenc.ValNone {
82 t, v := it.At()
83 ss.Values = append(ss.Values, model.SamplePair{
84 Value: model.SampleValue(v),
85 Timestamp: model.Time(t),
86 })
87 }
88 if it.Err() != nil {
89 return nil, it.Err()
90 }
91
92 m = append(m, &ss)
93 }
94
95 return m, set.Err()
96}
97
98// ToMetricsForLabelMatchersRequest builds a MetricsForLabelMatchersRequest proto
99func ToMetricsForLabelMatchersRequest(from, to model.Time, limit int, matchers []*labels.Matcher) (*MetricsForLabelMatchersRequest, error) {

Callers 2

runTestQueryTimesFunction · 0.92

Calls 7

NextMethod · 0.65
AtMethod · 0.65
ErrMethod · 0.65
LabelsMethod · 0.45
IteratorMethod · 0.45

Tested by 2

runTestQueryTimesFunction · 0.74