MCPcopy Index your code
hub / github.com/cortexproject/cortex / SeriesSetToQueryResponse

Function SeriesSetToQueryResponse

pkg/ingester/client/compat.go:114–157  ·  view source on GitHub ↗

SeriesSetToQueryResponse builds a QueryResponse proto

(s storage.SeriesSet)

Source from the content-addressed store, hash-verified

112
113// SeriesSetToQueryResponse builds a QueryResponse proto
114func SeriesSetToQueryResponse(s storage.SeriesSet) (*QueryResponse, error) {
115 result := &QueryResponse{}
116
117 var it chunkenc.Iterator
118 for s.Next() {
119 series := s.At()
120 samples := []cortexpb.Sample{}
121 histograms := []cortexpb.WrappedHistogram{}
122 it = series.Iterator(it)
123 for valType := it.Next(); valType != chunkenc.ValNone; valType = it.Next() {
124 switch valType {
125 case chunkenc.ValFloat:
126 t, v := it.At()
127 samples = append(samples, cortexpb.Sample{
128 TimestampMs: t,
129 Value: v,
130 })
131 case chunkenc.ValHistogram:
132 t, v := it.AtHistogram(nil)
133 histograms = append(histograms, cortexpb.WrappedHistogram{Histogram: cortexpb.HistogramToHistogramProto(t, v)})
134 case chunkenc.ValFloatHistogram:
135 t, v := it.AtFloatHistogram(nil)
136 histograms = append(histograms, cortexpb.WrappedHistogram{Histogram: cortexpb.FloatHistogramToHistogramProto(t, v)})
137 default:
138 panic("unhandled default case")
139 }
140 }
141 if err := it.Err(); err != nil {
142 return nil, err
143 }
144 ts := cortexpb.TimeSeries{
145 Labels: cortexpb.FromLabelsToLabelAdapters(series.Labels()),
146 }
147 if len(samples) > 0 {
148 ts.Samples = samples
149 }
150 if len(histograms) > 0 {
151 ts.Histograms = histograms
152 }
153 result.Timeseries = append(result.Timeseries, ts)
154 }
155
156 return result, s.Err()
157}
158
159// FromMetricsForLabelMatchersRequest unpacks a MetricsForLabelMatchersRequest proto
160func FromMetricsForLabelMatchersRequest(cache storecache.MatchersCache, req *MetricsForLabelMatchersRequest) (model.Time, model.Time, int, [][]*labels.Matcher, error) {

Callers 4

RemoteReadHandlerFunction · 0.92
TestIngester_PushFunction · 0.92
Test_Ingester_QueryFunction · 0.92

Calls 10

ErrMethod · 0.95
NextMethod · 0.65
AtMethod · 0.65
IteratorMethod · 0.45
AtHistogramMethod · 0.45
AtFloatHistogramMethod · 0.45
LabelsMethod · 0.45