DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending.
(b []byte)
| 1694 | |
| 1695 | // DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending. |
| 1696 | func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) { |
| 1697 | if PeekType(b) != BitArrayDesc { |
| 1698 | return nil, bitarray.BitArray{}, errors.Errorf("did not find marker %x", b) |
| 1699 | } |
| 1700 | b = b[1:] |
| 1701 | |
| 1702 | // First compute the length. |
| 1703 | numWords, _, err := getBitArrayWordsLen(b, bitArrayDataDescTerminator) |
| 1704 | if err != nil { |
| 1705 | return b, bitarray.BitArray{}, err |
| 1706 | } |
| 1707 | // Decode the words. |
| 1708 | words := make([]uint64, numWords) |
| 1709 | for i := range words { |
| 1710 | b, words[i], err = DecodeUvarintDescending(b) |
| 1711 | if err != nil { |
| 1712 | return b, bitarray.BitArray{}, err |
| 1713 | } |
| 1714 | } |
| 1715 | // Decode the final part. |
| 1716 | if len(b) == 0 || b[0] != bitArrayDataDescTerminator { |
| 1717 | return b, bitarray.BitArray{}, errBitArrayTerminatorMissing |
| 1718 | } |
| 1719 | b = b[1:] |
| 1720 | b, lastVal, err := DecodeUvarintDescending(b) |
| 1721 | if err != nil { |
| 1722 | return b, bitarray.BitArray{}, err |
| 1723 | } |
| 1724 | ba, err := bitarray.FromEncodingParts(words, lastVal) |
| 1725 | return b, ba, err |
| 1726 | } |
| 1727 | |
| 1728 | // Type represents the type of a value encoded by |
| 1729 | // Encode{Null,NotNull,Varint,Uvarint,Float,Bytes}. |
no test coverage detected
searching dependent graphs…