mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Fix percentile overflow error
This commit is contained in:
parent
3c399bc533
commit
af83205032
1 changed files with 3 additions and 1 deletions
|
|
@ -1295,7 +1295,9 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
|
|||
min, max := minVal.Val, maxVal.Val
|
||||
// estimate nth val, eg median when nth=0.5
|
||||
for min < max {
|
||||
possibleNthVal := (max + min) / 2
|
||||
// compute average without integer overflow, then correct for division of
|
||||
// odd numbers by 2
|
||||
possibleNthVal := ((max / 2) + (min / 2)) + (((max % 2) + (min % 2)) / 2)
|
||||
// get left count
|
||||
rangeCall.Args[fieldName] = &pql.Condition{
|
||||
Op: pql.Token(pql.LT),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue