use num containers to decide which direction to union

avoids doing a potentially expensive f.storage.Count()
This commit is contained in:
Matt Jaffee 2019-03-09 21:51:08 -06:00
parent e33ca2d0ae
commit 19807ff3a7
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF

View file

@ -1750,15 +1750,11 @@ func (f *fragment) importRoaring(data []byte, clear bool) error {
if clear {
bm = f.storage.Difference(bm)
} else if f.storage.Containers.Size() >= bm.Containers.Size() {
f.storage.UnionInPlace(bm)
bm = f.storage
} else {
if cnt := f.storage.Count(); cnt > 0 {
if incomingCnt > int(cnt) {
bm.UnionInPlace(f.storage)
} else {
f.storage.UnionInPlace(bm)
bm = f.storage
}
}
bm.UnionInPlace(f.storage)
}
for _, rowID := range rowSet {