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:
@ -41,15 +41,17 @@ namespace
|
||||
{
|
||||
char digit_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
void octet2hex(char *to, const char *str, uint32_t len)
|
||||
void octet2hex(char* to, const char* str, uint32_t len)
|
||||
{
|
||||
const char *str_end= str + len;
|
||||
for (; str != str_end; ++str)
|
||||
{
|
||||
*to++= digit_upper[((uint8_t) *str) >> 4];
|
||||
*to++= digit_upper[((uint8_t) *str) & 0x0F];
|
||||
}
|
||||
*to = '\0';
|
||||
const char* str_end = str + len;
|
||||
|
||||
for (; str != str_end; ++str)
|
||||
{
|
||||
*to++ = digit_upper[((uint8_t) * str) >> 4];
|
||||
*to++ = digit_upper[((uint8_t) * str) & 0x0F];
|
||||
}
|
||||
|
||||
*to = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,64 +59,70 @@ namespace funcexp
|
||||
{
|
||||
CalpontSystemCatalog::ColType Func_hex::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
|
||||
{
|
||||
return resultType;
|
||||
return resultType;
|
||||
}
|
||||
|
||||
string Func_hex::getStrVal(rowgroup::Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
string retval;
|
||||
uint64_t dec;
|
||||
char ans[65];
|
||||
uint64_t dec;
|
||||
char ans[65];
|
||||
|
||||
switch (parm[0]->data()->resultType().colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
case CalpontSystemCatalog::DATE:
|
||||
{
|
||||
const string& arg= parm[0]->data()->getStrVal(row, isNull);
|
||||
scoped_array<char> hexPtr(new char[strlen(arg.c_str())*2+1]);
|
||||
octet2hex(hexPtr.get(), arg.c_str(), strlen(arg.c_str()));
|
||||
return string(hexPtr.get(), strlen(arg.c_str())*2);
|
||||
}
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::FLOAT:
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
/* Return hex of unsigned longlong value */
|
||||
double val= parm[0]->data()->getDoubleVal(row, isNull);
|
||||
if ((val <= (double) numeric_limits<int64_t>::min()) ||
|
||||
(val >= (double) numeric_limits<int64_t>::max()))
|
||||
dec= ~(int64_t) 0;
|
||||
else
|
||||
dec= (uint64_t) (val + (val > 0 ? 0.5 : -0.5));
|
||||
retval = helpers::convNumToStr(dec, ans, 16);
|
||||
break;
|
||||
}
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
switch (parm[0]->data()->resultType().colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
case CalpontSystemCatalog::DATE:
|
||||
{
|
||||
const string& arg = parm[0]->data()->getStrVal(row, isNull);
|
||||
scoped_array<char> hexPtr(new char[strlen(arg.c_str()) * 2 + 1]);
|
||||
octet2hex(hexPtr.get(), arg.c_str(), strlen(arg.c_str()));
|
||||
return string(hexPtr.get(), strlen(arg.c_str()) * 2);
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::FLOAT:
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
/* Return hex of unsigned longlong value */
|
||||
double val = parm[0]->data()->getDoubleVal(row, isNull);
|
||||
|
||||
if ((val <= (double) numeric_limits<int64_t>::min()) ||
|
||||
(val >= (double) numeric_limits<int64_t>::max()))
|
||||
dec = ~(int64_t) 0;
|
||||
else
|
||||
dec = (uint64_t) (val + (val > 0 ? 0.5 : -0.5));
|
||||
|
||||
retval = helpers::convNumToStr(dec, ans, 16);
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
case CalpontSystemCatalog::BLOB:
|
||||
{
|
||||
const string& arg = parm[0]->data()->getStrVal(row, isNull);
|
||||
uint64_t hexLen = arg.size() * 2;
|
||||
scoped_array<char> hexPtr(new char[hexLen + 1]); // "+ 1" for the last \0
|
||||
octet2hex(hexPtr.get(), arg.data(), arg.size());
|
||||
return string(hexPtr.get(), hexLen);
|
||||
}
|
||||
default:
|
||||
{
|
||||
dec= (uint64_t)parm[0]->data()->getIntVal(row, isNull);
|
||||
retval = helpers::convNumToStr(dec, ans, 16);
|
||||
if (retval.length() > (uint32_t)ct.colWidth)
|
||||
retval = retval.substr(retval.length()-ct.colWidth, ct.colWidth);
|
||||
}
|
||||
}
|
||||
{
|
||||
const string& arg = parm[0]->data()->getStrVal(row, isNull);
|
||||
uint64_t hexLen = arg.size() * 2;
|
||||
scoped_array<char> hexPtr(new char[hexLen + 1]); // "+ 1" for the last \0
|
||||
octet2hex(hexPtr.get(), arg.data(), arg.size());
|
||||
return string(hexPtr.get(), hexLen);
|
||||
}
|
||||
|
||||
return retval;
|
||||
default:
|
||||
{
|
||||
dec = (uint64_t)parm[0]->data()->getIntVal(row, isNull);
|
||||
retval = helpers::convNumToStr(dec, ans, 16);
|
||||
|
||||
if (retval.length() > (uint32_t)ct.colWidth)
|
||||
retval = retval.substr(retval.length() - ct.colWidth, ct.colWidth);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user