MCPcopy
hub / github.com/go-sql-driver/mysql / writeCompressedPacket

Method writeCompressedPacket

compress.go:197–213  ·  view source on GitHub ↗

writeCompressedPacket writes a compressed packet with header. data should start with 7 size space for header followed by payload.

(data []byte, uncompressedLen int)

Source from the content-addressed store, hash-verified

195// writeCompressedPacket writes a compressed packet with header.
196// data should start with 7 size space for header followed by payload.
197func (c *compIO) writeCompressedPacket(data []byte, uncompressedLen int) (int, error) {
198 mc := c.mc
199 comprLength := len(data) - 7
200 if debug {
201 fmt.Printf(
202 "writeCompressedPacket: comprLength=%v, uncompressedLen=%v, seq=%v\n",
203 comprLength, uncompressedLen, mc.compressSequence)
204 }
205
206 // compression header
207 putUint24(data[0:3], comprLength)
208 data[3] = mc.compressSequence
209 putUint24(data[4:7], uncompressedLen)
210
211 mc.compressSequence++
212 return mc.writeWithTimeout(data)
213}

Callers 1

writePacketsMethod · 0.95

Calls 2

putUint24Function · 0.85
writeWithTimeoutMethod · 0.80

Tested by

no test coverage detected