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

@ -28,29 +28,38 @@
using namespace std;
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
@ -59,11 +68,11 @@ ArithmeticOperator::ArithmeticOperator() : Operator()
{
}
ArithmeticOperator::ArithmeticOperator(const string& operatorName):Operator(operatorName)
ArithmeticOperator::ArithmeticOperator(const string& operatorName): Operator(operatorName)
{
}
ArithmeticOperator::ArithmeticOperator(const ArithmeticOperator& rhs):Operator(rhs)
ArithmeticOperator::ArithmeticOperator(const ArithmeticOperator& rhs): Operator(rhs)
{
}
@ -78,11 +87,11 @@ ArithmeticOperator:: ~ArithmeticOperator()
/**
* friend function
*/
ostream& operator<<(ostream &output, const ArithmeticOperator& rhs)
ostream& operator<<(ostream& output, const ArithmeticOperator& rhs)
{
output << rhs.toString();
output << "opType=" << rhs.operationType().colDataType << endl;
return output;
output << rhs.toString();
output << "opType=" << rhs.operationType().colDataType << endl;
return output;
}
/**
@ -90,118 +99,125 @@ ostream& operator<<(ostream &output, const ArithmeticOperator& rhs)
*/
void ArithmeticOperator::serialize(messageqcpp::ByteStream& b) const
{
b << (ObjectReader::id_t) ObjectReader::ARITHMETICOPERATOR;
Operator::serialize(b);
b << (ObjectReader::id_t) ObjectReader::ARITHMETICOPERATOR;
Operator::serialize(b);
}
void ArithmeticOperator::unserialize(messageqcpp::ByteStream& b)
{
ObjectReader::checkType(b, ObjectReader::ARITHMETICOPERATOR);
Operator::unserialize(b);
ObjectReader::checkType(b, ObjectReader::ARITHMETICOPERATOR);
Operator::unserialize(b);
}
bool ArithmeticOperator::operator==(const ArithmeticOperator& t) const
{
if (fData == t.fData)
return true;
return false;
if (fData == t.fData)
return true;
return false;
}
bool ArithmeticOperator::operator==(const TreeNode* t) const
{
const ArithmeticOperator *o;
const ArithmeticOperator* o;
o = dynamic_cast<const ArithmeticOperator*>(t);
if (o == NULL)
return false;
return *this == *o;
o = dynamic_cast<const ArithmeticOperator*>(t);
if (o == NULL)
return false;
return *this == *o;
}
bool ArithmeticOperator::operator!=(const ArithmeticOperator& t) const
{
return (!(*this == t));
return (!(*this == t));
}
bool ArithmeticOperator::operator!=(const TreeNode* t) const
{
return (!(*this == t));
return (!(*this == t));
}
#if 0
void ArithmeticOperator::operationType(const Type& l, const Type& r)
{
if (l.colDataType == execplan::CalpontSystemCatalog::DECIMAL)
{
switch (r.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
{
// should follow the result type that MySQL gives
fOperationType = fResultType;
break;
}
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::BIGINT:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = l.scale;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
}
}
else if (r.colDataType == execplan::CalpontSystemCatalog::DECIMAL)
{
switch (l.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
{
// 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:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = r.scale;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
}
}
else if ((l.colDataType == execplan::CalpontSystemCatalog::INT ||
l.colDataType == execplan::CalpontSystemCatalog::MEDINT ||
l.colDataType == execplan::CalpontSystemCatalog::TINYINT ||
l.colDataType == execplan::CalpontSystemCatalog::BIGINT) &&
(r.colDataType == execplan::CalpontSystemCatalog::INT ||
r.colDataType == execplan::CalpontSystemCatalog::MEDINT ||
r.colDataType == execplan::CalpontSystemCatalog::TINYINT ||
r.colDataType == execplan::CalpontSystemCatalog::BIGINT))
fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
else
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
if (l.colDataType == execplan::CalpontSystemCatalog::DECIMAL)
{
switch (r.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
{
// should follow the result type that MySQL gives
fOperationType = fResultType;
break;
}
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::BIGINT:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = l.scale;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
}
}
else if (r.colDataType == execplan::CalpontSystemCatalog::DECIMAL)
{
switch (l.colDataType)
{
case execplan::CalpontSystemCatalog::DECIMAL:
{
// 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:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DECIMAL;
fOperationType.scale = r.scale;
break;
default:
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
}
}
else if ((l.colDataType == execplan::CalpontSystemCatalog::INT ||
l.colDataType == execplan::CalpontSystemCatalog::MEDINT ||
l.colDataType == execplan::CalpontSystemCatalog::TINYINT ||
l.colDataType == execplan::CalpontSystemCatalog::BIGINT) &&
(r.colDataType == execplan::CalpontSystemCatalog::INT ||
r.colDataType == execplan::CalpontSystemCatalog::MEDINT ||
r.colDataType == execplan::CalpontSystemCatalog::TINYINT ||
r.colDataType == execplan::CalpontSystemCatalog::BIGINT))
fOperationType.colDataType = execplan::CalpontSystemCatalog::BIGINT;
else
fOperationType.colDataType = execplan::CalpontSystemCatalog::DOUBLE;
}
#endif
void ArithmeticOperator::adjustResultType(const CalpontSystemCatalog::ColType& m)
{
if (m.colDataType != CalpontSystemCatalog::DECIMAL)
{
fResultType = m;
}
else
{
CalpontSystemCatalog::ColType n;
n.colDataType = CalpontSystemCatalog::DOUBLE;
n.scale = m.scale; // @bug5736, save the original decimal scale
n.precision = -1; // @bug5736, indicate this double is for decimal math
n.colWidth = 8;
fResultType = n;
}
if (m.colDataType != CalpontSystemCatalog::DECIMAL)
{
fResultType = m;
}
else
{
CalpontSystemCatalog::ColType n;
n.colDataType = CalpontSystemCatalog::DOUBLE;
n.scale = m.scale; // @bug5736, save the original decimal scale
n.precision = -1; // @bug5736, indicate this double is for decimal math
n.colWidth = 8;
fResultType = n;
}
}
} // namespace