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

Function DecodeUvarintDescending

pkg/util/encoding/encoding.go:584–600  ·  view source on GitHub ↗

DecodeUvarintDescending decodes a uint64 value which was encoded using EncodeUvarintDescending.

(b []byte)

Source from the content-addressed store, hash-verified

582// DecodeUvarintDescending decodes a uint64 value which was encoded
583// using EncodeUvarintDescending.
584func DecodeUvarintDescending(b []byte) ([]byte, uint64, error) {
585 if len(b) == 0 {
586 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value")
587 }
588 length := intZero - int(b[0])
589 b = b[1:] // skip length byte
590 if length < 0 || length > 8 {
591 return nil, 0, errors.Errorf("invalid uvarint length of %d", length)
592 } else if len(b) < length {
593 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value: %q", b)
594 }
595 var x uint64
596 for _, t := range b[:length] {
597 x = (x << 8) | uint64(^t)
598 }
599 return b[length:], x, nil
600}
601
602const (
603 // <term> -> \x00\x01

Callers 3

DecodeBitArrayDescendingFunction · 0.85
decodeSmallNumberFunction · 0.85
decodeLargeNumberFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…