You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
Fix the 0 count problem
This commit is contained in:
committed by
Leonid Fedorov
parent
80a2d8e9f5
commit
e7cab8445c
@ -114,16 +114,24 @@ mcsv1_UDAF::ReturnCode regr_sxx::subEvaluate(mcsv1Context* context, const UserDa
|
||||
long double inCx = inData->cx;
|
||||
|
||||
uint64_t resCnt = inCnt + outCnt;
|
||||
long double deltax = outAvgx - inAvgx;
|
||||
if (resCnt == 0)
|
||||
{
|
||||
outData->avgx = 0;
|
||||
outData->cx = 0;
|
||||
outData->cnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
long double deltax = outAvgx - inAvgx;
|
||||
|
||||
long double resAvgx = inAvgx + deltax * outCnt / resCnt;
|
||||
long double resAvgx = inAvgx + deltax * outCnt / resCnt;
|
||||
|
||||
long double resCx = outCx + inCx + deltax * deltax * inCnt * outCnt / resCnt;
|
||||
|
||||
outData->avgx = resAvgx;
|
||||
outData->cx = resCx;
|
||||
outData->cnt = resCnt;
|
||||
long double resCx = outCx + inCx + deltax * deltax * inCnt * outCnt / resCnt;
|
||||
|
||||
outData->avgx = resAvgx;
|
||||
outData->cx = resCx;
|
||||
outData->cnt = resCnt;
|
||||
}
|
||||
return mcsv1_UDAF::SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user