You've already forked mariadb-columnstore-engine
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:
@ -48,26 +48,28 @@ inline bool getChar( uint64_t value, char* buf )
|
||||
uint32_t cur_offset = 0; // current index into buf
|
||||
int cur_bitpos = 56; // 8th octet in input val
|
||||
|
||||
while( cur_bitpos >= 0 )
|
||||
{
|
||||
if( ( ( value >> cur_bitpos ) & 0xff ) != 0 )
|
||||
{
|
||||
buf[cur_offset++] = char( ( value >> cur_bitpos ) & 0xff );
|
||||
}
|
||||
cur_bitpos -= 8;
|
||||
}
|
||||
buf[cur_offset] = '\0';
|
||||
while ( cur_bitpos >= 0 )
|
||||
{
|
||||
if ( ( ( value >> cur_bitpos ) & 0xff ) != 0 )
|
||||
{
|
||||
buf[cur_offset++] = char( ( value >> cur_bitpos ) & 0xff );
|
||||
}
|
||||
|
||||
return true;
|
||||
cur_bitpos -= 8;
|
||||
}
|
||||
|
||||
buf[cur_offset] = '\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// see comment above regarding buf assumptions
|
||||
inline bool getChar( int64_t value, char* buf )
|
||||
{
|
||||
if ( value < 0 )
|
||||
return false;
|
||||
else
|
||||
return getChar( (uint64_t) value, buf );
|
||||
if ( value < 0 )
|
||||
return false;
|
||||
else
|
||||
return getChar( (uint64_t) value, buf );
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,35 +77,36 @@ namespace funcexp
|
||||
{
|
||||
CalpontSystemCatalog::ColType Func_char::operationType(FunctionParm& fp, CalpontSystemCatalog::ColType& resultType)
|
||||
{
|
||||
// operation type is not used by this functor
|
||||
return fp[0]->data()->resultType();
|
||||
// operation type is not used by this functor
|
||||
return fp[0]->data()->resultType();
|
||||
}
|
||||
|
||||
string Func_char::getStrVal(Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
const int BUF_SIZE = 9; // see comment above for size requirement
|
||||
const int BUF_SIZE = 9; // see comment above for size requirement
|
||||
char buf[BUF_SIZE];
|
||||
|
||||
switch (ct.colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
{
|
||||
int64_t value = parm[0]->data()->getIntVal(row, isNull);
|
||||
switch (ct.colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
{
|
||||
int64_t value = parm[0]->data()->getIntVal(row, isNull);
|
||||
|
||||
if ( !getChar(value, buf) )
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
if ( !getChar(value, buf) ) {
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
@ -112,7 +115,8 @@ string Func_char::getStrVal(Row& row,
|
||||
{
|
||||
uint64_t value = parm[0]->data()->getUintVal(row, isNull);
|
||||
|
||||
if ( !getChar(value, buf) ) {
|
||||
if ( !getChar(value, buf) )
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
@ -120,72 +124,80 @@ string Func_char::getStrVal(Row& row,
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR: // including CHAR'
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
{
|
||||
double value = parm[0]->data()->getDoubleVal(row, isNull);
|
||||
if ( !getChar((int64_t)value, buf) ) {
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
{
|
||||
double value = parm[0]->data()->getDoubleVal(row, isNull);
|
||||
|
||||
if ( !getChar((int64_t)value, buf) )
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
{
|
||||
float value = parm[0]->data()->getFloatVal(row, isNull);
|
||||
if ( !getChar((int64_t)value, buf) ) {
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
{
|
||||
float value = parm[0]->data()->getFloatVal(row, isNull);
|
||||
|
||||
if ( !getChar((int64_t)value, buf) )
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
|
||||
// get decimal and round up
|
||||
int value = d.value / helpers::power(d.scale);
|
||||
int lefto = (d.value - value * helpers::power(d.scale)) / helpers::power(d.scale-1);
|
||||
if ( lefto > 4 )
|
||||
value++;
|
||||
if ( !getChar((int64_t)value, buf) ) {
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
|
||||
// get decimal and round up
|
||||
int value = d.value / helpers::power(d.scale);
|
||||
int lefto = (d.value - value * helpers::power(d.scale)) / helpers::power(d.scale - 1);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
break;
|
||||
if ( lefto > 4 )
|
||||
value++;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "char: datatype of " << execplan::colDataTypeToString(ct.colDataType);
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
}
|
||||
// Bug 5110 : Here the data in col is null. But there might have other
|
||||
// non-null columns we processed before and we do not want entire value
|
||||
// to become null. Therefore we set isNull flag to false.
|
||||
if(isNull)
|
||||
{
|
||||
isNull = false;
|
||||
return "";
|
||||
}
|
||||
if ( !getChar((int64_t)value, buf) )
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
return buf;
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "char: datatype of " << execplan::colDataTypeToString(ct.colDataType);
|
||||
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Bug 5110 : Here the data in col is null. But there might have other
|
||||
// non-null columns we processed before and we do not want entire value
|
||||
// to become null. Therefore we set isNull flag to false.
|
||||
if (isNull)
|
||||
{
|
||||
isNull = false;
|
||||
return "";
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user