Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions roaring64/parallel64.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ func ParOr(parallelism int, bitmaps ...*Bitmap) *Bitmap {
// on some systems, would block indefinitely.
keyRange := uint64(hKey) - uint64(lKey) + 1
if keyRange == 1 {
// revert to FastOr. Since the key range is 0
// no container-level aggregation parallelism is achievable
return FastOr(bitmaps...)
// All bitmaps have the same key,
// we can merge the 32-bit roaring bitmaps in parallel
var bms32s = make([]*roaring.Bitmap, 0, len(bitmaps))
for _, b := range bitmaps {
bms32s = append(bms32s, b.highlowcontainer.containers...)
}
return roaring32AsRoaring64(roaring.ParOr(parallelism, bms32s...), lKey)
}

if parallelism == 0 {
Expand Down
6 changes: 5 additions & 1 deletion roaring64/roaring64.go
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,13 @@ func (rb *Bitmap) Validate() error {
// Roaring32AsRoaring64 inserts a 32-bit roaring bitmap into
// a 64-bit roaring bitmap. No copy is made.
func Roaring32AsRoaring64(bm32 *roaring.Bitmap) *Bitmap {
return roaring32AsRoaring64(bm32, 0)
}

func roaring32AsRoaring64(bm32 *roaring.Bitmap, key uint32) *Bitmap {
rb := NewBitmap()
rb.highlowcontainer.resize(0)
rb.highlowcontainer.keys = append(rb.highlowcontainer.keys, 0)
rb.highlowcontainer.keys = append(rb.highlowcontainer.keys, key)
rb.highlowcontainer.containers = append(rb.highlowcontainer.containers, bm32)
rb.highlowcontainer.needCopyOnWrite = append(rb.highlowcontainer.needCopyOnWrite, false)
return rb
Expand Down
Loading