MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / PutLengthEncodedInt

Function PutLengthEncodedInt

IceFireDB-SQLite/pkg/mysql/mysql/util.go:173–191  ·  view source on GitHub ↗
(n uint64)

Source from the content-addressed store, hash-verified

171}
172
173func PutLengthEncodedInt(n uint64) []byte {
174 switch {
175 case n <= 250:
176 return []byte{byte(n)}
177
178 case n <= 0xffff:
179 return []byte{0xfc, byte(n), byte(n >> 8)}
180
181 case n <= 0xffffff:
182 return []byte{0xfd, byte(n), byte(n >> 8), byte(n >> 16)}
183
184 case n <= 0xffffffffffffffff:
185 return []byte{
186 0xfe, byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24),
187 byte(n >> 32), byte(n >> 40), byte(n >> 48), byte(n >> 56),
188 }
189 }
190 return nil
191}
192
193// LengthEncodedString returns the string read as a bytes slice, whether the value is NULL,
194// the number of bytes read and an error, in case the string is longer than

Callers 4

PutLengthEncodedStringFunction · 0.70
writeMethod · 0.50
writeOKMethod · 0.50
writeResultsetMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected