1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-641 Replaced IDB_Decima.__v union with int128_t attribute.

Moved all tests into ./test

Introduced ./datatypes directory
This commit is contained in:
Roman Nozdrin
2020-03-03 15:51:55 +00:00
parent 824615a55b
commit 238386bf63
17 changed files with 398 additions and 106 deletions

View File

@ -116,70 +116,6 @@ bool ArithmeticOperator::operator!=(const TreeNode* t) const
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;
}
#endif
void ArithmeticOperator::adjustResultType(const CalpontSystemCatalog::ColType& m)
{
if (m.colDataType != CalpontSystemCatalog::DECIMAL)

View File

@ -288,13 +288,9 @@ inline void ArithmeticOperator::execute(IDB_Decimal& result, IDB_Decimal op1, ID
switch (fOp)
{
case OP_ADD:
if (resultCscType.precision > 18)
if (resultCscType.colWidth == 16)
{
// WIP make this a separate function w and w/o overflow check
if (resultCscType.colDataType == execplan::CalpontSystemCatalog::DECIMAL)
result.__v.__s128 = op1.__v.__s128 + op2.__v.__s128;
else
result.__v.__u128 = op1.__v.__u128 + op2.__v.__u128;
result.s128Value = op1.s128Value + op2.s128Value;
break;
}

View File

@ -635,16 +635,8 @@ void SimpleColumn::evaluate(Row& row, bool& isNull)
{
case 16:
{
if (fResultType.colDataType == CalpontSystemCatalog::UDECIMAL)
{
fResult.decimalVal.__v.__u128 =
*row.getBinaryField_offset<decltype(fResult.decimalVal.__v.__u128)>(fInputOffset);
}
else
{
fResult.decimalVal.__v.__s128 =
*row.getBinaryField_offset<decltype(fResult.decimalVal.__v.__s128)>(fInputOffset);
}
fResult.decimalVal.s128Value =
*row.getBinaryField_offset<decltype(fResult.decimalVal.s128Value)>(fInputOffset);
fResult.decimalVal.scale = (unsigned)fResultType.scale;
break;
}

View File

@ -37,7 +37,6 @@
#include "dataconvert.h"
using int128_t = __int128;
using uint128_t = unsigned __int128;
namespace messageqcpp
{
@ -66,14 +65,14 @@ struct IDB_Decimal
{
IDB_Decimal(): value(0), scale(0), precision(0)
{
__v.__s128 = 0;
s128Value = 0;
}
IDB_Decimal(int64_t val, int8_t s, uint8_t p) :
value (val),
scale(s),
precision(p)
{
__v.__s128 = 0;
s128Value = 0;
}
int decimalComp(const IDB_Decimal& d) const
@ -158,11 +157,7 @@ struct IDB_Decimal
return (decimalComp(rhs) != 0);
}
union {
uint128_t __u128;
int128_t __s128;
int64_t __s64[2];
} __v;
int128_t s128Value;
int64_t value;
int8_t scale; // 0~38
uint8_t precision; // 1~38