MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / BitDel

Method BitDel

structure/bitmap_1.go:256–274  ·  view source on GitHub ↗

BitDel delete the bit at the specified offset in the bitmap If the key does not exist, it returns an error There is room for optimization

(key string, offset uint)

Source from the content-addressed store, hash-verified

254// If the key does not exist, it returns an error
255// There is room for optimization
256func (b *BitMapStructure) BitDel(key string, offset uint) error {
257
258 bitmap, length, err := b.getBitmapFromDB(key, false)
259 if err != nil {
260 return err
261 }
262 // If offset is greater than or equal to length, no operation is needed
263 if offset >= length {
264 return nil
265 }
266
267 length--
268 // Shift the bits one by one
269 for i := offset; i < length; i++ {
270 b.setBit(bitmap, i, b.getBit(bitmap, i+1))
271 }
272
273 return b.setBitmapToDB(key, bitmap, length)
274}
275
276// BitDels delete a group of bits at the specified offsets in the bitmap
277// If the key does not exist, it returns an error

Callers 1

Calls 4

getBitmapFromDBMethod · 0.95
setBitMethod · 0.95
getBitMethod · 0.95
setBitmapToDBMethod · 0.95

Tested by 1