mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Merge pull request #89 from tgruben/bug-q2-double-delete
bit remove leaves internals corrupt on empty edge case
This commit is contained in:
commit
ba70bf3079
2 changed files with 49 additions and 1 deletions
|
|
@ -3576,3 +3576,47 @@ func TestFragmentConcurrentReadWrite(t *testing.T) {
|
|||
|
||||
t.Logf("%d", acc)
|
||||
}
|
||||
|
||||
func TestFragment_Bug_Q2DoubleDelete(t *testing.T) {
|
||||
f := mustOpenFragment("i", "f", viewStandard, 0, "")
|
||||
b := []byte{60, 48, 0, 0, 1, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 24, 0, 0, 0, 1, 0}
|
||||
defer f.Clean(t)
|
||||
err := f.importRoaringT(b, false)
|
||||
if err != nil {
|
||||
t.Fatalf("importing roaring: %v", err)
|
||||
}
|
||||
//check the bit
|
||||
res := f.row(1).Columns()
|
||||
if len(res) < 1 || f.row(1).Columns()[0] != 1 {
|
||||
t.Fatalf("expecting 1 got: %v", res)
|
||||
}
|
||||
//clear the bit
|
||||
changed, _ := f.clearBit(1, 1)
|
||||
if !changed {
|
||||
t.Fatalf("expected change got %v", changed)
|
||||
}
|
||||
//check missing
|
||||
res = f.row(1).Columns()
|
||||
if len(res) != 0 {
|
||||
t.Fatalf("expected nothing got %v", res)
|
||||
}
|
||||
// import again
|
||||
err = f.importRoaringT(b, false)
|
||||
if err != nil {
|
||||
t.Fatalf("importing roaring: %v", err)
|
||||
}
|
||||
//check
|
||||
res = f.row(1).Columns()
|
||||
if len(res) < 1 || f.row(1).Columns()[0] != 1 {
|
||||
t.Fatalf("again expecting 1 got: %v", res)
|
||||
}
|
||||
changed, _ = f.clearBit(1, 1)
|
||||
if !changed {
|
||||
t.Fatalf("again expected change got %v", changed)
|
||||
}
|
||||
//check missing
|
||||
res = f.row(1).Columns()
|
||||
if len(res) != 0 {
|
||||
t.Fatalf("expected nothing got %v", res)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,7 +422,11 @@ func (b *Bitmap) remove(v uint64) bool {
|
|||
c := b.Containers.Get(highbits(v))
|
||||
newC, changed := c.remove(lowbits(v))
|
||||
if newC != c {
|
||||
b.Containers.Put(highbits(v), newC)
|
||||
if newC != nil {
|
||||
b.Containers.Put(highbits(v), newC)
|
||||
} else {
|
||||
b.Containers.Remove(highbits(v))
|
||||
}
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue