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

Method GetBit

structure/bitmap.go:150–167  ·  view source on GitHub ↗

GetBit function retrieves a bit at the specified offset in the bitmap for the provided key

(k string, off uint)

Source from the content-addressed store, hash-verified

148
149// GetBit function retrieves a bit at the specified offset in the bitmap for the provided key
150func (b *BitmapStructure) GetBit(k string, off uint) (bool, error) {
151 // Convert the key to bytes
152 key := stringToBytesWithKey(k)
153 // Get the bits from the database
154 value, err := b.db.Get(key)
155 if err != nil {
156 return false, err
157 }
158 // Create a new bitset
159 bit := bitset.New(1)
160 // Unmarshal the retrieved bits into the bitset
161 err = bit.UnmarshalBinary(value)
162 if err != nil {
163 return false, err
164 }
165 // Return the bit at the specified offset
166 return bit.Test(off), nil
167}
168
169// DelBit function deletes a bit at the specified offset in the bitmap for the provided key
170func (b *BitmapStructure) DelBit(k string, off uint) error {

Callers 4

Calls 3

stringToBytesWithKeyFunction · 0.85
GetMethod · 0.65
UnmarshalBinaryMethod · 0.45

Tested by 4