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

@ -26,7 +26,7 @@
using namespace std;
#ifdef __linux__
#include <regex.h>
#include <regex.h>
#else
#include <boost/regex.hpp>
using namespace boost;
@ -47,146 +47,155 @@ using namespace logging;
namespace
{
inline bool getBool(rowgroup::Row& row,
funcexp::FunctionParm& pm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
string expr;
string pattern;
inline bool getBool(rowgroup::Row& row,
funcexp::FunctionParm& pm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
switch (pm[0]->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::UBIGINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::VARCHAR: // including CHAR'
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
{
expr = pm[0]->data()->getStrVal(row, isNull);
break;
}
case execplan::CalpontSystemCatalog::DATE:
{
expr = dataconvert::DataConvert::dateToString(pm[0]->data()->getDateIntVal(row, isNull));
break;
}
case execplan::CalpontSystemCatalog::DATETIME:
{
expr = dataconvert::DataConvert::datetimeToString(pm[0]->data()->getDatetimeIntVal(row, isNull));
//strip off micro seconds
expr = expr.substr(0,19);
break;
}
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
IDB_Decimal d = pm[0]->data()->getDecimalVal(row, isNull);
char buf[80];
dataconvert::DataConvert::decimalToString(d.value, d.scale, buf, 80, pm[0]->data()->resultType().colDataType);
expr = buf;
break;
}
string expr;
string pattern;
default:
{
std::ostringstream oss;
oss << "regexp: datatype of " << execplan::colDataTypeToString(ct.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
}
switch (pm[0]->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::UBIGINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::VARCHAR: // including CHAR'
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
{
expr = pm[0]->data()->getStrVal(row, isNull);
break;
}
switch (pm[1]->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::UBIGINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::VARCHAR: // including CHAR'
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
{
pattern = pm[1]->data()->getStrVal(row, isNull);
break;
}
case execplan::CalpontSystemCatalog::DATE:
{
pattern = dataconvert::DataConvert::dateToString(pm[1]->data()->getDateIntVal(row, isNull));
break;
}
case execplan::CalpontSystemCatalog::DATETIME:
{
pattern = dataconvert::DataConvert::datetimeToString(pm[1]->data()->getDatetimeIntVal(row, isNull));
//strip off micro seconds
pattern = pattern.substr(0,19);
break;
}
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
IDB_Decimal d = pm[1]->data()->getDecimalVal(row, isNull);
char buf[80];
dataconvert::DataConvert::decimalToString( d.value, d.scale, buf, 80, pm[1]->data()->resultType().colDataType);
pattern = buf;
break;
}
default:
{
std::ostringstream oss;
oss << "regexp: datatype of " << execplan::colDataTypeToString(ct.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
}
case execplan::CalpontSystemCatalog::DATE:
{
expr = dataconvert::DataConvert::dateToString(pm[0]->data()->getDateIntVal(row, isNull));
break;
}
case execplan::CalpontSystemCatalog::DATETIME:
{
expr = dataconvert::DataConvert::datetimeToString(pm[0]->data()->getDatetimeIntVal(row, isNull));
//strip off micro seconds
expr = expr.substr(0, 19);
break;
}
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
IDB_Decimal d = pm[0]->data()->getDecimalVal(row, isNull);
char buf[80];
dataconvert::DataConvert::decimalToString(d.value, d.scale, buf, 80, pm[0]->data()->resultType().colDataType);
expr = buf;
break;
}
default:
{
std::ostringstream oss;
oss << "regexp: datatype of " << execplan::colDataTypeToString(ct.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
}
switch (pm[1]->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::UBIGINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::VARCHAR: // including CHAR'
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT:
{
pattern = pm[1]->data()->getStrVal(row, isNull);
break;
}
case execplan::CalpontSystemCatalog::DATE:
{
pattern = dataconvert::DataConvert::dateToString(pm[1]->data()->getDateIntVal(row, isNull));
break;
}
case execplan::CalpontSystemCatalog::DATETIME:
{
pattern = dataconvert::DataConvert::datetimeToString(pm[1]->data()->getDatetimeIntVal(row, isNull));
//strip off micro seconds
pattern = pattern.substr(0, 19);
break;
}
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
IDB_Decimal d = pm[1]->data()->getDecimalVal(row, isNull);
char buf[80];
dataconvert::DataConvert::decimalToString( d.value, d.scale, buf, 80, pm[1]->data()->resultType().colDataType);
pattern = buf;
break;
}
default:
{
std::ostringstream oss;
oss << "regexp: datatype of " << execplan::colDataTypeToString(ct.colDataType);
throw logging::IDBExcept(oss.str(), ERR_DATATYPE_NOT_SUPPORT);
}
}
#ifdef __linux__
regex_t re;
regex_t re;
regcomp(&re, pattern.c_str(), REG_EXTENDED | REG_NOSUB );
regcomp(&re, pattern.c_str(), REG_EXTENDED | REG_NOSUB );
int res = regexec(&re, expr.c_str(), 0, NULL, 0);
regfree(&re);
if (res == 0)
return true;
else
return false;
int res = regexec(&re, expr.c_str(), 0, NULL, 0);
regfree(&re);
if (res == 0)
return true;
else
return false;
#else
regex pat(pattern.c_str());
return regex_search(expr.c_str(), pat);
regex pat(pattern.c_str());
return regex_search(expr.c_str(), pat);
#endif
}
}
}
namespace funcexp
@ -194,15 +203,15 @@ namespace funcexp
CalpontSystemCatalog::ColType Func_regexp::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
{
return resultType;
return resultType;
}
bool Func_regexp::getBoolVal(rowgroup::Row& row,
FunctionParm& pm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
FunctionParm& pm,
bool& isNull,
CalpontSystemCatalog::ColType& ct)
{
return getBool(row, pm, isNull, ct) && !isNull;
return getBool(row, pm, isNull, ct) && !isNull;
}