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

Method Write

compress/snappy/xerial.go:224–249  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

222}
223
224func (x *xerialWriter) Write(b []byte) (int, error) {
225 wn := 0
226
227 if cap(x.input) == 0 {
228 x.input = make([]byte, 0, defaultBufferSize)
229 }
230
231 for len(b) > 0 {
232 if x.full() {
233 x.grow()
234 }
235
236 n := copy(x.input[len(x.input):cap(x.input)], b)
237 b = b[n:]
238 wn += n
239 x.input = x.input[:len(x.input)+n]
240
241 if x.fullEnough() {
242 if err := x.Flush(); err != nil {
243 return wn, err
244 }
245 }
246 }
247
248 return wn, nil
249}
250
251func (x *xerialWriter) Flush() error {
252 if len(x.input) == 0 {

Callers 2

WriteToMethod · 0.45
writeMethod · 0.45

Calls 4

fullMethod · 0.95
growMethod · 0.95
fullEnoughMethod · 0.95
FlushMethod · 0.95

Tested by

no test coverage detected