BitCount Count the number of bits set to 1 in the specified range of the bitmap If the key does not exist, it returns an error
(key string, start uint, end uint)
| 144 | // BitCount Count the number of bits set to 1 in the specified range of the bitmap |
| 145 | // If the key does not exist, it returns an error |
| 146 | func (b *BitMapStructure) BitCount(key string, start uint, end uint) (int, error) { |
| 147 | bitmap, length, err := b.getBitmapFromDB(key, false) |
| 148 | if err != nil { |
| 149 | return 0, err |
| 150 | } |
| 151 | |
| 152 | total1 := 0 |
| 153 | |
| 154 | // Iterate over the range |
| 155 | for offset := start; offset <= end; offset++ { |
| 156 | if offset < length { |
| 157 | if b.getBit(bitmap, offset) { |
| 158 | total1++ |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return total1, nil |
| 164 | } |
| 165 | |
| 166 | // BitOp count the number of bits set to 1 in the specified range of the bitmap |
| 167 | // If the key does not exist, it returns an error |
nothing calls this directly
no test coverage detected