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

Function calculateBounds

pkg/io/buffered.go:79–98  ·  view source on GitHub ↗
(offset, length int64, bufferSize int, readerAtSize int64)

Source from the content-addressed store, hash-verified

77}
78
79func calculateBounds(offset, length int64, bufferSize int, readerAtSize int64) (newOffset, newLength int64) {
80 // Increase to minimim read size
81 sz := length
82 if sz < int64(bufferSize) {
83 sz = int64(bufferSize)
84 }
85
86 // Don't read larger than entire contents
87 if sz > readerAtSize {
88 sz = readerAtSize
89 }
90
91 // If read extends past the end of reader,
92 // back offset up to fill the whole buffer
93 if offset+sz >= readerAtSize {
94 offset = readerAtSize - sz
95 }
96
97 return offset, sz
98}
99
100func (r *BufferedReaderAt) ReadAt(b []byte, offset int64) (int, error) {
101 r.mtx.Lock()

Callers 2

prepMethod · 0.85

Calls

no outgoing calls

Tested by 1