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

MCOL-1822 add LONG DOUBLE support

This commit is contained in:
David Hall
2019-01-29 09:55:43 -06:00
parent ee2cb7b0de
commit c5b9ae11e5
40 changed files with 746 additions and 38 deletions

View File

@ -174,7 +174,6 @@ int DoubleCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2)
return ret;
}
int FloatCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2)
{
l->row1().setData(r1);
@ -206,6 +205,37 @@ int FloatCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2)
return ret;
}
int LongDoubleCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2)
{
l->row1().setData(r1);
l->row2().setData(r2);
bool b1 = l->row1().isNullValue(fSpec.fIndex);
bool b2 = l->row2().isNullValue(fSpec.fIndex);
int ret = 0;
if (b1 == true || b2 == true)
{
if (b1 == false && b2 == true)
ret = fSpec.fNf;
else if (b1 == true && b2 == false)
ret = -fSpec.fNf;
}
else
{
long double v1 = l->row1().getLongDoubleField(fSpec.fIndex);
long double v2 = l->row2().getLongDoubleField(fSpec.fIndex);
if (v1 > v2)
ret = fSpec.fAsc;
else if (v1 < v2)
ret = -fSpec.fAsc;
}
return ret;
}
bool CompareRule::less(Row::Pointer r1, Row::Pointer r2)
{
@ -279,6 +309,13 @@ void CompareRule::compileRules(const std::vector<IdbSortSpec>& spec, const rowgr
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
Compare* c = new LongDoubleCompare(*i);
fCompares.push_back(c);
break;
}
case CalpontSystemCatalog::DATE:
case CalpontSystemCatalog::DATETIME:
case CalpontSystemCatalog::TIME:
@ -442,6 +479,12 @@ bool EqualCompData::operator()(Row::Pointer a, Row::Pointer b)
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
eq = (fRow1.getLongDoubleField(*i) == fRow2.getLongDoubleField(*i));
break;
}
default:
{
eq = false;

View File

@ -119,6 +119,14 @@ public:
int operator()(IdbCompare*, rowgroup::Row::Pointer, rowgroup::Row::Pointer);
};
class LongDoubleCompare : public Compare
{
public:
LongDoubleCompare(const IdbSortSpec& spec) : Compare(spec) {}
int operator()(IdbCompare*, rowgroup::Row::Pointer, rowgroup::Row::Pointer);
};
class FloatCompare : public Compare
{

View File

@ -90,6 +90,12 @@ boost::shared_ptr<WindowFunctionType> WF_lead_lag<T>::makeFunction(int id, const
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_lead_lag<long double>(id, name));
break;
}
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
{

View File

@ -96,6 +96,12 @@ boost::shared_ptr<WindowFunctionType> WF_min_max<T>::makeFunction(int id, const
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_min_max<long double>(id, name));
break;
}
default:
{
func.reset(new WF_min_max<string>(id, name));

View File

@ -102,6 +102,12 @@ boost::shared_ptr<WindowFunctionType> WF_percentile<T>::makeFunction(int id, con
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_percentile<long double>(id, name));
break;
}
default:
{
if (id == WF__PERCENTILE_DISC)
@ -140,6 +146,7 @@ boost::shared_ptr<WindowFunctionType> WF_percentile<T>::makeFunction(int id, con
case CalpontSystemCatalog::UDOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_percentile<double>(id, name));
break;

View File

@ -96,6 +96,12 @@ boost::shared_ptr<WindowFunctionType> WF_stats<T>::makeFunction(int id, const st
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_stats<long double>(id, name));
break;
}
default:
{
string errStr = name + "(" + colType2String[ct] + ")";

View File

@ -159,7 +159,7 @@ template<typename T>
boost::shared_ptr<WindowFunctionType> WF_sum_avg<T>::makeFunction(int id, const string& name, int ct)
{
boost::shared_ptr<WindowFunctionType> func;
#if 0
switch (ct)
{
case CalpontSystemCatalog::TINYINT:
@ -198,6 +198,35 @@ boost::shared_ptr<WindowFunctionType> WF_sum_avg<T>::makeFunction(int id, const
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_sum_avg<long double>(id, name));
break;
}
#endif
switch (ct)
{
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UTINYINT:
case CalpontSystemCatalog::USMALLINT:
case CalpontSystemCatalog::UMEDINT:
case CalpontSystemCatalog::UINT:
case CalpontSystemCatalog::UBIGINT:
case CalpontSystemCatalog::UDECIMAL:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::UDOUBLE:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
case CalpontSystemCatalog::LONGDOUBLE:
{
func.reset(new WF_sum_avg<long double>(id, name));
break;
}
default:
{
string errStr = name + "(" + colType2String[ct] + ")";

View File

@ -398,6 +398,48 @@ bool WF_udaf::dropValues(int64_t b, int64_t e)
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
double valIn;
if (cc)
{
valIn = cc->getLongDoubleVal(fRow, isNull);
}
else
{
getValue(colIn, valIn);
}
// Check for distinct, if turned on.
// Currently, distinct only works on the first parameter.
if (k == 0)
{
if (fDistinct)
{
DistinctMap::iterator distinct;
distinct = fDistinctMap.find(valIn);
if (distinct != fDistinctMap.end())
{
// This is a duplicate: decrement the count
--(*distinct).second;
if ((*distinct).second > 0) // still more of these
{
bSkipIt = true;
continue;
}
else
{
fDistinctMap.erase(distinct);
}
}
}
}
datum.columnData = valIn;
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:
@ -971,6 +1013,38 @@ void WF_udaf::operator()(int64_t b, int64_t e, int64_t c)
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
long double valIn;
if (cc)
{
valIn = cc->getLongDoubleVal(fRow, isNull);
}
else
{
getValue(colIn, valIn);
}
// Check for distinct, if turned on.
// Currently, distinct only works on the first parameter.
if (k == 0 && fDistinct)
{
std::pair<static_any::any, uint64_t> val = make_pair(valIn, 1);
std::pair<DistinctMap::iterator, bool> distinct;
distinct = fDistinctMap.insert(val);
if (distinct.second == false)
{
++(*distinct.first).second;
bSkipIt = true;
continue;
}
}
datum.columnData = valIn;
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:

View File

@ -290,6 +290,16 @@ template<> void WindowFunctionType::getValue<float>(uint64_t i, float& t, CDT* c
}
}
template<> void WindowFunctionType::getValue<long double>(uint64_t i, long double& t, CDT* cdt)
{
t = fRow.getLongDoubleField(i);
if (cdt)
{
*cdt = execplan::CalpontSystemCatalog::LONGDOUBLE;
}
}
template<> void WindowFunctionType::getValue<string>(uint64_t i, string& t, CDT* cdt)
{
t = fRow.getStringField(i);
@ -320,6 +330,11 @@ template<> void WindowFunctionType::setValue<float>(uint64_t i, float& t)
fRow.setFloatField(t, i);
}
template<> void WindowFunctionType::setValue<long double>(uint64_t i, long double& t)
{
fRow.setLongDoubleField(t, i);
}
template<> void WindowFunctionType::setValue<string>(uint64_t i, string& t)
{
fRow.setStringField(t, i);
@ -406,6 +421,14 @@ void WindowFunctionType::setValue(int ct, int64_t b, int64_t e, int64_t c, T* v)
setValue(i, fv);
break;
}
case CalpontSystemCatalog::LONGDOUBLE:
{
long double dv = *v;
setValue(i, dv);
break;
}
default:
{
setValue(i, *v);
@ -523,6 +546,12 @@ void WindowFunctionType::getConstValue<double>(ConstantColumn* cc, double& t, bo
t = cc->getDoubleVal(fRow, b);
}
template<>
void WindowFunctionType::getConstValue<long double>(ConstantColumn* cc, long double& t, bool& b)
{
t = cc->getLongDoubleVal(fRow, b);
}
template<>
void WindowFunctionType::getConstValue<float>(ConstantColumn* cc, float& t, bool& b)
{
@ -539,11 +568,13 @@ template void WindowFunctionType::implicit2T<int64_t>(uint64_t, int64_t&, int);
template void WindowFunctionType::implicit2T<uint64_t>(uint64_t, uint64_t&, int);
template void WindowFunctionType::implicit2T<float>(uint64_t, float&, int);
template void WindowFunctionType::implicit2T<double>(uint64_t, double&, int);
template void WindowFunctionType::implicit2T<long double>(uint64_t, long double&, int);
template void WindowFunctionType::setValue<int64_t>(int, int64_t, int64_t, int64_t, int64_t*);
template void WindowFunctionType::setValue<uint64_t>(int, int64_t, int64_t, int64_t, uint64_t*);
template void WindowFunctionType::setValue<float>(int, int64_t, int64_t, int64_t, float*);
template void WindowFunctionType::setValue<double>(int, int64_t, int64_t, int64_t, double*);
template void WindowFunctionType::setValue<long double>(int, int64_t, int64_t, int64_t, long double*);
void* WindowFunctionType::getNullValueByType(int ct, int pos)
{
@ -557,6 +588,7 @@ void* WindowFunctionType::getNullValueByType(int ct, int pos)
static uint64_t utinyIntNull = joblist::UTINYINTNULL;
static uint64_t floatNull = joblist::FLOATNULL;
static uint64_t doubleNull = joblist::DOUBLENULL;
static long double longDoubleNull= joblist::LONGDOUBLENULL;
static uint64_t dateNull = joblist::DATENULL;
static uint64_t datetimeNull = joblist::DATETIMENULL;
static uint64_t timeNull = joblist::TIMENULL;
@ -691,6 +723,9 @@ void* WindowFunctionType::getNullValueByType(int ct, int pos)
break;
case CalpontSystemCatalog::LONGDOUBLE:
v = &longDoubleNull;
break;
case CalpontSystemCatalog::VARBINARY:
default:
std::ostringstream oss;

View File

@ -223,6 +223,10 @@ protected:
{
return fRow.getDoubleField(i);
}
long double getLongDoubleValue(uint64_t i)
{
return fRow.getLongDoubleField(i);
}
void setIntValue(int64_t i, int64_t v)
{
fRow.setIntField(v, i);
@ -231,7 +235,10 @@ protected:
{
fRow.setDoubleField(v, i);
}
void setLongDoubleValue(int64_t i, long double v)
{
fRow.setLongDoubleField(v, i);
}
// for string table
rowgroup::Row::Pointer getPointer(joblist::RowPosition& r)