From 41b322d7446a899a9a0a336967d3a6c4fc780d86 Mon Sep 17 00:00:00 2001 From: Travis Date: Fri, 15 Sep 2017 14:52:57 -0500 Subject: [PATCH] update fragment.FieldSum to use roaring IntersectionCount() --- fragment.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fragment.go b/fragment.go index b687b506c..cca8c4ede 100644 --- a/fragment.go +++ b/fragment.go @@ -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