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

Function DecodeUvarintAscending

pkg/util/encoding/encoding.go:558–580  ·  view source on GitHub ↗

DecodeUvarintAscending decodes a uint64 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

556// buffer. The remainder of the input buffer and the decoded uint64
557// are returned.
558func DecodeUvarintAscending(b []byte) ([]byte, uint64, error) {
559 if len(b) == 0 {
560 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value")
561 }
562 length := int(b[0]) - intZero
563 b = b[1:] // skip length byte
564 if length <= intSmall {
565 return b, uint64(length), nil
566 }
567 length -= intSmall
568 if length < 0 || length > 8 {
569 return nil, 0, errors.Errorf("invalid uvarint length of %d", length)
570 } else if len(b) < length {
571 return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value: %q", b)
572 }
573 var v uint64
574 // It is faster to range over the elements in a slice than to index
575 // into the slice on each loop iteration.
576 for _, t := range b[:length] {
577 v = (v << 8) | uint64(t)
578 }
579 return b[length:], v, nil
580}
581
582// DecodeUvarintDescending decodes a uint64 value which was encoded
583// using EncodeUvarintDescending.

Callers 5

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