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

Method Put

pkg/tempopb/pool.go:80–99  ·  view source on GitHub ↗

Put adds a slice to the right bucket in the pool.

(s []byte)

Source from the content-addressed store, hash-verified

78
79// Put adds a slice to the right bucket in the pool.
80func (p *Pool) Put(s []byte) int {
81 c := cap(s)
82
83 // valid slice?
84 if (c-p.minBucket)%p.bktSize != 0 {
85 return -1
86 }
87 bkt := p.bucketFor(c) // -1 puts the slice in the pool below. it will be larger than all requested slices for this bucket
88 if bkt < 0 {
89 return -1
90 }
91 if bkt >= len(p.buckets) {
92 return -1
93 }
94
95 // reset length for safety
96 p.buckets[bkt].Put(s[:0]) // nolint: staticcheck
97
98 return bkt // for testing
99}
100
101func (p *Pool) bucketFor(sz int) int {
102 if sz <= p.minBucket {

Callers 8

TestPoolGetFunction · 0.95
syncIteratorPoolPutFunction · 0.45
ReleaseMethod · 0.45
encoderPoolPutFunction · 0.45
encoderPoolPutOriginalFunction · 0.45
ReuseByteSlicesFunction · 0.45
putStatsFunction · 0.45

Calls 1

bucketForMethod · 0.95

Tested by 3

TestPoolGetFunction · 0.76
encoderPoolPutOriginalFunction · 0.36