DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending.
(b []byte)
| 1210 | |
| 1211 | // DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending. |
| 1212 | func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) { |
| 1213 | if PeekType(b) != BitArrayDesc { |
| 1214 | return nil, bitarray.BitArray{}, errors.Errorf("did not find marker %x", b) |
| 1215 | } |
| 1216 | b = b[1:] |
| 1217 | |
| 1218 | // First compute the length. |
| 1219 | numWords, _, err := getBitArrayWordsLen(b, bitArrayDataDescTerminator) |
| 1220 | if err != nil { |
| 1221 | return b, bitarray.BitArray{}, err |
| 1222 | } |
| 1223 | // Decode the words. |
| 1224 | words := make([]uint64, numWords) |
| 1225 | for i := range words { |
| 1226 | b, words[i], err = DecodeUvarintDescending(b) |
| 1227 | if err != nil { |
| 1228 | return b, bitarray.BitArray{}, err |
| 1229 | } |
| 1230 | } |
| 1231 | // Decode the final part. |
| 1232 | if len(b) == 0 || b[0] != bitArrayDataDescTerminator { |
| 1233 | return b, bitarray.BitArray{}, errBitArrayTerminatorMissing |
| 1234 | } |
| 1235 | b = b[1:] |
| 1236 | b, lastVal, err := DecodeUvarintDescending(b) |
| 1237 | if err != nil { |
| 1238 | return b, bitarray.BitArray{}, err |
| 1239 | } |
| 1240 | ba, err := bitarray.FromEncodingParts(words, lastVal) |
| 1241 | return b, ba, err |
| 1242 | } |
| 1243 | |
| 1244 | // Type represents the type of a value encoded by |
| 1245 | // Encode{Null,NotNull,Varint,Uvarint,Float,Bytes}. |
no test coverage detected
searching dependent graphs…