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

MCOL-4409 Moved static Decimal conversion methods into VDecimal class

MCOL-4409 This patch combines VDecimal and Decimal and makes
IDB_Decimal an alias for the result class

MCOL-4409 More boilerplate reduction in Func_mod

Removed couple TSInt128::toType() methods
This commit is contained in:
Roman Nozdrin
2020-11-24 15:28:38 +00:00
parent 2003417a89
commit 494bde61e1
27 changed files with 760 additions and 929 deletions

View File

@ -138,33 +138,22 @@ string Func_char::getStrVal(Row& row,
{
IDB_Decimal d = rc->getDecimalVal(row, isNull);
uint8_t roundingFactor = 4;
if (ct.colWidth == datatypes::MAXDECIMALWIDTH)
{
if (d.s128Value < 0)
return "";
int128_t scaleDivisor, scaleDivisor2;
datatypes::getScaleDivisor(scaleDivisor, d.scale);
scaleDivisor2 = (scaleDivisor <= 10) ? 1 : (scaleDivisor / 10);
int128_t tmpval = d.s128Value / scaleDivisor;
int128_t lefto = (d.s128Value - tmpval * scaleDivisor) / scaleDivisor2;
if (lefto > 4)
tmpval++;
value = datatypes::Decimal::getInt32FromWideDecimal(tmpval);
// rounding by the left over
value = static_cast<int32_t>(d.getRoundedIntegralPart(roundingFactor));
}
else
{
double dscale = d.scale;
// get decimal and round up
value = d.value / pow(10.0, dscale);
int lefto = (d.value - value * pow(10.0, dscale)) / pow(10.0, dscale - 1);
uint8_t lefto = (d.value - value * pow(10.0, dscale)) / pow(10.0, dscale - 1);
if ( lefto > 4 )
if ( lefto > roundingFactor )
value++;
}
}