You've already forked mariadb-columnstore-engine
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:
@ -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++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user