mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
Merge pull request #1908 from jaffee/bitmap-any-quick-fix
quick fix for Bitmap.Any bug [no changelog]
This commit is contained in:
commit
86ea040639
2 changed files with 29 additions and 1 deletions
|
|
@ -331,7 +331,7 @@ func (b *Bitmap) Any() bool {
|
|||
// TODO (jaffee) I'm not sure if it's possible/legal to have an empty
|
||||
// container, so this loop may be totally unnecessary. In theory, any empty
|
||||
// container should be removed from the bitmap though.
|
||||
for b := iter.Next(); b; iter.Next() {
|
||||
for iter.Next() {
|
||||
_, c := iter.Value()
|
||||
if c.n > 0 {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -3818,3 +3818,31 @@ func BenchmarkUnionInPlaceRegression(b *testing.B) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestBitmapAny(t *testing.T) {
|
||||
bm := NewBTreeBitmap()
|
||||
if bm.Any() {
|
||||
t.Error("empty bitmap should have Any()==false")
|
||||
}
|
||||
bm.Add(1)
|
||||
if !bm.Any() {
|
||||
t.Error("bitmap with 1 bit should have Any()==true")
|
||||
}
|
||||
bm.Add(100000)
|
||||
if !bm.Any() {
|
||||
t.Error("bitmap with 2 bits should have Any()==true")
|
||||
}
|
||||
bm.Remove(1)
|
||||
if !bm.Any() {
|
||||
t.Error("bitmap with 1 bit left after removing 1 should have Any()==true")
|
||||
}
|
||||
bm.Add(1)
|
||||
bm = bm.Difference(NewBTreeBitmap(1))
|
||||
if !bm.Any() {
|
||||
t.Error("bitmap with 1 bit left after differencing 1 should have Any()==true")
|
||||
}
|
||||
bm.Remove(100000)
|
||||
if bm.Any() {
|
||||
t.Error("shouldn't be any left")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue