mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
This commit changes the `roaring.Bitmap` to use a 40/24 split in the high and low bits. This change also requires the low bits to use `uint32` instead of `uint16`.
43 lines
775 B
Go
43 lines
775 B
Go
package roaring
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// Ensure iterator returns values from a bitmap.
|
|
func TestBitmapIterator(t *testing.T) {
|
|
for i, tt := range []struct {
|
|
bitmap []uint64
|
|
values []uint32
|
|
}{
|
|
// Empty
|
|
{
|
|
bitmap: []uint64{6}, // 0110
|
|
values: []uint32{1, 2},
|
|
},
|
|
|
|
// Single uint64 bitmap
|
|
{
|
|
bitmap: []uint64{6}, // 0110
|
|
values: []uint32{1, 2},
|
|
},
|
|
|
|
// Multi uint64 bitmap
|
|
{
|
|
bitmap: []uint64{1 << 63, 1, 0, 1, 3 << 62},
|
|
values: []uint32{63, 64, 192, 318, 319},
|
|
},
|
|
} {
|
|
itr := newBitmapIterator(tt.bitmap)
|
|
|
|
var a []uint32
|
|
for v, eof := itr.next(); !eof; v, eof = itr.next() {
|
|
a = append(a, v)
|
|
}
|
|
|
|
if !reflect.DeepEqual(a, tt.values) {
|
|
t.Errorf("%d. unexpected values: exp=%+v, got=%+v", i, a, tt.values)
|
|
}
|
|
}
|
|
}
|