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

Function getBitArrayWordsLen

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

1187// encoded bytes and the size in bytes of the encoded word array
1188// (excluding the terminator byte).
1189func getBitArrayWordsLen(b []byte, term byte) (int, int, error) {
1190 bSearch := b
1191 numWords := 0
1192 sz := 0
1193 for {
1194 if len(bSearch) == 0 {
1195 return 0, 0, errors.Errorf("slice too short for bit array (%d)", len(b))
1196 }
1197 if bSearch[0] == term {
1198 break
1199 }
1200 vLen, err := getVarintLen(bSearch)
1201 if err != nil {
1202 return 0, 0, err
1203 }
1204 bSearch = bSearch[vLen:]
1205 numWords++
1206 sz += vLen
1207 }
1208 return numWords, sz, nil
1209}
1210
1211// DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending.
1212func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) {

Callers 3

DecodeBitArrayAscendingFunction · 0.85
DecodeBitArrayDescendingFunction · 0.85
PeekLengthFunction · 0.85

Calls 1

getVarintLenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…