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

@ -40,147 +40,162 @@ namespace funcexp
CalpontSystemCatalog::ColType Func_maketime::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
string Func_maketime::getStrVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
{
int64_t hour = 0;
int64_t min = 0;
int64_t sec = 0;
int64_t hour = 0;
int64_t min = 0;
int64_t sec = 0;
//get hour
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);
hour = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
hour = d.value / helpers::power(d.scale);
int lefto = (d.value - hour * helpers::power(d.scale)) / helpers::power(d.scale-1);
if ( hour >= 0 && lefto > 4 )
hour++;
if ( hour < 0 && lefto < -4 )
hour--;
break;
}
default:
isNull = true;
return "";
}
//get hour
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);
hour = (int64_t) value;
break;
}
//get minute
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:
{
double value = parm[1]->data()->getDoubleVal(row, isNull);
min = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[1]->data()->getDecimalVal(row, isNull);
min = d.value / helpers::power(d.scale);
int lefto = (d.value - min * helpers::power(d.scale)) / helpers::power(d.scale-1);
if ( min >= 0 && lefto > 4 )
min++;
if ( min < 0 && lefto < -4 )
min--;
break;
}
default:
isNull = true;
return "";
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
hour = d.value / helpers::power(d.scale);
int lefto = (d.value - hour * helpers::power(d.scale)) / helpers::power(d.scale - 1);
if (min < 0 || min > 59)
{
isNull = true;
return "";
}
if ( hour >= 0 && lefto > 4 )
hour++;
//get second
switch (parm[2]->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[2]->data()->getDoubleVal(row, isNull);
sec = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[2]->data()->getDecimalVal(row, isNull);
sec = d.value / helpers::power(d.scale);
int lefto = (d.value - sec * helpers::power(d.scale)) / helpers::power(d.scale-1);
if ( sec >= 0 && lefto > 4 )
sec++;
if ( sec < 0 && lefto < -4 )
sec--;
break;
}
default:
isNull = true;
return "";
}
if ( hour < 0 && lefto < -4 )
hour--;
if (sec < 0 || sec > 59)
{
isNull = true;
return "";
}
break;
}
if (hour > 838)
{
hour = 838;
min = 59;
sec = 59;
}
default:
isNull = true;
return "";
}
if (hour < -838)
{
hour = -838;
min = 59;
sec = 59;
}
//get minute
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:
{
double value = parm[1]->data()->getDoubleVal(row, isNull);
min = (int64_t) value;
break;
}
// in worst case hour is 4 characters (3 digits + '-') so max
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[1]->data()->getDecimalVal(row, isNull);
min = d.value / helpers::power(d.scale);
int lefto = (d.value - min * helpers::power(d.scale)) / helpers::power(d.scale - 1);
if ( min >= 0 && lefto > 4 )
min++;
if ( min < 0 && lefto < -4 )
min--;
break;
}
default:
isNull = true;
return "";
}
if (min < 0 || min > 59)
{
isNull = true;
return "";
}
//get second
switch (parm[2]->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[2]->data()->getDoubleVal(row, isNull);
sec = (int64_t) value;
break;
}
case CalpontSystemCatalog::DECIMAL:
{
IDB_Decimal d = parm[2]->data()->getDecimalVal(row, isNull);
sec = d.value / helpers::power(d.scale);
int lefto = (d.value - sec * helpers::power(d.scale)) / helpers::power(d.scale - 1);
if ( sec >= 0 && lefto > 4 )
sec++;
if ( sec < 0 && lefto < -4 )
sec--;
break;
}
default:
isNull = true;
return "";
}
if (sec < 0 || sec > 59)
{
isNull = true;
return "";
}
if (hour > 838)
{
hour = 838;
min = 59;
sec = 59;
}
if (hour < -838)
{
hour = -838;
min = 59;
sec = 59;
}
// in worst case hour is 4 characters (3 digits + '-') so max
// string length is 11 (4:2:2 + '\0')
char buf[11];
snprintf(buf, 11, "%02d:%02d:%02d", (int) hour, (int) min, (int) sec);