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

Function DecodeUvarintDescending

pkg/util/encoding/encoding.go:453–469  ·  view source on GitHub ↗

DecodeUvarintDescending decodes a uint64 value which was encoded using EncodeUvarintDescending.

(b []byte)

Source from the content-addressed store, hash-verified

451// DecodeUvarintDescending decodes a uint64 value which was encoded
452// using EncodeUvarintDescending.
453func DecodeUvarintDescending(b []byte) ([]byte, uint64, error) {
454 if len(b) == 0 {
455 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value")
456 }
457 length := intZero - int(b[0])
458 b = b[1:] // skip length byte
459 if length < 0 || length > 8 {
460 return nil, 0, errors.Errorf("invalid uvarint length of %d", length)
461 } else if len(b) < length {
462 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value: %q", b)
463 }
464 var x uint64
465 for _, t := range b[:length] {
466 x = (x << 8) | uint64(^t)
467 }
468 return b[length:], x, nil
469}
470
471const (
472 // <term> -> \x00\x01

Callers 3

DecodeBitArrayDescendingFunction · 0.85
decodeSmallNumberFunction · 0.85
decodeLargeNumberFunction · 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…