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

@ -42,100 +42,117 @@ namespace
using namespace funcexp;
dataconvert::DateTime getDateTime (rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType&)
{
TimeExtractor extractor;
dataconvert::DateTime dateTime;
dateTime.year = 0;
dateTime.month = 0;
dateTime.day = 0;
dateTime.hour = 0;
dateTime.minute = 0;
dateTime.second = 0;
dateTime.msecond = 0;
int64_t val = 0;
string valStr;
const string& formatStr = parm[1]->data()->getStrVal(row, isNull);
int rc = 0;
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::DATE:
{
val = parm[0]->data()->getIntVal(row, isNull);
valStr = dataconvert::DataConvert::dateToString (val);
rc = extractor.extractTime (valStr, formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::DATETIME:
{
val = parm[0]->data()->getIntVal(row, isNull);
valStr = dataconvert::DataConvert::datetimeToString (val);
rc = extractor.extractTime (valStr, formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
const string& valref = parm[0]->data()->getStrVal(row, isNull);
//decode with provided format
rc = extractor.extractTime (valref, formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
{
val = parm[0]->data()->getIntVal(row, isNull);
//decode with provided format
rc = extractor.extractTime (helpers::intToString(val), formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::DECIMAL:
{
if (parm[0]->data()->resultType().scale == 0)
{
val = parm[0]->data()->getIntVal(row, isNull);
//decode with provided format
rc = extractor.extractTime (helpers::intToString(val), formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
}
break;
}
default:
isNull = true;
return -1;
}
return dateTime;
TimeExtractor extractor;
dataconvert::DateTime dateTime;
dateTime.year = 0;
dateTime.month = 0;
dateTime.day = 0;
dateTime.hour = 0;
dateTime.minute = 0;
dateTime.second = 0;
dateTime.msecond = 0;
int64_t val = 0;
string valStr;
const string& formatStr = parm[1]->data()->getStrVal(row, isNull);
int rc = 0;
switch (parm[0]->data()->resultType().colDataType)
{
case CalpontSystemCatalog::DATE:
{
val = parm[0]->data()->getIntVal(row, isNull);
valStr = dataconvert::DataConvert::dateToString (val);
rc = extractor.extractTime (valStr, formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::DATETIME:
{
val = parm[0]->data()->getIntVal(row, isNull);
valStr = dataconvert::DataConvert::datetimeToString (val);
rc = extractor.extractTime (valStr, formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR:
{
const string& valref = parm[0]->data()->getStrVal(row, isNull);
//decode with provided format
rc = extractor.extractTime (valref, formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::INT:
{
val = parm[0]->data()->getIntVal(row, isNull);
//decode with provided format
rc = extractor.extractTime (helpers::intToString(val), formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
break;
}
case CalpontSystemCatalog::DECIMAL:
{
if (parm[0]->data()->resultType().scale == 0)
{
val = parm[0]->data()->getIntVal(row, isNull);
//decode with provided format
rc = extractor.extractTime (helpers::intToString(val), formatStr, dateTime);
if ( rc < 0)
{
isNull = true;
return -1;
}
}
break;
}
default:
isNull = true;
return -1;
}
return dateTime;
}
}
@ -145,52 +162,52 @@ namespace funcexp
CalpontSystemCatalog::ColType Func_str_to_date::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
string Func_str_to_date::getStrVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
string convertedDate = dataconvert::DataConvert::datetimeToString(*((long long*) &dateTime));
return convertedDate;
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
string convertedDate = dataconvert::DataConvert::datetimeToString(*((long long*) &dateTime));
return convertedDate;
}
int32_t Func_str_to_date::getDateIntVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
return ((((int32_t)(time >> 32)) & 0xFFFFFFC0) | 0x3E);
}
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
return ((((int32_t)(time >> 32)) & 0xFFFFFFC0) | 0x3E);
}
int64_t Func_str_to_date::getDatetimeIntVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
return time;
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
return time;
}
int64_t Func_str_to_date::getIntVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
return time;
}
dataconvert::DateTime dateTime;
dateTime = getDateTime(row, parm, isNull, ct);
int64_t time = *(reinterpret_cast<int64_t*>(&dateTime));
return time;
}
} // namespace funcexp