move 0.0 check up to right after Min is queried

This commit is contained in:
Matt Jaffee 2021-03-02 21:59:46 -06:00
parent 1e4cc12bd0
commit f81c0cab6b
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF

View file

@ -1336,6 +1336,9 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
if err != nil {
return ValCount{}, errors.Wrap(err, "executing Min call for Percentile")
}
if nth == 0.0 {
return ValCount{Val: minVal.Val, Count: minVal.Count}, nil
}
// get max
q, _ = pql.ParseString(fmt.Sprintf(`Max(field="%s")`, fieldName))
@ -1361,10 +1364,6 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
rangeCall = intersectCall.Children[0]
}
if nth == 0.0 {
return ValCount{Val: minVal.Val, Count: minVal.Count}, nil
}
k := (1 - nth) / nth
min, max := minVal.Val, maxVal.Val