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

Function SampleJsoniterEncode

pkg/cortexpb/compat.go:236–249  ·  view source on GitHub ↗
(ptr unsafe.Pointer, stream *jsoniter.Stream)

Source from the content-addressed store, hash-verified

234}
235
236func SampleJsoniterEncode(ptr unsafe.Pointer, stream *jsoniter.Stream) {
237 sample := (*Sample)(ptr)
238
239 if isTesting && math.IsNaN(sample.Value) {
240 stream.Error = fmt.Errorf("test sample")
241 return
242 }
243
244 stream.WriteArrayStart()
245 stream.WriteFloat64(float64(sample.TimestampMs) / float64(time.Second/time.Millisecond))
246 stream.WriteMore()
247 stream.WriteString(model.SampleValue(sample.Value).String())
248 stream.WriteArrayEnd()
249}
250
251func SampleJsoniterDecode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
252 if !iter.ReadArray() {

Callers 2

encodeSampleStreamFunction · 0.92
encodeSampleFunction · 0.92

Calls 2

WriteStringMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected