diff --git a/fragment.go b/fragment.go index 930c8e02b..a18c4de61 100644 --- a/fragment.go +++ b/fragment.go @@ -189,7 +189,7 @@ func (f *Fragment) Open() error { func (f *Fragment) openStorage() error { // Create a roaring bitmap to serve as storage for the slice. if f.storage == nil { - f.storage = roaring.NewBitmap() + f.storage = roaring.NewBitmapBtree() } // Open the data file to be mmap'd and used as an ops log. file, err := os.OpenFile(f.path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) diff --git a/roaring/containers_test.go b/roaring/containers_test.go index 6d155f397..02e998151 100644 --- a/roaring/containers_test.go +++ b/roaring/containers_test.go @@ -5,7 +5,8 @@ import ( ) func TestContainersIterator(t *testing.T) { - btc := NewBTreeContainers() + //btc := NewBTreeContainers() + btc := NewSliceContainers() itr, found := btc.Iterator(0) if found { t.Fatalf("shouldn't have found 0 in empty btc") diff --git a/roaring/roaring.go b/roaring/roaring.go index 51f1efe9a..bcef1762c 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -113,6 +113,14 @@ type Bitmap struct { // NewBitmap returns a Bitmap with an initial set of values. func NewBitmap(a ...uint64) *Bitmap { + b := &Bitmap{ + conts: NewSliceContainers(), + } + b.Add(a...) + return b +} + +func NewBitmapBtree(a ...uint64) *Bitmap { b := &Bitmap{ conts: NewBTreeContainers(), } diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index f972d8573..48d29c058 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -1176,7 +1176,7 @@ const ( func BenchmarkContainerLinear(b *testing.B) { for n := 0; n < b.N; n++ { - bm := roaring.NewBitmap() + bm := roaring.NewBitmapBtree() for row := uint64(1); row < NumRows; row++ { for col := uint64(1); col < NumColums; col++ { bm.Add(row*pilosa.SliceWidth + (col * MaxContainerVal)) @@ -1187,7 +1187,7 @@ func BenchmarkContainerLinear(b *testing.B) { func BenchmarkContainerReverse(b *testing.B) { for n := 0; n < b.N; n++ { - bm := roaring.NewBitmap() + bm := roaring.NewBitmapBtree() for row := NumRows - 1; row >= 1; row-- { for col := NumColums - 1; col >= 1; col-- { bm.Add(row*pilosa.SliceWidth + (col * MaxContainerVal)) @@ -1198,7 +1198,7 @@ func BenchmarkContainerReverse(b *testing.B) { func BenchmarkContainerColumn(b *testing.B) { for n := 0; n < b.N; n++ { - bm := roaring.NewBitmap() + bm := roaring.NewBitmapBtree() for col := uint64(1); col < NumColums; col++ { for row := uint64(1); row < NumRows; row++ { bm.Add(row*pilosa.SliceWidth + (col * MaxContainerVal)) @@ -1210,7 +1210,7 @@ func BenchmarkContainerColumn(b *testing.B) { func BenchmarkContainerOutsideIn(b *testing.B) { middle := NumRows / uint64(2) for n := 0; n < b.N; n++ { - bm := roaring.NewBitmap() + bm := roaring.NewBitmapBtree() for col := uint64(1); col < NumColums; col++ { for row := uint64(1); row < middle; row++ { @@ -1224,7 +1224,7 @@ func BenchmarkContainerOutsideIn(b *testing.B) { func BenchmarkContainerInsideOut(b *testing.B) { middle := NumRows / uint64(2) for n := 0; n < b.N; n++ { - bm := roaring.NewBitmap() + bm := roaring.NewBitmapBtree() for col := uint64(1); col < NumColums; col++ { for row := uint64(1); row <= middle; row++ { bm.Add((middle+row)*pilosa.SliceWidth + (col * MaxContainerVal))