aviggiano / redis-roaring

Roaring Bitmaps for Redis
MIT License
345 stars 55 forks source link

Roaring r.setfull missed 2 bits #85

Closed arthurkiller closed 3 years ago

arthurkiller commented 3 years ago

r.setfull means fill all bits with a key.

But after calling r.setfull, not all bits were set. r.statandr.bitcount` shown that we have left 2 bits unset.

    Bitmap* bitmap = bitmap_from_range(0, UINT32_MAX-1);

roaring can take [0 ~ 2^32-1] , [0 ~ 4294967295] , and UINT32_MAX represent 4294967295, so we should use instead.

    Bitmap* bitmap = bitmap_from_range(0, UINT32_MAX);

But after this, still got 1 bit left.

roaring_bitmap_from_range(from, to, 1);

roaring_bitmap_from_range will set range for bitset only with a right-open range, those bits between [from, to) will be set.

so we should do this manually by adding

bitmap_setbit(bitmap, UINT32_MAX, 1);
arthurkiller commented 3 years ago

closed via #86