mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 11:57:51 +00:00
DirectAdd adds a single value
This commit is contained in:
parent
09c24cd3be
commit
37fdd73a7f
2 changed files with 6 additions and 7 deletions
|
|
@ -167,11 +167,9 @@ func (b *Bitmap) Add(a ...uint64) (changed bool, err error) {
|
|||
return changed, nil
|
||||
}
|
||||
|
||||
// DirectAdd adds values to the bitmap by bypassing the op log.
|
||||
func (b *Bitmap) DirectAdd(values ...uint64) {
|
||||
for _, value := range values {
|
||||
b.add(value)
|
||||
}
|
||||
// DirectAdd adds a value to the bitmap by bypassing the op log.
|
||||
func (b *Bitmap) DirectAdd(value uint64) bool {
|
||||
return b.add(value)
|
||||
}
|
||||
|
||||
func (b *Bitmap) add(v uint64) bool {
|
||||
|
|
|
|||
|
|
@ -334,8 +334,9 @@ func TestBitmap_ArrayCountRange(t *testing.T) {
|
|||
func TestBitmap_DirectAdd(t *testing.T) {
|
||||
bits := []uint64{0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 1000000, 1000002, 1000003, 1000004, 1000005, 1000006, 1000010, 1000011, 1000012, 1000013, 1000014}
|
||||
bm := roaring.NewBitmap()
|
||||
bm.DirectAdd(0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17)
|
||||
bm.DirectAdd(1000000, 1000002, 1000003, 1000004, 1000005, 1000006, 1000010, 1000011, 1000012, 1000013, 1000014)
|
||||
for _, b := range []uint64{0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 1000000, 1000002, 1000003, 1000004, 1000005, 1000006, 1000010, 1000011, 1000012, 1000013, 1000014} {
|
||||
bm.DirectAdd(b)
|
||||
}
|
||||
if len(bits) != int(bm.Count()) {
|
||||
t.Fatalf("count %d != %d", len(bits), bm.Count())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue