mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 11:27:50 +00:00
quick fix for Bitmap.Any bug
Want to make empty containers a thing of the past, but that can wait for another day.
This commit is contained in:
parent
7550b5445a
commit
d202e6a1a0
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