diff --git a/roaring64/bsi64.go b/roaring64/bsi64.go index 5d6019db..484dd8ea 100644 --- a/roaring64/bsi64.go +++ b/roaring64/bsi64.go @@ -971,23 +971,18 @@ func ClearBits(foundSet, target *Bitmap) { target.AndNot(foundSet) } -// ClearValues removes the values found in foundSet +// ClearValues removes from the BSI all values whose column IDs are in +// foundSet, modifying the BSI in place. +// +// The implementation is intentionally serial. A previous goroutine-per-bit-plane +// approach was slower in practice: goroutine creation overhead dominated for +// typical BSI sizes, and the cost compounds when ClearValues is called in a +// tight loop (e.g. once per term across an entire index during a deletion pass). func (b *BSI) ClearValues(foundSet *Bitmap) { - - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - b.eBM.AndNot(foundSet) - }() - for i := 0; i < b.BitCount(); i++ { - wg.Add(1) - go func(j int) { - defer wg.Done() - b.bA[j].AndNot(foundSet) - }(i) + b.eBM.AndNot(foundSet) + for i := range b.bA { + b.bA[i].AndNot(foundSet) } - wg.Wait() } // NewBSIRetainSet - Construct a new BSI from a clone of existing BSI, retain only values contained in foundSet