1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -55,93 +55,100 @@ namespace windowfunction
boost::shared_ptr<WindowFunctionType> WF_ranking::makeFunction(int id, const string& name, int ct)
{
boost::shared_ptr<WindowFunctionType> func(new WF_ranking(id, name));
return func;
boost::shared_ptr<WindowFunctionType> func(new WF_ranking(id, name));
return func;
}
WindowFunctionType* WF_ranking::clone() const
{
return new WF_ranking(*this);
return new WF_ranking(*this);
}
void WF_ranking::resetData()
{
fRank = 0;
fDups = 0;
fRank = 0;
fDups = 0;
WindowFunctionType::resetData();
WindowFunctionType::resetData();
}
void WF_ranking::operator()(int64_t b, int64_t e, int64_t c)
{
// one row handling
if (fPartition.first == fPartition.second)
{
fRow.setData(getPointer(fRowData->at(fPartition.first)));
int64_t r = (fFunctionId == WF__PERCENT_RANK) ? 0 : 1;
if (fFunctionId == WF__RANK || fFunctionId == WF__DENSE_RANK)
setIntValue(fFieldIndex[0], r);
else
setDoubleValue(fFieldIndex[0], r);
// one row handling
if (fPartition.first == fPartition.second)
{
fRow.setData(getPointer(fRowData->at(fPartition.first)));
int64_t r = (fFunctionId == WF__PERCENT_RANK) ? 0 : 1;
return;
}
if (fFunctionId == WF__RANK || fFunctionId == WF__DENSE_RANK)
setIntValue(fFieldIndex[0], r);
else
setDoubleValue(fFieldIndex[0], r);
// more than one row, e > b
b = fPartition.first;
e = fPartition.second;
double n1 = e - b; // count(*) - 1, n will not be 0.
for (c = b; c <= e; c++)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
return;
}
if (c != b &&
fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(c-1))))
{
fDups++;
}
else
{
fRank++;
if (fFunctionId != WF__DENSE_RANK)
fRank += fDups;
fDups = 0;
}
// more than one row, e > b
b = fPartition.first;
e = fPartition.second;
double n1 = e - b; // count(*) - 1, n will not be 0.
fRow.setData(getPointer(fRowData->at(c)));
if (fFunctionId != WF__PERCENT_RANK)
setIntValue(fFieldIndex[0], fRank);
else
setDoubleValue(fFieldIndex[0], (fRank-1)/n1);
}
for (c = b; c <= e; c++)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
// Two-pass, need to find peers.
if (fFunctionId == WF__CUME_DIST)
{
int prevRank = ++fRank + fDups; // hypothetical row at (e+1)
double n0 = (e - b + 1); // count(*)
double cumeDist = 1;
fRow.setData(getPointer(fRowData->at(e)));
for (c = e; c >= b; c--)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
if (c != b &&
fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(c - 1))))
{
fDups++;
}
else
{
fRank++;
fRow.setData(getPointer(fRowData->at(c)));
int currRank = getIntValue(fFieldIndex[0]);
if (currRank != prevRank)
{
cumeDist = ((double) (prevRank-1)) / n0;
prevRank = currRank;
}
if (fFunctionId != WF__DENSE_RANK)
fRank += fDups;
setDoubleValue(fFieldIndex[0], cumeDist);
}
}
fDups = 0;
}
fRow.setData(getPointer(fRowData->at(c)));
if (fFunctionId != WF__PERCENT_RANK)
setIntValue(fFieldIndex[0], fRank);
else
setDoubleValue(fFieldIndex[0], (fRank - 1) / n1);
}
// Two-pass, need to find peers.
if (fFunctionId == WF__CUME_DIST)
{
int prevRank = ++fRank + fDups; // hypothetical row at (e+1)
double n0 = (e - b + 1); // count(*)
double cumeDist = 1;
fRow.setData(getPointer(fRowData->at(e)));
for (c = e; c >= b; c--)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
fRow.setData(getPointer(fRowData->at(c)));
int currRank = getIntValue(fFieldIndex[0]);
if (currRank != prevRank)
{
cumeDist = ((double) (prevRank - 1)) / n0;
prevRank = currRank;
}
setDoubleValue(fFieldIndex[0], cumeDist);
}
}
}