CRoaring icon indicating copy to clipboard operation
CRoaring copied to clipboard

Avoid calculating the sum of items in bitmap statistics

Open Dr-Emann opened this issue 9 months ago • 2 comments

Calculating the sum of values requires visiting every item in the bitmap: Other than this, all other statistics can be calculated by only visiting each container. Is it worth either:

  1. Removing the field entirely (breaking change, both API and ABI)
  2. Changing the implementation to leave sum as zero, and documenting that the sum field is not actually updated.

Originally posted by @AviAvni in https://github.com/RoaringBitmap/CRoaring/pull/617#discussion_r1585936127

Dr-Emann avatar May 01 '24 14:05 Dr-Emann

we can also provide another api to get a sum just like min and max and it can be optimize for example if we can iterate on ranges for example 1..100 1000..2000 we can just simply calculate (1+100)*100/2+(1000+2000)*1000/2

AviAvni avatar May 01 '24 14:05 AviAvni

I think it would be an acceptable breaking change.

lemire avatar May 01 '24 16:05 lemire

Done by #624

Dr-Emann avatar May 28 '24 14:05 Dr-Emann