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

Function getBitArrayWordsLen

pkg/util/encoding/encoding.go:1673–1693  ·  view source on GitHub ↗

getBitArrayWordsLen returns the number of bit array words in the encoded bytes and the size in bytes of the encoded word array (excluding the terminator byte).

(b []byte, term byte)

Source from the content-addressed store, hash-verified

1671// encoded bytes and the size in bytes of the encoded word array
1672// (excluding the terminator byte).
1673func getBitArrayWordsLen(b []byte, term byte) (int, int, error) {
1674 bSearch := b
1675 numWords := 0
1676 sz := 0
1677 for {
1678 if len(bSearch) == 0 {
1679 return 0, 0, errors.Errorf("slice too short for bit array (%d)", len(b))
1680 }
1681 if bSearch[0] == term {
1682 break
1683 }
1684 vLen, err := getVarintLen(bSearch)
1685 if err != nil {
1686 return 0, 0, err
1687 }
1688 bSearch = bSearch[vLen:]
1689 numWords++
1690 sz += vLen
1691 }
1692 return numWords, sz, nil
1693}
1694
1695// DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending.
1696func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) {

Callers 3

DecodeBitArrayAscendingFunction · 0.85
DecodeBitArrayDescendingFunction · 0.85
PeekLengthFunction · 0.85

Calls 2

getVarintLenFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…