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

Function DecodeBitArrayAscending

pkg/util/encoding/encoding.go:1636–1666  ·  view source on GitHub ↗

DecodeBitArrayAscending decodes a bit array which was encoded using EncodeBitArrayAscending. The remainder of the input buffer and the decoded bit array are returned.

(b []byte)

Source from the content-addressed store, hash-verified

1634// EncodeBitArrayAscending. The remainder of the input buffer and the
1635// decoded bit array are returned.
1636func DecodeBitArrayAscending(b []byte) ([]byte, bitarray.BitArray, error) {
1637 if PeekType(b) != BitArray {
1638 return nil, bitarray.BitArray{}, errors.Errorf("did not find marker %x", b)
1639 }
1640 b = b[1:]
1641
1642 // First compute the length.
1643 numWords, _, err := getBitArrayWordsLen(b, bitArrayDataTerminator)
1644 if err != nil {
1645 return b, bitarray.BitArray{}, err
1646 }
1647 // Decode the words.
1648 words := make([]uint64, numWords)
1649 for i := range words {
1650 b, words[i], err = DecodeUvarintAscending(b)
1651 if err != nil {
1652 return b, bitarray.BitArray{}, err
1653 }
1654 }
1655 // Decode the final part.
1656 if len(b) == 0 || b[0] != bitArrayDataTerminator {
1657 return b, bitarray.BitArray{}, errBitArrayTerminatorMissing
1658 }
1659 b = b[1:]
1660 b, lastVal, err := DecodeUvarintAscending(b)
1661 if err != nil {
1662 return b, bitarray.BitArray{}, err
1663 }
1664 ba, err := bitarray.FromEncodingParts(words, lastVal)
1665 return b, ba, err
1666}
1667
1668var errBitArrayTerminatorMissing = errors.New("cannot find bit array data terminator")
1669

Callers 1

prettyPrintFirstValueFunction · 0.85

Calls 5

FromEncodingPartsFunction · 0.92
PeekTypeFunction · 0.85
getBitArrayWordsLenFunction · 0.85
DecodeUvarintAscendingFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…