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

@ -40,45 +40,51 @@ using namespace funcexp;
namespace
{
uint64_t makedate(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull)
FunctionParm& parm,
bool& isNull)
{
int64_t year = 0;
string dayofyear;
int64_t year = 0;
string dayofyear;
//get year
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
double value = parm[0]->data()->getDoubleVal(row, isNull);
year = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
year = d.value / helpers::power(d.scale);
int lefto = (d.value - year * helpers::power(d.scale)) / helpers::power(d.scale - 1);
if ( year >= 0 && lefto > 4 )
year++;
if ( year < 0 && lefto < -4 )
year--;
break;
}
default:
isNull = true;
return 0;
}
//get year
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
double value = parm[0]->data()->getDoubleVal(row, isNull);
year = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
year = d.value / helpers::power(d.scale);
int lefto = (d.value - year * helpers::power(d.scale)) / helpers::power(d.scale-1);
if ( year >= 0 && lefto > 4 )
year++;
if ( year < 0 && lefto < -4 )
year--;
break;
}
default:
isNull = true;
return 0;
}
if (year < 70)
{
year = 2000 + year;
@ -87,74 +93,80 @@ uint64_t makedate(rowgroup::Row& row,
{
year = 1900 + year;
}
else if (year < 1000 || year > 9999) {
isNull = true;
return 0;
}
else if (year < 1000 || year > 9999)
{
isNull = true;
return 0;
}
//get dayofyear
switch (parm[1]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
dayofyear = parm[1]->data()->getStrVal(row, isNull);
//get dayofyear
switch (parm[1]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
dayofyear = parm[1]->data()->getStrVal(row, isNull);
if (atoi(dayofyear.c_str()) < 1)
{
isNull = true;
return 0;
}
if (atoi(dayofyear.c_str()) < 1)
{
isNull = true;
return 0;
}
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[1]->data()->getDecimalVal(row, isNull);
int64_t tmp = d.value / helpers::power(d.scale);
int lefto = (d.value - tmp * helpers::power(d.scale)) / helpers::power(d.scale-1);
if ( tmp >= 0 && lefto > 4 )
tmp++;
if ( tmp < 0 && lefto < -4 )
tmp--;
break;
}
if (tmp < 1)
{
isNull = true;
return 0;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[1]->data()->getDecimalVal(row, isNull);
int64_t tmp = d.value / helpers::power(d.scale);
int lefto = (d.value - tmp * helpers::power(d.scale)) / helpers::power(d.scale - 1);
if ( tmp >= 0 && lefto > 4 )
tmp++;
if ( tmp < 0 && lefto < -4 )
tmp--;
if (tmp < 1)
{
isNull = true;
return 0;
}
dayofyear = helpers::intToString(tmp);
break;
}
default:
isNull = true;
return 0;
}
break;
}
default:
isNull = true;
return 0;
}
// convert the year to a date in our internal format, then subtract
// one since we are about to add the day of year back in
Date d(year,1,1);
Date d(year, 1, 1);
//@Bug 5232. spare bit is set, cannot use regular substraction
d.day -= 1;
//uint64_t intDate = ((*(reinterpret_cast<uint32_t *> (&d))) & 0xFFFFFFC) - 1;
uint64_t intDate = *(reinterpret_cast<uint32_t *> (&d));
uint64_t intDate = *(reinterpret_cast<uint32_t*> (&d));
uint64_t value = helpers::dateAdd( intDate, dayofyear, IntervalColumn::INTERVAL_DAY, true, OP_ADD );
uint64_t value = helpers::dateAdd( intDate, dayofyear, IntervalColumn::INTERVAL_DAY, true, OP_ADD );
if ( value == 0 ) {
isNull = true;
}
if ( value == 0 )
{
isNull = true;
}
return value;
return value;
}
}
@ -165,29 +177,30 @@ namespace funcexp
CalpontSystemCatalog::ColType Func_makedate::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_makedate::getIntVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
{
return makedate(row, parm, isNull);
return makedate(row, parm, isNull);
}
string Func_makedate::getStrVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
{
uint64_t value = makedate(row, parm, isNull);
if (isNull)
return "";
uint64_t value = makedate(row, parm, isNull);
return dataconvert::DataConvert::dateToString(value);
if (isNull)
return "";
return dataconvert::DataConvert::dateToString(value);
}