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

Function getVarintLen

pkg/util/encoding/encoding.go:342–360  ·  view source on GitHub ↗

getVarintLen returns the encoded length of an encoded varint. Assumes the slice has at least one byte.

(b []byte)

Source from the content-addressed store, hash-verified

340// getVarintLen returns the encoded length of an encoded varint. Assumes the
341// slice has at least one byte.
342func getVarintLen(b []byte) (int, error) {
343 length := int(b[0]) - intZero
344 if length >= 0 {
345 if length <= intSmall {
346 // just the tag
347 return 1, nil
348 }
349 // tag and length-intSmall bytes
350 length = 1 + length - intSmall
351 } else {
352 // tag and -length bytes
353 length = 1 - length
354 }
355
356 if length > len(b) {
357 return 0, errors.Errorf("varint length %d exceeds slice length %d", length, len(b))
358 }
359 return length, nil
360}
361
362// DecodeVarintAscending decodes a value encoded by EncodeVarintAscending.
363func DecodeVarintAscending(b []byte) ([]byte, int64, error) {

Callers 6

DecodeGeoInvertedKeyFunction · 0.85
getBitArrayWordsLenFunction · 0.85
GetMultiVarintLenFunction · 0.85
PeekLengthFunction · 0.85
getDecimalLenFunction · 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…