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

@ -52,26 +52,26 @@ using namespace funcexp;
// and could be extracted into a utility class with its own header
// if that is the case - this is left as future exercise
bool getUIntValFromParm(
Row& row,
const execplan::SPTP& parm,
uint64_t& value,
bool& isNull)
Row& row,
const execplan::SPTP& parm,
uint64_t& value,
bool& isNull)
{
switch (parm->data()->resultType().colDataType)
{
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::FLOAT:
switch (parm->data()->resultType().colDataType)
{
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UDOUBLE:
case execplan::CalpontSystemCatalog::UFLOAT:
{
value = parm->data()->getIntVal(row, isNull);
}
break;
{
value = parm->data()->getIntVal(row, isNull);
}
break;
case execplan::CalpontSystemCatalog::UBIGINT:
case execplan::CalpontSystemCatalog::UINT:
@ -84,65 +84,72 @@ bool getUIntValFromParm(
break;
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
{
value = parm->data()->getIntVal(row, isNull);
if (isNull)
{
isNull = true;
}
else
{
value = 0;
}
}
break;
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
{
value = parm->data()->getIntVal(row, isNull);
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
IDB_Decimal d = parm->data()->getDecimalVal(row, isNull);
if (parm->data()->resultType().colDataType == execplan::CalpontSystemCatalog::UDECIMAL &&
d.value < 0)
{
d.value = 0;
}
int64_t tmpval = d.value / helpers::power(d.scale);
int lefto = (d.value - tmpval * helpers::power(d.scale)) / helpers::power(d.scale-1);
if ( tmpval >= 0 && lefto > 4 )
tmpval++;
if ( tmpval < 0 && lefto < -4 )
tmpval--;
value = tmpval;
}
break;
if (isNull)
{
isNull = true;
}
else
{
value = 0;
}
}
break;
case execplan::CalpontSystemCatalog::DATE:
{
int32_t time = parm->data()->getDateIntVal(row, isNull);
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
IDB_Decimal d = parm->data()->getDecimalVal(row, isNull);
Date d(time);
value = d.convertToMySQLint();
}
break;
if (parm->data()->resultType().colDataType == execplan::CalpontSystemCatalog::UDECIMAL &&
d.value < 0)
{
d.value = 0;
}
case execplan::CalpontSystemCatalog::DATETIME:
{
int64_t time = parm->data()->getDatetimeIntVal(row, isNull);
int64_t tmpval = d.value / helpers::power(d.scale);
int lefto = (d.value - tmpval * helpers::power(d.scale)) / helpers::power(d.scale - 1);
// @bug 4703 - missing year when convering to int
DateTime dt(time);
value = dt.convertToMySQLint();
}
break;
if ( tmpval >= 0 && lefto > 4 )
tmpval++;
default:
{
return false;
}
}
return true;
if ( tmpval < 0 && lefto < -4 )
tmpval--;
value = tmpval;
}
break;
case execplan::CalpontSystemCatalog::DATE:
{
int32_t time = parm->data()->getDateIntVal(row, isNull);
Date d(time);
value = d.convertToMySQLint();
}
break;
case execplan::CalpontSystemCatalog::DATETIME:
{
int64_t time = parm->data()->getDatetimeIntVal(row, isNull);
// @bug 4703 - missing year when convering to int
DateTime dt(time);
value = dt.convertToMySQLint();
}
break;
default:
{
return false;
}
}
return true;
}
}
@ -156,30 +163,32 @@ namespace funcexp
CalpontSystemCatalog::ColType Func_bitand::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_bitand::getIntVal(Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
{
if ( parm.size() < 2 ) {
isNull = true;
return 0;
}
if ( parm.size() < 2 )
{
isNull = true;
return 0;
}
uint64_t val1 = 0;
uint64_t val2 = 0;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "bitand: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
uint64_t val1 = 0;
uint64_t val2 = 0;
return val1 & val2;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "bitand: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
return val1 & val2;
}
@ -190,30 +199,32 @@ int64_t Func_bitand::getIntVal(Row& row,
CalpontSystemCatalog::ColType Func_leftshift::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_leftshift::getIntVal(Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
{
if ( parm.size() < 2 ) {
isNull = true;
return 0;
}
if ( parm.size() < 2 )
{
isNull = true;
return 0;
}
uint64_t val1 = 0;
uint64_t val2 = 0;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "leftshift: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
uint64_t val1 = 0;
uint64_t val2 = 0;
return val1 << val2;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "leftshift: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
return val1 << val2;
}
@ -224,30 +235,32 @@ int64_t Func_leftshift::getIntVal(Row& row,
CalpontSystemCatalog::ColType Func_rightshift::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_rightshift::getIntVal(Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
{
if ( parm.size() < 2 ) {
isNull = true;
return 0;
}
if ( parm.size() < 2 )
{
isNull = true;
return 0;
}
uint64_t val1 = 0;
uint64_t val2 = 0;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "rightshift: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
uint64_t val1 = 0;
uint64_t val2 = 0;
return val1 >> val2;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "rightshift: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
return val1 >> val2;
}
@ -258,7 +271,7 @@ int64_t Func_rightshift::getIntVal(Row& row,
CalpontSystemCatalog::ColType Func_bitor::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_bitor::getIntVal(Row& row,
@ -266,30 +279,32 @@ int64_t Func_bitor::getIntVal(Row& row,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
{
if ( parm.size() < 2 ) {
isNull = true;
return 0;
}
if ( parm.size() < 2 )
{
isNull = true;
return 0;
}
uint64_t val1 = 0;
uint64_t val2 = 0;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "bitor: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
uint64_t val1 = 0;
uint64_t val2 = 0;
return val1 | val2;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "bitor: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
return val1 | val2;
}
uint64_t Func_bitor::getUintVal(rowgroup::Row& row,
FunctionParm& fp,
bool& isNull,
execplan::CalpontSystemCatalog::ColType& op_ct)
{
return static_cast<uint64_t>(getIntVal(row,fp,isNull,op_ct));
{
return static_cast<uint64_t>(getIntVal(row, fp, isNull, op_ct));
}
@ -300,30 +315,32 @@ uint64_t Func_bitor::getUintVal(rowgroup::Row& row,
CalpontSystemCatalog::ColType Func_bitxor::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
int64_t Func_bitxor::getIntVal(Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& operationColType)
{
if ( parm.size() < 2 ) {
isNull = true;
return 0;
}
if ( parm.size() < 2 )
{
isNull = true;
return 0;
}
uint64_t val1 = 0;
uint64_t val2 = 0;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "bitxor: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
uint64_t val1 = 0;
uint64_t val2 = 0;
return val1 ^ val2;
if (!getUIntValFromParm(row, parm[0], val1, isNull) ||
!getUIntValFromParm(row, parm[1], val2, isNull))
{
std::ostringstream oss;
oss << "bitxor: datatype of " << execplan::colDataTypeToString(operationColType.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
return val1 ^ val2;
}