MCPcopy Create free account
hub / github.com/apecloud/myduckserver / appendForEncoding

Function appendForEncoding

binlogreplication/binlog_json_serialization.go:295–302  ·  view source on GitHub ↗

appendForEncoding appends the |value| to the specified |bytes| and returns the updated byte slice. If |largeEncoding| is true, then 4 bytes are added to |bytes| to represent |value|, otherwise 2 bytes are used. This is a helper function for serializing the smallArray/largeArray and smallObject/large

(bytes []byte, value uint32, largeEncoding bool)

Source from the content-addressed store, hash-verified

293// This is a helper function for serializing the smallArray/largeArray and smallObject/largeObject formats, since
294// they are identical formats, except that offsets, counts, and sizes are stored as 2 bytes in the small encodings,
295// and stored as 4 bytes in the large encodings.
296func appendForEncoding(bytes []byte, value uint32, largeEncoding bool) []byte {
297 if !largeEncoding {
298 bytes = append(bytes, byte(value), byte(value>>8))
299 } else {
300 bytes = append(bytes, byte(value), byte(value>>8), byte(value>>16), byte(value>>24))
301 }
302 return bytes
303}
304
305// appendStringLength appends a variable number of bytes to the specified |bytes| to encode |length|, the

Callers 2

encodeJsonArrayFunction · 0.85
encodeJsonObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected