You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Renamed variables + removed server tests
This commit is contained in:
@ -1962,15 +1962,15 @@ void RowAggregation::doStatistics(const Row& rowIn, int64_t colIn, int64_t colOu
|
||||
|
||||
double count = fRow.getDoubleField(colOut) + 1.0;
|
||||
long double mean = fRow.getLongDoubleField(colAux);
|
||||
long double M2 = fRow.getLongDoubleField(colAux + 1);
|
||||
long double scaledMomentum2 = fRow.getLongDoubleField(colAux + 1);
|
||||
volatile long double delta = valIn - mean;
|
||||
mean += delta/count;
|
||||
M2 += delta * (valIn - mean);
|
||||
scaledMomentum2 += delta * (valIn - mean);
|
||||
|
||||
|
||||
fRow.setDoubleField(count, colOut);
|
||||
fRow.setLongDoubleField(mean, colAux);
|
||||
fRow.setLongDoubleField(M2, colAux + 1);
|
||||
fRow.setLongDoubleField(scaledMomentum2, colAux + 1);
|
||||
}
|
||||
|
||||
void RowAggregation::mergeStatistics(const Row& rowIn, uint64_t colOut, uint64_t colAux)
|
||||
@ -3164,26 +3164,26 @@ void RowAggregationUM::calculateStatisticsFunctions()
|
||||
}
|
||||
else // count > 1
|
||||
{
|
||||
long double M2 = fRow.getLongDoubleField(colAux + 1);
|
||||
long double scaledMomentum2 = fRow.getLongDoubleField(colAux + 1);
|
||||
|
||||
uint32_t scale = fRow.getScale(colOut);
|
||||
auto factor = datatypes::scaleDivisor<long double>(scale);
|
||||
|
||||
if (scale != 0) // adjust the scale if necessary
|
||||
{
|
||||
M2 /= factor * factor;
|
||||
scaledMomentum2 /= factor * factor;
|
||||
}
|
||||
|
||||
if (fFunctionCols[i]->fStatsFunction == ROWAGG_STDDEV_POP)
|
||||
M2 = sqrt(M2 / cnt);
|
||||
scaledMomentum2 = sqrt(scaledMomentum2 / cnt);
|
||||
else if (fFunctionCols[i]->fStatsFunction == ROWAGG_STDDEV_SAMP)
|
||||
M2 = sqrt(M2 / (cnt - 1));
|
||||
scaledMomentum2 = sqrt(scaledMomentum2 / (cnt - 1));
|
||||
else if (fFunctionCols[i]->fStatsFunction == ROWAGG_VAR_POP)
|
||||
M2 = M2 / cnt;
|
||||
scaledMomentum2 = scaledMomentum2 / cnt;
|
||||
else if (fFunctionCols[i]->fStatsFunction == ROWAGG_VAR_SAMP)
|
||||
M2 = M2 / (cnt - 1);
|
||||
scaledMomentum2 = scaledMomentum2 / (cnt - 1);
|
||||
|
||||
fRow.setDoubleField(M2, colOut);
|
||||
fRow.setDoubleField(scaledMomentum2, colOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4294,29 +4294,29 @@ void RowAggregationUMP2::doStatistics(const Row& rowIn, int64_t colIn, int64_t c
|
||||
{
|
||||
double count = fRow.getDoubleField(colOut);
|
||||
long double mean = fRow.getLongDoubleField(colAux);
|
||||
long double M2 = fRow.getLongDoubleField(colAux + 1);
|
||||
long double scaledMomentum2 = fRow.getLongDoubleField(colAux + 1);
|
||||
|
||||
double block_count = rowIn.getDoubleField(colIn);
|
||||
long double block_mean = rowIn.getLongDoubleField(colIn + 1);
|
||||
long double block_M2 = rowIn.getLongDoubleField(colIn + 2);
|
||||
double blockCount = rowIn.getDoubleField(colIn);
|
||||
long double blockMean = rowIn.getLongDoubleField(colIn + 1);
|
||||
long double blockScaledMomentum2 = rowIn.getLongDoubleField(colIn + 2);
|
||||
|
||||
double next_count = count + block_count;
|
||||
long double next_mean;
|
||||
long double next_M2;
|
||||
if (next_count == 0)
|
||||
double nextCount = count + blockCount;
|
||||
long double nextMean;
|
||||
long double nextScaledMomentum2;
|
||||
if (nextCount == 0)
|
||||
{
|
||||
next_mean = 0;
|
||||
next_M2 = 0;
|
||||
nextMean = 0;
|
||||
nextScaledMomentum2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
volatile long double delta = mean - block_mean;
|
||||
next_mean = (mean * count + block_mean * block_count) / next_count;
|
||||
next_M2 = M2 + block_M2 + delta * delta * (count * block_count / next_count);
|
||||
volatile long double delta = mean - blockMean;
|
||||
nextMean = (mean * count + blockMean * blockCount) / nextCount;
|
||||
nextScaledMomentum2 = scaledMomentum2 + blockScaledMomentum2 + delta * delta * (count * blockCount / nextCount);
|
||||
}
|
||||
fRow.setDoubleField(next_count, colOut);
|
||||
fRow.setLongDoubleField(next_mean, colAux);
|
||||
fRow.setLongDoubleField(next_M2, colAux + 1);
|
||||
fRow.setDoubleField(nextCount, colOut);
|
||||
fRow.setLongDoubleField(nextMean, colAux);
|
||||
fRow.setLongDoubleField(nextScaledMomentum2, colAux + 1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -139,10 +139,10 @@ WindowFunctionType* WF_stats<T>::clone() const
|
||||
template <typename T>
|
||||
void WF_stats<T>::resetData()
|
||||
{
|
||||
fMean = 0;
|
||||
fM2sum = 0;
|
||||
fCount = 0;
|
||||
fStats = 0.0;
|
||||
mean_ = 0;
|
||||
scaledMomentum2_ = 0;
|
||||
count_ = 0;
|
||||
stats_ = 0.0;
|
||||
|
||||
WindowFunctionType::resetData();
|
||||
}
|
||||
@ -175,17 +175,17 @@ void WF_stats<T>::operator()(int64_t b, int64_t e, int64_t c)
|
||||
T valIn;
|
||||
getValue(colIn, valIn, &cdt);
|
||||
long double val = (long double)valIn;
|
||||
fCount++;
|
||||
long double delta = val - fMean;
|
||||
fMean += delta/fCount;
|
||||
fM2sum += delta * (val - fMean);
|
||||
count_++;
|
||||
long double delta = val - mean_;
|
||||
mean_ += delta/count_;
|
||||
scaledMomentum2_ += delta * (val - mean_);
|
||||
}
|
||||
|
||||
if (fCount > 1)
|
||||
if (count_ > 1)
|
||||
{
|
||||
uint32_t scale = fRow.getScale(colIn);
|
||||
auto factor = datatypes::scaleDivisor<long double>(scale);
|
||||
long double stat = fM2sum;
|
||||
long double stat = scaledMomentum2_;
|
||||
|
||||
// adjust the scale if necessary
|
||||
if (scale != 0 && cdt != CalpontSystemCatalog::LONGDOUBLE)
|
||||
@ -194,23 +194,23 @@ void WF_stats<T>::operator()(int64_t b, int64_t e, int64_t c)
|
||||
}
|
||||
|
||||
if (fFunctionId == WF__STDDEV_POP)
|
||||
stat = sqrt(stat / fCount);
|
||||
stat = sqrt(stat / count_);
|
||||
else if (fFunctionId == WF__STDDEV_SAMP)
|
||||
stat = sqrt(stat / (fCount - 1));
|
||||
stat = sqrt(stat / (count_ - 1));
|
||||
else if (fFunctionId == WF__VAR_POP)
|
||||
stat = stat / fCount;
|
||||
stat = stat / count_;
|
||||
else if (fFunctionId == WF__VAR_SAMP)
|
||||
stat = stat / (fCount - 1);
|
||||
stat = stat / (count_ - 1);
|
||||
|
||||
fStats = (double)stat;
|
||||
stats_ = (double)stat;
|
||||
}
|
||||
}
|
||||
|
||||
if (fCount == 0)
|
||||
if (count_ == 0)
|
||||
{
|
||||
setValue(CalpontSystemCatalog::DOUBLE, b, e, c, (double*)NULL);
|
||||
}
|
||||
else if (fCount == 1)
|
||||
else if (count_ == 1)
|
||||
{
|
||||
if (fFunctionId == WF__STDDEV_SAMP || fFunctionId == WF__VAR_SAMP)
|
||||
{
|
||||
@ -224,7 +224,7 @@ void WF_stats<T>::operator()(int64_t b, int64_t e, int64_t c)
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(CalpontSystemCatalog::DOUBLE, b, e, c, &fStats);
|
||||
setValue(CalpontSystemCatalog::DOUBLE, b, e, c, &stats_);
|
||||
}
|
||||
|
||||
fPrev = c;
|
||||
|
@ -40,10 +40,10 @@ class WF_stats : public WindowFunctionType
|
||||
static boost::shared_ptr<WindowFunctionType> makeFunction(int, const string&, int, WindowFunctionColumn*);
|
||||
|
||||
protected:
|
||||
long double fMean;
|
||||
long double fM2sum;
|
||||
uint64_t fCount;
|
||||
double fStats;
|
||||
long double mean_;
|
||||
long double scaledMomentum2_;
|
||||
uint64_t count_;
|
||||
double stats_;
|
||||
};
|
||||
|
||||
} // namespace windowfunction
|
||||
|
Reference in New Issue
Block a user