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

Function decodeSample

pkg/querier/tripperware/query.go:345–364  ·  view source on GitHub ↗
(ptr unsafe.Pointer, iter *jsoniter.Iterator)

Source from the content-addressed store, hash-verified

343}
344
345func decodeSample(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
346 ss := (*Sample)(ptr)
347 for field := iter.ReadObject(); field != ""; field = iter.ReadObject() {
348 switch field {
349 case "metric":
350 lbls := labels.Labels{}
351 chunk.DecodeLabels(unsafe.Pointer(&lbls), iter)
352 ss.Labels = cortexpb.FromLabelsToLabelAdapters(lbls)
353 case "value":
354 ss.Sample = &cortexpb.Sample{}
355 cortexpb.SampleJsoniterDecode(unsafe.Pointer(ss.Sample), iter)
356 case "histogram":
357 ss.Histogram = &SampleHistogramPair{}
358 UnmarshalSampleHistogramPairJSON(unsafe.Pointer(ss.Histogram), iter)
359 default:
360 iter.ReportError("unmarshal Sample", fmt.Sprint("unexpected key:", field))
361 return
362 }
363 }
364}
365
366func encodeSample(ptr unsafe.Pointer, stream *jsoniter.Stream) {
367 ss := (*Sample)(ptr)

Callers

nothing calls this directly

Calls 4

DecodeLabelsFunction · 0.92
SampleJsoniterDecodeFunction · 0.92

Tested by

no test coverage detected