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

Method ReadRange

tempodb/backend/cache/cache.go:110–131  ·  view source on GitHub ↗

ReadRange implements backend.RawReader

(ctx context.Context, name string, keypath backend.KeyPath, offset uint64, buffer []byte, cacheInfo *backend.CacheInfo)

Source from the content-addressed store, hash-verified

108
109// ReadRange implements backend.RawReader
110func (r *readerWriter) ReadRange(ctx context.Context, name string, keypath backend.KeyPath, offset uint64, buffer []byte, cacheInfo *backend.CacheInfo) error {
111 var k string
112 cache := r.cacheFor(cacheInfo)
113 if cache != nil {
114 k = strings.Join(append(keypath, name, strconv.Itoa(int(offset)), strconv.Itoa(len(buffer))), ":")
115 b, found := cache.FetchKey(ctx, k)
116 if found {
117 copy(buffer, b)
118 cache.Release(b)
119 return nil
120 }
121 }
122
123 // previous implemenation always passed false forward for "shouldCache" so we are matching that behavior by passing nil for cacheInfo
124 // todo: reevaluate. should we pass the cacheInfo forward?
125 err := r.nextReader.ReadRange(ctx, name, keypath, offset, buffer, nil)
126 if err == nil && cache != nil {
127 store(ctx, cache, cacheInfo.Role, k, buffer)
128 }
129
130 return err
131}
132
133// Shutdown implements backend.RawReader
134func (r *readerWriter) Shutdown() {

Callers

nothing calls this directly

Calls 6

cacheForMethod · 0.95
storeFunction · 0.70
JoinMethod · 0.65
FetchKeyMethod · 0.65
ReleaseMethod · 0.65
ReadRangeMethod · 0.65

Tested by

no test coverage detected