MCPcopy Index your code
hub / github.com/prometheus/prometheus / Decode

Method Decode

tsdb/compression/compression.go:112–130  ·  view source on GitHub ↗

Decode returns the decoded form of src or error, given expected compression type. The buf is used as a buffer for the returned decoded entry, and it must not overlap with src. It is valid to pass a nil buf.

(t Type, src, buf []byte)

Source from the content-addressed store, hash-verified

110// The buf is used as a buffer for the returned decoded entry, and it must not
111// overlap with src. It is valid to pass a nil buf.
112func (d *Decoder) Decode(t Type, src, buf []byte) (_ []byte, err error) {
113 switch {
114 case len(src) == 0, t == "", t == None:
115 return src, nil
116 case t == Snappy:
117 // The snappy library uses `len` to calculate if we need a new buffer.
118 // In order to allocate as few buffers as possible make the length
119 // equal to the capacity.
120 buf = buf[:cap(buf)]
121 return snappy.Decode(buf, src)
122 case t == Zstd:
123 if d == nil {
124 return nil, errors.New("zstd requested but Decoder was not initialized with NewDecoder()")
125 }
126 return d.r.DecodeAll(src, buf[:0])
127 default:
128 return nil, fmt.Errorf("unsupported compression type: %s", t)
129 }
130}

Callers 15

ParseFunction · 0.95
TestPromTextToProtoFunction · 0.95
UnmarshalJSONMethod · 0.95
readSeriesStateFileMethod · 0.80
TestEncodeDecodeFunction · 0.80
BenchmarkDecode_SamplesFunction · 0.80
serveFunction · 0.80
benchExpFmtFunction · 0.80
TestSampledReadEndpointFunction · 0.80
DecodeReadRequestFunction · 0.80

Calls

no outgoing calls

Tested by 11

TestPromTextToProtoFunction · 0.76
TestEncodeDecodeFunction · 0.64
BenchmarkDecode_SamplesFunction · 0.64
benchExpFmtFunction · 0.64
TestSampledReadEndpointFunction · 0.64
fetchLTSReleasesFunction · 0.64
snapshotQueryRangeMethod · 0.64
mockServerFunction · 0.64
TestServeTSDBBlocksFunction · 0.64