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

Function DecodeBitArrayAscending

pkg/util/encoding/encoding.go:1152–1182  ·  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

1150// EncodeBitArrayAscending. The remainder of the input buffer and the
1151// decoded bit array are returned.
1152func DecodeBitArrayAscending(b []byte) ([]byte, bitarray.BitArray, error) {
1153 if PeekType(b) != BitArray {
1154 return nil, bitarray.BitArray{}, errors.Errorf("did not find marker %x", b)
1155 }
1156 b = b[1:]
1157
1158 // First compute the length.
1159 numWords, _, err := getBitArrayWordsLen(b, bitArrayDataTerminator)
1160 if err != nil {
1161 return b, bitarray.BitArray{}, err
1162 }
1163 // Decode the words.
1164 words := make([]uint64, numWords)
1165 for i := range words {
1166 b, words[i], err = DecodeUvarintAscending(b)
1167 if err != nil {
1168 return b, bitarray.BitArray{}, err
1169 }
1170 }
1171 // Decode the final part.
1172 if len(b) == 0 || b[0] != bitArrayDataTerminator {
1173 return b, bitarray.BitArray{}, errBitArrayTerminatorMissing
1174 }
1175 b = b[1:]
1176 b, lastVal, err := DecodeUvarintAscending(b)
1177 if err != nil {
1178 return b, bitarray.BitArray{}, err
1179 }
1180 ba, err := bitarray.FromEncodingParts(words, lastVal)
1181 return b, ba, err
1182}
1183
1184var errBitArrayTerminatorMissing = errors.New("cannot find bit array data terminator")
1185

Callers 1

prettyPrintFirstValueFunction · 0.85

Calls 4

FromEncodingPartsFunction · 0.92
PeekTypeFunction · 0.85
getBitArrayWordsLenFunction · 0.85
DecodeUvarintAscendingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…