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

Function DecodeUvarintAscending

pkg/util/encoding/encoding.go:427–449  ·  view source on GitHub ↗

DecodeUvarintAscending decodes a varint encoded uint64 from the input buffer. The remainder of the input buffer and the decoded uint64 are returned.

(b []byte)

Source from the content-addressed store, hash-verified

425// buffer. The remainder of the input buffer and the decoded uint64
426// are returned.
427func DecodeUvarintAscending(b []byte) ([]byte, uint64, error) {
428 if len(b) == 0 {
429 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value")
430 }
431 length := int(b[0]) - intZero
432 b = b[1:] // skip length byte
433 if length <= intSmall {
434 return b, uint64(length), nil
435 }
436 length -= intSmall
437 if length < 0 || length > 8 {
438 return nil, 0, errors.Errorf("invalid uvarint length of %d", length)
439 } else if len(b) < length {
440 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value: %q", b)
441 }
442 var v uint64
443 // It is faster to range over the elements in a slice than to index
444 // into the slice on each loop iteration.
445 for _, t := range b[:length] {
446 v = (v << 8) | uint64(t)
447 }
448 return b[length:], v, nil
449}
450
451// DecodeUvarintDescending decodes a uint64 value which was encoded
452// using EncodeUvarintDescending.

Callers 5

DecodeVarintAscendingFunction · 0.85
DecodeBitArrayAscendingFunction · 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…