Make percentile checker in test-case match executor implementation

This commit is contained in:
nagamocha3000 2021-06-03 21:55:11 +03:00
parent af83205032
commit b1d18a1ba3
2 changed files with 2 additions and 1 deletions

View file

@ -1298,6 +1298,7 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
// compute average without integer overflow, then correct for division of
// odd numbers by 2
possibleNthVal := ((max / 2) + (min / 2)) + (((max % 2) + (min % 2)) / 2)
// possibleNthVal = (max + min) / 2
// get left count
rangeCall.Args[fieldName] = &pql.Condition{
Op: pql.Token(pql.LT),

View file

@ -6939,7 +6939,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) {
possibleNthVal := int64(0)
// bin search
for min < max {
possibleNthVal = (max + min) / 2
possibleNthVal = ((max / 2) + (min / 2)) + (((max % 2) + (min % 2)) / 2)
leftCount, rightCount := int64(0), int64(0)
for _, num := range nums {
if num < possibleNthVal {