mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #841 from travisturner/perf-use-intersection-count
update fragment.FieldSum to use roaring IntersectionCount()
This commit is contained in:
commit
cc43cbd22b
1 changed files with 8 additions and 4 deletions
12
fragment.go
12
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue