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

Function marshalWithStartEnd

pkg/model/v2/segment_decoder.go:88–106  ·  view source on GitHub ↗
(pb proto.Message, start uint32, end uint32)

Source from the content-addressed store, hash-verified

86}
87
88func marshalWithStartEnd(pb proto.Message, start uint32, end uint32) ([]byte, error) {
89 const uint32Size = 4
90
91 sz := proto.Size(pb)
92 buff := make([]byte, 0, sz+uint32Size*2) // proto buff size + start/end uint32s
93
94 buffer := proto.NewBuffer(buff)
95
96 _ = buffer.EncodeFixed32(uint64(start)) // EncodeFixed32 can't return an error
97 _ = buffer.EncodeFixed32(uint64(end))
98 err := buffer.Marshal(pb)
99 if err != nil {
100 return nil, err
101 }
102
103 buff = buffer.Bytes()
104
105 return buff, nil
106}
107
108func stripStartEnd(buff []byte) ([]byte, uint32, uint32, error) {
109 if len(buff) < 8 {

Callers 3

PrepareForWriteMethod · 0.85
ToObjectMethod · 0.85
CombineMethod · 0.85

Calls 3

BytesMethod · 0.80
SizeMethod · 0.65
MarshalMethod · 0.65

Tested by

no test coverage detected