1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-24 14:20:59 +03:00

MCOL-1822 Intermediate checkin. DISTINCT not working.

This commit is contained in:
David Hall
2019-02-25 14:54:46 -06:00
parent ab931e7c51
commit a2aa4b8479
67 changed files with 2391 additions and 1018 deletions

View File

@@ -45,7 +45,9 @@ namespace
using namespace funcexp;
inline void decimalPlaceDouble(FunctionParm& fp, int64_t& s, double& p, Row& row, bool& isNull)
// P should either be double or long double
template <typename P>
inline void decimalPlaceDouble(FunctionParm& fp, int64_t& s, P& p, Row& row, bool& isNull)
{
s = fp[1]->data()->getIntVal(row, isNull);
int64_t d = s;
@@ -60,9 +62,9 @@ inline void decimalPlaceDouble(FunctionParm& fp, int64_t& s, double& p, Row& row
r *= 10;
if (d >= 0)
p = (double) r;
p = (P) r;
else
p = 1.0 / ((double) r);
p = 1.0 / ((P) r);
}
}
@@ -200,6 +202,67 @@ double Func_round::getDoubleVal(Row& row,
return d;
}
long double Func_round::getLongDoubleVal(Row& row,
FunctionParm& parm,
bool& isNull,
CalpontSystemCatalog::ColType& op_ct)
{
if (execplan::CalpontSystemCatalog::LONGDOUBLE == op_ct.colDataType)
{
int64_t d = 0;
long double p = 1;
if (parm.size() > 1) // round(X, D)
decimalPlaceDouble(parm, d, p, row, isNull);
if (isNull)
return 0.0;
long double x = parm[0]->data()->getLongDoubleVal(row, isNull);
if (!isNull)
{
x *= p;
if (x >= 0)
x = floor(x + 0.5);
else
x = ceil(x - 0.5);
if (p != 0.0)
x /= p;
else
x = 0.0;
}
return x;
}
if (isUnsigned(op_ct.colDataType))
{
return getUintVal(row, parm, isNull, op_ct);
}
IDB_Decimal x = getDecimalVal(row, parm, isNull, op_ct);
if (isNull)
return 0.0;
double d = x.value;
if (x.scale > 0)
{
while (x.scale-- > 0)
d /= 10.0;
}
else
{
while (x.scale++ < 0)
d *= 10.0;
}
return d;
}
IDB_Decimal Func_round::getDecimalVal(Row& row,
FunctionParm& parm,
@@ -330,6 +393,34 @@ IDB_Decimal Func_round::getDecimalVal(Row& row,
}
break;
case execplan::CalpontSystemCatalog::LONGDOUBLE:
{
int64_t s = 0;
long double p = 1;
if (parm.size() > 1) // round(X, D)
decimalPlaceDouble(parm, s, p, row, isNull);
if (isNull)
break;
long double x = parm[0]->data()->getDoubleVal(row, isNull);
if (!isNull)
{
x *= p;
if (x >= 0)
x = floor(x + 0.5);
else
x = ceil(x - 0.5);
decimal.value = (int64_t) x;
decimal.scale = s;
}
}
break;
case execplan::CalpontSystemCatalog::DATE:
{
int32_t s = 0;