MCPcopy
hub / github.com/segmentio/kafka-go / Truncate

Method Truncate

protocol/buffer.go:259–282  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

257}
258
259func (pb *pageBuffer) Truncate(n int) {
260 if n < pb.length {
261 pb.length = n
262
263 if n < pb.cursor {
264 pb.cursor = n
265 }
266
267 for i := range pb.pages {
268 if p := pb.pages[i]; p.length <= n {
269 n -= p.length
270 } else {
271 if n > 0 {
272 pb.pages[i].Truncate(n)
273 i++
274 }
275 pb.pages[i:].unref()
276 pb.pages[i:].clear()
277 pb.pages = pb.pages[:i]
278 break
279 }
280 }
281 }
282}
283
284func (pb *pageBuffer) Seek(offset int64, whence int) (int64, error) {
285 c, err := seek(int64(pb.cursor), int64(pb.length), offset, whence)

Callers

nothing calls this directly

Calls 3

clearMethod · 0.80
TruncateMethod · 0.45
unrefMethod · 0.45

Tested by

no test coverage detected