MCPcopy
hub / github.com/grafana/tempo / marshal

Method marshal

tempodb/backend/tenantindex.go:31–53  ·  view source on GitHub ↗

marshal converts to json and compresses the bucketindex

()

Source from the content-addressed store, hash-verified

29
30// marshal converts to json and compresses the bucketindex
31func (b *TenantIndex) marshal() ([]byte, error) {
32 buffer := &bytes.Buffer{}
33
34 gzip := gzip.NewWriter(buffer)
35 gzip.Name = internalFilename
36
37 jsonBytes, err := json.Marshal(b)
38 if err != nil {
39 return nil, err
40 }
41
42 if _, err = gzip.Write(jsonBytes); err != nil {
43 return nil, err
44 }
45 if err = gzip.Flush(); err != nil {
46 return nil, err
47 }
48 if err = gzip.Close(); err != nil {
49 return nil, err
50 }
51
52 return buffer.Bytes(), nil
53}
54
55// unmarshal decompresses and unmarshals the results from json
56func (b *TenantIndex) unmarshal(buffer []byte) error {

Callers 5

BenchmarkIndexMarshalFunction · 0.80
BenchmarkIndexUnmarshalFunction · 0.80
WriteTenantIndexMethod · 0.80
TestTenantIndexFallbackFunction · 0.80

Calls 5

WriteMethod · 0.95
BytesMethod · 0.80
MarshalMethod · 0.65
FlushMethod · 0.65
CloseMethod · 0.65

Tested by 4

BenchmarkIndexMarshalFunction · 0.64
BenchmarkIndexUnmarshalFunction · 0.64
TestTenantIndexFallbackFunction · 0.64