Merge pull request #841 from travisturner/perf-use-intersection-count

update fragment.FieldSum to use roaring IntersectionCount()
This commit is contained in:
Travis Turner 2017-09-27 12:26:52 -05:00 committed by GitHub
commit cc43cbd22b

View file

@ -589,9 +589,10 @@ func (f *Fragment) FieldSum(filter *Bitmap, bitDepth uint) (sum, count uint64, e
// Compute count based on the existance bit.
row := f.Row(uint64(bitDepth))
if filter != nil {
row = row.Intersect(filter)
count = row.IntersectionCount(filter)
} else {
count = row.Count()
}
count = row.Count()
// Compute the sum based on the bit count of each row multiplied by the
// place value of each row. For example, 10 bits in the 1's place plus
@ -602,10 +603,13 @@ func (f *Fragment) FieldSum(filter *Bitmap, bitDepth uint) (sum, count uint64, e
//
for i := uint(0); i < bitDepth; i++ {
row := f.Row(uint64(i))
cnt := uint64(0)
if filter != nil {
row = row.Intersect(filter)
cnt = row.IntersectionCount(filter)
} else {
cnt = row.Count()
}
sum += (1 << i) * row.Count()
sum += (1 << i) * cnt
}
return sum, count, nil