diff --git a/roaring/filter.go b/roaring/filter.go index 9c79cc33f..c594e8ca7 100644 --- a/roaring/filter.go +++ b/roaring/filter.go @@ -338,12 +338,11 @@ func (f *BitmapRowsUnion) ConsiderData(key FilterKey, data *Container) FilterRes // if necessary (because we expect the results to correspond to our shard // ID). func (f *BitmapRowsUnion) Results(shard uint64) *Bitmap { - shard <<= shardwidth.Exponent b := NewSliceBitmap() for i, c := range f.c { // UnionInPlace might not have fixed count c.Repair() - b.Containers.Put(uint64(i)+shard, c) + b.Containers.Put(uint64(i)+shard*rowWidth, c) } return b } diff --git a/roaring/filter_internal_test.go b/roaring/filter_internal_test.go index 3bffb4ef1..30a64ad23 100644 --- a/roaring/filter_internal_test.go +++ b/roaring/filter_internal_test.go @@ -125,6 +125,15 @@ func TestRowsUnion(t *testing.T) { } out := u.Results(0) compareSlices(t, "sevenEleven", out.Slice(), expected) + + // regression check (FB-1497)... make sure we're getting the + // expected bits in a higher shard as well + expected2 := make([]uint64, len(expected)) + for i, exp := range expected { + expected2[i] = exp + 2*1<