1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-06-12 05:01:56 +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

@ -33,86 +33,98 @@ using namespace std;
bool futf8 = true;
namespace {
namespace
{
/**@brief util struct for converting string to lower case */
struct to_lower
{
char operator() (char c) const { return tolower(c); }
char operator() (char c) const
{
return tolower(c);
}
};
//Trim any leading/trailing ws
const string lrtrim(const string& in)
{
string::size_type p1;
p1 = in.find_first_not_of(" \t\n");
if (p1 == string::npos) p1 = 0;
string::size_type p2;
p2 = in.find_last_not_of(" \t\n");
if (p2 == string::npos) p2 = in.size() - 1;
return string(in, p1, (p2 - p1 + 1));
string::size_type p1;
p1 = in.find_first_not_of(" \t\n");
if (p1 == string::npos) p1 = 0;
string::size_type p2;
p2 = in.find_last_not_of(" \t\n");
if (p2 == string::npos) p2 = in.size() - 1;
return string(in, p1, (p2 - p1 + 1));
}
}
namespace execplan {
namespace execplan
{
/**
* Constructors/Destructors
*/
PredicateOperator::PredicateOperator()
{
Oam oam;
// get and set locale language
string systemLang = "C";
Oam oam;
// get and set locale language
string systemLang = "C";
try{
try
{
oam.getSystemConfig("SystemLang", systemLang);
}
catch(...)
catch (...)
{}
if ( systemLang != "en_US.UTF-8" &&
systemLang.find("UTF") != string::npos )
systemLang.find("UTF") != string::npos )
futf8 = true;
}
PredicateOperator::PredicateOperator(const string& operatorName)
{
Oam oam;
// get and set locale language
string systemLang = "C";
Oam oam;
// get and set locale language
string systemLang = "C";
try{
try
{
oam.getSystemConfig("SystemLang", systemLang);
}
catch(...)
catch (...)
{}
if ( systemLang != "en_US.UTF-8" &&
systemLang.find("UTF") != string::npos )
systemLang.find("UTF") != string::npos )
futf8 = true;
data(operatorName);
}
data(operatorName);
}
PredicateOperator::PredicateOperator(const PredicateOperator& rhs) : Operator(rhs)
{
Oam oam;
// get and set locale language
string systemLang = "C";
Oam oam;
// get and set locale language
string systemLang = "C";
try{
try
{
oam.getSystemConfig("SystemLang", systemLang);
}
catch(...)
catch (...)
{}
if ( systemLang != "en_US.UTF-8" &&
systemLang.find("UTF") != string::npos )
systemLang.find("UTF") != string::npos )
futf8 = true;
data(rhs.data());
data(rhs.data());
}
PredicateOperator:: ~PredicateOperator()
@ -126,165 +138,178 @@ PredicateOperator:: ~PredicateOperator()
/**
* friend function
*/
ostream& operator<<(ostream &output, const PredicateOperator& rhs)
ostream& operator<<(ostream& output, const PredicateOperator& rhs)
{
output << rhs.toString() << endl;
output << "OpType=" << rhs.operationType().colDataType << endl;
return output;
}
output << rhs.toString() << endl;
output << "OpType=" << rhs.operationType().colDataType << endl;
return output;
}
/**
* The serialization interface
*/
void PredicateOperator::serialize(messageqcpp::ByteStream& b) const
{
b << (ObjectReader::id_t) ObjectReader::PREDICATEOPERATOR;
//b << fData;
Operator::serialize(b);
b << (ObjectReader::id_t) ObjectReader::PREDICATEOPERATOR;
//b << fData;
Operator::serialize(b);
}
void PredicateOperator::unserialize(messageqcpp::ByteStream& b)
{
ObjectReader::checkType(b, ObjectReader::PREDICATEOPERATOR);
//b >> fData;
Operator::unserialize(b);
ObjectReader::checkType(b, ObjectReader::PREDICATEOPERATOR);
//b >> fData;
Operator::unserialize(b);
}
bool PredicateOperator::operator==(const PredicateOperator& t) const
{
if (fData == t.fData)
return true;
return false;
if (fData == t.fData)
return true;
return false;
}
bool PredicateOperator::operator==(const TreeNode* t) const
{
const PredicateOperator *o;
const PredicateOperator* o;
o = dynamic_cast<const PredicateOperator*>(t);
if (o == NULL)
return false;
return *this == *o;
o = dynamic_cast<const PredicateOperator*>(t);
if (o == NULL)
return false;
return *this == *o;
}
bool PredicateOperator::operator!=(const PredicateOperator& t) const
{
return (!(*this == t));
return (!(*this == t));
}
bool PredicateOperator::operator!=(const TreeNode* t) const
{
return (!(*this == t));
return (!(*this == t));
}
//FIXME: VARBINARY???
void PredicateOperator::setOpType(Type& l, Type& r)
{
if ( l.colDataType == execplan::CalpontSystemCatalog::DATETIME ||
l.colDataType == execplan::CalpontSystemCatalog::DATE )
{
switch (r.colDataType)
{
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
fOperationType = l;
break;
case execplan::CalpontSystemCatalog::DATETIME:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DATETIME;
fOperationType.colWidth = 8;
break;
case execplan::CalpontSystemCatalog::DATE:
fOperationType = l;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
break;
}
}
else if ( r.colDataType == execplan::CalpontSystemCatalog::DATETIME ||
r.colDataType == execplan::CalpontSystemCatalog::DATE )
{
switch (l.colDataType)
{
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
fOperationType.colWidth = 255;
break;
case execplan::CalpontSystemCatalog::DATETIME:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DATETIME;
fOperationType.colWidth = 8;
break;
case execplan::CalpontSystemCatalog::DATE:
fOperationType = r;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
break;
}
}
else if (l.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
if ( l.colDataType == execplan::CalpontSystemCatalog::DATETIME ||
l.colDataType == execplan::CalpontSystemCatalog::DATE )
{
switch (r.colDataType)
{
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
fOperationType = l;
break;
case execplan::CalpontSystemCatalog::DATETIME:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DATETIME;
fOperationType.colWidth = 8;
break;
case execplan::CalpontSystemCatalog::DATE:
fOperationType = l;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
break;
}
}
else if ( r.colDataType == execplan::CalpontSystemCatalog::DATETIME ||
r.colDataType == execplan::CalpontSystemCatalog::DATE )
{
switch (l.colDataType)
{
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
fOperationType.colWidth = 255;
break;
case execplan::CalpontSystemCatalog::DATETIME:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DATETIME;
fOperationType.colWidth = 8;
break;
case execplan::CalpontSystemCatalog::DATE:
fOperationType = r;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
break;
}
}
else if (l.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
l.colDataType == execplan::CalpontSystemCatalog::UDECIMAL)
{
switch (r.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
{
switch (r.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
// should following the result type that MySQL gives
fOperationType = l;
fOperationType.scale = (l.scale > r.scale ? l.scale : r.scale);
break;
}
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::BIGINT:
{
// should following the result type that MySQL gives
fOperationType = l;
fOperationType.scale = (l.scale > r.scale ? l.scale : r.scale);
break;
}
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::UBIGINT:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = l.scale;
fOperationType.colWidth = 8;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
}
}
else if (r.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = l.scale;
fOperationType.colWidth = 8;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
}
}
else if (r.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
r.colDataType == execplan::CalpontSystemCatalog::UDECIMAL)
{
switch (l.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
{
switch (l.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
// should following the result type that MySQL gives based on the following logic?
// @NOTE is this trustable?
fOperationType = fResultType;
break;
}
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::BIGINT:
{
// should following the result type that MySQL gives based on the following logic?
// @NOTE is this trustable?
fOperationType = fResultType;
break;
}
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::UBIGINT:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = r.scale;
fOperationType.colWidth = 8;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
}
}
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = r.scale;
fOperationType.colWidth = 8;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
}
}
// If both sides are unsigned, use UBIGINT as result type, otherwise
// "promote" to BIGINT.
else if (isUnsigned(l.colDataType) && isUnsigned(r.colDataType))
@ -299,45 +324,45 @@ void PredicateOperator::setOpType(Type& l, Type& r)
fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
fOperationType.colWidth = 8;
}
else if ((l.colDataType == execplan::CalpontSystemCatalog::CHAR ||
l.colDataType == execplan::CalpontSystemCatalog::VARCHAR ||
l.colDataType == execplan::CalpontSystemCatalog::TEXT) &&
(r.colDataType == execplan::CalpontSystemCatalog::CHAR ||
r.colDataType == execplan::CalpontSystemCatalog::VARCHAR ||
r.colDataType == execplan::CalpontSystemCatalog::TEXT))
{
if ( ( (l.colDataType == execplan::CalpontSystemCatalog::CHAR && l.colWidth <= 8) ||
(l.colDataType == execplan::CalpontSystemCatalog::VARCHAR && l.colWidth < 8) ) &&
( (r.colDataType == execplan::CalpontSystemCatalog::CHAR && r.colWidth <= 8) ||
(r.colDataType == execplan::CalpontSystemCatalog::VARCHAR && r.colWidth < 8) ) )
{
if ( futf8 )
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
fOperationType.colWidth = 255;
}
else
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
fOperationType.scale = 0;
fOperationType.colWidth = 8;
else if ((l.colDataType == execplan::CalpontSystemCatalog::CHAR ||
l.colDataType == execplan::CalpontSystemCatalog::VARCHAR ||
l.colDataType == execplan::CalpontSystemCatalog::TEXT) &&
(r.colDataType == execplan::CalpontSystemCatalog::CHAR ||
r.colDataType == execplan::CalpontSystemCatalog::VARCHAR ||
r.colDataType == execplan::CalpontSystemCatalog::TEXT))
{
if ( ( (l.colDataType == execplan::CalpontSystemCatalog::CHAR && l.colWidth <= 8) ||
(l.colDataType == execplan::CalpontSystemCatalog::VARCHAR && l.colWidth < 8) ) &&
( (r.colDataType == execplan::CalpontSystemCatalog::CHAR && r.colWidth <= 8) ||
(r.colDataType == execplan::CalpontSystemCatalog::VARCHAR && r.colWidth < 8) ) )
{
if ( futf8 )
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
fOperationType.colWidth = 255;
}
else
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
fOperationType.scale = 0;
fOperationType.colWidth = 8;
// @bug3532, char[] as network order int for fast comparison.
l.colDataType = execplan::CalpontSystemCatalog::STRINT;
r.colDataType = execplan::CalpontSystemCatalog::STRINT;
}
}
else
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
fOperationType.colWidth = 255;
}
}
else
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
}
// @bug3532, char[] as network order int for fast comparison.
l.colDataType = execplan::CalpontSystemCatalog::STRINT;
r.colDataType = execplan::CalpontSystemCatalog::STRINT;
}
}
else
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::VARCHAR;
fOperationType.colWidth = 255;
}
}
else
{
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
fOperationType.colWidth = 8;
}
}
} // namespace