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

Method Flush

compress/snappy/xerial.go:251–285  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

249}
250
251func (x *xerialWriter) Flush() error {
252 if len(x.input) == 0 {
253 return nil
254 }
255
256 var b []byte
257 if x.encode == nil {
258 b = x.input
259 } else {
260 x.output = x.encode(x.output[:cap(x.output)], x.input)
261 b = x.output
262 }
263
264 x.input = x.input[:0]
265 x.output = x.output[:0]
266
267 if x.framed && x.nbytes == 0 {
268 writeXerialHeader(x.header[:])
269 _, err := x.write(x.header[:])
270 if err != nil {
271 return err
272 }
273 }
274
275 if x.framed {
276 writeXerialFrame(x.header[:4], len(b))
277 _, err := x.write(x.header[:4])
278 if err != nil {
279 return err
280 }
281 }
282
283 _, err := x.write(b)
284 return err
285}
286
287func (x *xerialWriter) write(b []byte) (int, error) {
288 n, err := x.writer.Write(b)

Callers 8

ReadFromMethod · 0.95
WriteMethod · 0.95
BenchmarkCompressionFunction · 0.45
TestXerialReaderWriterFunction · 0.45
CloseMethod · 0.45

Calls 3

writeMethod · 0.95
writeXerialHeaderFunction · 0.85
writeXerialFrameFunction · 0.85