MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / EncodeUvarintAscending

Function EncodeUvarintAscending

pkg/util/encoding/encoding.go:406–431  ·  view source on GitHub ↗

EncodeUvarintAscending encodes the uint64 value using a variable length (length-prefixed) representation. The length is encoded as a single byte indicating the number of encoded bytes (-8) to follow. See EncodeVarintAscending for rationale. The encoded bytes are appended to the supplied buffer and t

(b []byte, v uint64)

Source from the content-addressed store, hash-verified

404// EncodeVarintAscending for rationale. The encoded bytes are appended to the
405// supplied buffer and the final buffer is returned.
406func EncodeUvarintAscending(b []byte, v uint64) []byte {
407 switch {
408 case v <= intSmall:
409 return append(b, intZero+byte(v))
410 case v <= 0xff:
411 return append(b, IntMax-7, byte(v))
412 case v <= 0xffff:
413 return append(b, IntMax-6, byte(v>>8), byte(v))
414 case v <= 0xffffff:
415 return append(b, IntMax-5, byte(v>>16), byte(v>>8), byte(v))
416 case v <= 0xffffffff:
417 return append(b, IntMax-4, byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
418 case v <= 0xffffffffff:
419 return append(b, IntMax-3, byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8),
420 byte(v))
421 case v <= 0xffffffffffff:
422 return append(b, IntMax-2, byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16),
423 byte(v>>8), byte(v))
424 case v <= 0xffffffffffffff:
425 return append(b, IntMax-1, byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24),
426 byte(v>>16), byte(v>>8), byte(v))
427 default:
428 return append(b, IntMax, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32),
429 byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
430 }
431}
432
433// EncodedLengthUvarintAscending returns the length of the variable length
434// representation, i.e. the number of bytes appended by EncodeUvarintAscending.

Callers 4

EncodeVarintAscendingFunction · 0.85
EncodeBitArrayAscendingFunction · 0.85
encodeVarExpNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…