1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +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

@ -56,104 +56,111 @@ namespace windowfunction
boost::shared_ptr<WindowFunctionType> WF_ntile::makeFunction(int id, const string& name, int ct)
{
boost::shared_ptr<WindowFunctionType> func(new WF_ntile(id, name));
return func;
boost::shared_ptr<WindowFunctionType> func(new WF_ntile(id, name));
return func;
}
WindowFunctionType* WF_ntile::clone() const
{
return new WF_ntile(*this);
return new WF_ntile(*this);
}
void WF_ntile::resetData()
{
WindowFunctionType::resetData();
WindowFunctionType::resetData();
}
void WF_ntile::parseParms(const std::vector<execplan::SRCP>& parms)
{
// parms[0]: nt
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(parms[0].get());
if (cc != NULL)
{
fNtileNull = false;
fNtile = cc->getIntVal(fRow, fNtileNull); // row not used, no need to setData.
if (!fNtileNull && fNtile <= 0)
{
ostringstream oss;
oss << fNtile;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(ERR_WF_ARG_OUT_OF_RANGE,
oss.str()), ERR_WF_ARG_OUT_OF_RANGE);
}
}
// parms[0]: nt
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(parms[0].get());
if (cc != NULL)
{
fNtileNull = false;
fNtile = cc->getIntVal(fRow, fNtileNull); // row not used, no need to setData.
if (!fNtileNull && fNtile <= 0)
{
ostringstream oss;
oss << fNtile;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(ERR_WF_ARG_OUT_OF_RANGE,
oss.str()), ERR_WF_ARG_OUT_OF_RANGE);
}
}
}
void WF_ntile::operator()(int64_t b, int64_t e, int64_t c)
{
int64_t idx = fFieldIndex[1];
if (idx != -1)
{
fRow.setData(getPointer(fRowData->at(b)));
if (idx != -1)
{
double tmp = 1.0;
fNtileNull = fRow.isNullValue(idx);
if (!fNtileNull)
implicit2T(idx, tmp, 0);
int64_t idx = fFieldIndex[1];
if (!fNtileNull && tmp <= 0)
{
ostringstream oss;
oss << tmp;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(ERR_WF_ARG_OUT_OF_RANGE,
oss.str()), ERR_WF_ARG_OUT_OF_RANGE);
}
if (idx != -1)
{
fRow.setData(getPointer(fRowData->at(b)));
if (tmp > e) // prevent integer overflow
tmp = e + 1;
if (idx != -1)
{
double tmp = 1.0;
fNtileNull = fRow.isNullValue(idx);
fNtile = (int64_t) tmp;
}
}
if (!fNtileNull)
implicit2T(idx, tmp, 0);
c = b;
if (!fNtileNull)
{
int64_t rowPerBucket = (e - b + 1) / fNtile;
int64_t n = rowPerBucket * fNtile;
int64_t x = (e-b+1) - n; // extra
int64_t y = 0;
int64_t z = 0;
if (!fNtileNull && tmp <= 0)
{
ostringstream oss;
oss << tmp;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(ERR_WF_ARG_OUT_OF_RANGE,
oss.str()), ERR_WF_ARG_OUT_OF_RANGE);
}
while (c <= e)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
if (tmp > e) // prevent integer overflow
tmp = e + 1;
y = rowPerBucket + ((x-- > 0) ? 1 : 0);
z++;
for (int64_t i = 0; i < y && c <= e; i++)
{
fRow.setData(getPointer(fRowData->at(c++)));
setIntValue(fFieldIndex[0], z);
}
}
}
else
{
while (c <= e)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
fNtile = (int64_t) tmp;
}
}
fRow.setData(getPointer(fRowData->at(c++)));
setIntValue(fFieldIndex[0], joblist::BIGINTNULL);
}
}
c = b;
if (!fNtileNull)
{
int64_t rowPerBucket = (e - b + 1) / fNtile;
int64_t n = rowPerBucket * fNtile;
int64_t x = (e - b + 1) - n; // extra
int64_t y = 0;
int64_t z = 0;
while (c <= e)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
y = rowPerBucket + ((x-- > 0) ? 1 : 0);
z++;
for (int64_t i = 0; i < y && c <= e; i++)
{
fRow.setData(getPointer(fRowData->at(c++)));
setIntValue(fFieldIndex[0], z);
}
}
}
else
{
while (c <= e)
{
if (c % 1000 == 0 && fStep->cancelled())
break;
fRow.setData(getPointer(fRowData->at(c++)));
setIntValue(fFieldIndex[0], joblist::BIGINTNULL);
}
}
}