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

@ -39,45 +39,91 @@ namespace funcexp
CalpontSystemCatalog::ColType Func_time_to_sec::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& op_ct)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& op_ct)
{
// assume 256 is enough. assume not allowing incomplete date
uint32_t hour = 0,
min = 0,
sec = 0;
// assume 256 is enough. assume not allowing incomplete date
uint32_t hour = 0,
min = 0,
sec = 0;
bool bIsNegative = false; // Only set to true if CHAR or VARCHAR with a '-'
int64_t val = 0;
dataconvert::Time tval;
int64_t val = 0;
dataconvert::Time tval;
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::DATE:
return 0;
case CalpontSystemCatalog::DATETIME:
val = parm[0]->data()->getIntVal(row, isNull);
hour = (uint32_t)((val >> 32) & 0x3f);
min = (uint32_t)((val >> 26) & 0x3f);
sec = (uint32_t)((val >> 20) & 0x3f);
break;
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::DATE:
return 0;
case CalpontSystemCatalog::DATETIME:
val = parm[0]->data()->getIntVal(row, isNull);
hour = (uint32_t)((val >> 32) & 0x3f);
min = (uint32_t)((val >> 26) & 0x3f);
sec = (uint32_t)((val >> 20) & 0x3f);
break;
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
std::string strVal = parm[0]->data()->getStrVal(row, isNull);
if (strVal[0] == '-')
{
std::string strVal = parm[0]->data()->getStrVal(row, isNull);
if (strVal[0] == '-')
{
bIsNegative = true;
strVal.replace(0, 1, 1, ' ');
}
val = dataconvert::DataConvert::stringToTime(strVal);
bIsNegative = true;
strVal.replace(0, 1, 1, ' ');
}
val = dataconvert::DataConvert::stringToTime(strVal);
if (val == -1)
{
isNull = true;
return -1;
}
else
{
tval = *(reinterpret_cast<dataconvert::Time*>(&val));
hour = (uint32_t)(tval.hour);
min = (uint32_t)(tval.minute);
sec = (uint32_t)(tval.second);
}
}
break;
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
if (val == -1)
{
isNull = true;
return -1;
}
else
{
hour = (uint32_t)((val >> 32) & 0x3f);
min = (uint32_t)((val >> 26) & 0x3f);
sec = (uint32_t)((val >> 20) & 0x3f);
}
break;
case CalpontSystemCatalog::DECIMAL:
if (parm[0]->data()->resultType().scale == 0)
{
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
if (val == -1)
{
isNull = true;
@ -85,58 +131,27 @@ int64_t Func_time_to_sec::getIntVal(rowgroup::Row& row,
}
else
{
tval = *(reinterpret_cast<dataconvert::Time*>(&val));
hour = (uint32_t)(tval.hour);
min = (uint32_t)(tval.minute);
sec = (uint32_t)(tval.second);
hour = (uint32_t)((val >> 32) & 0x3f);
min = (uint32_t)((val >> 26) & 0x3f);
sec = (uint32_t)((val >> 20) & 0x3f);
}
}
break;
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
if (val == -1)
{
isNull = true;
return -1;
}
else
{
hour = (uint32_t)((val >> 32) & 0x3f);
min = (uint32_t)((val >> 26) & 0x3f);
sec = (uint32_t)((val >> 20) & 0x3f);
}
break;
case CalpontSystemCatalog::DECIMAL:
if (parm[0]->data()->resultType().scale == 0)
{
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
if (val == -1)
{
isNull = true;
return -1;
}
else
{
hour = (uint32_t)((val >> 32) & 0x3f);
min = (uint32_t)((val >> 26) & 0x3f);
sec = (uint32_t)((val >> 20) & 0x3f);
}
}
break;
default:
isNull = true;
return -1;
}
int64_t rtn = (int64_t)(hour*60*60)+(min*60)+sec;
break;
default:
isNull = true;
return -1;
}
int64_t rtn = (int64_t)(hour * 60 * 60) + (min * 60) + sec;
if (bIsNegative)
{
rtn *= -1;
}
return rtn;
return rtn;
}