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-4313 Introduced TSInt128 that is a storage class for int128
Removed uint128 from joblist/lbidlist.* Another toString() method for wide-decimal that is EMPTY/NULL aware Unified decimal processing in WF functions Fixed a potential issue in EqualCompData::operator() for wide-decimal processing Fixed some signedness warnings
This commit is contained in:
@ -300,7 +300,8 @@ void FrameBoundExpressionRange<T>::validate()
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (this->fRow.getColumnWidth(this->fIndex[1]) < 16)
|
||||
if (UNLIKELY(this->fRow.getColumnWidth(this->fIndex[1])
|
||||
< datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
int64_t tmp = this->fRow.getIntField(this->fIndex[1]);
|
||||
this->fIsZero = (tmp == 0);
|
||||
@ -313,7 +314,7 @@ void FrameBoundExpressionRange<T>::validate()
|
||||
}
|
||||
else
|
||||
{
|
||||
int128_t tmp = this->fRow.getInt128Field(this->fIndex[1]);
|
||||
datatypes::TSInt128 tmp = this->fRow.getTSInt128Field(this->fIndex[1]);
|
||||
this->fIsZero = (tmp == 0);
|
||||
|
||||
if (tmp < 0)
|
||||
@ -325,6 +326,22 @@ void FrameBoundExpressionRange<T>::validate()
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (UNLIKELY(this->fRow.getColumnWidth(this->fIndex[1])
|
||||
< datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
uint64_t tmp = this->fRow.getUintField(this->fIndex[1]);
|
||||
this->fIsZero = (tmp == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
datatypes::TSInt128 tmp = this->fRow.getTSInt128Field(this->fIndex[1]);
|
||||
this->fIsZero = (tmp == 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
{
|
||||
@ -369,22 +386,6 @@ void FrameBoundExpressionRange<T>::validate()
|
||||
break;
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (this->fRow.getColumnWidth(this->fIndex[1]) < 16)
|
||||
{
|
||||
uint64_t tmp = this->fRow.getUintField(this->fIndex[1]);
|
||||
this->fIsZero = (tmp == 0);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint128_t tmp = this->fRow.getUint128Field(this->fIndex[1]);
|
||||
this->fIsZero = (tmp == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
|
@ -853,13 +853,14 @@ bool EqualCompData::operator()(Row::Pointer a, Row::Pointer b)
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
// equal compare. ignore sign and null
|
||||
if (fRow1.getColumnWidth(*i) < datatypes::MAXDECIMALWIDTH)
|
||||
if (UNLIKELY(fRow1.getColumnWidth(*i) < datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
eq = (fRow1.getUintField(*i) == fRow2.getUintField(*i));
|
||||
}
|
||||
else if (fRow1.getColumnWidth(*i) == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
eq = (fRow1.getUint128Field(*i) == fRow2.getUint128Field(*i));
|
||||
eq = (*fRow1.getBinaryField<int128_t>(*i) ==
|
||||
*fRow2.getBinaryField<int128_t>(*i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -78,11 +78,13 @@ boost::shared_ptr<WindowFunctionType> WF_count<T>::makeFunction(int id, const st
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < datatypes::MAXDECIMALWIDTH)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->functionParms()[0]->resultType().colWidth;
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_count<int64_t>(id, name));
|
||||
}
|
||||
else if (wc->functionParms()[0]->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_count<int128_t>(id, name));
|
||||
}
|
||||
|
@ -84,31 +84,23 @@ boost::shared_ptr<WindowFunctionType> WF_lead_lag<T>::makeFunction(int id, const
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < datatypes::MAXDECIMALWIDTH)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->functionParms()[0]->resultType().colWidth;
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_lead_lag<int64_t>(id, name));
|
||||
if (ct == CalpontSystemCatalog::UDECIMAL)
|
||||
func.reset(new WF_lead_lag<uint64_t>(id, name));
|
||||
else
|
||||
func.reset(new WF_lead_lag<int64_t>(id, name));
|
||||
}
|
||||
else if (wc->functionParms()[0]->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_lead_lag<int128_t>(id, name));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < 16)
|
||||
{
|
||||
func.reset(new WF_lead_lag<uint64_t>(id, name));
|
||||
}
|
||||
else
|
||||
{
|
||||
func.reset(new WF_lead_lag<uint128_t>(id, name));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
{
|
||||
@ -319,7 +311,6 @@ boost::shared_ptr<WindowFunctionType> WF_lead_lag<int64_t>::makeFunction(int, co
|
||||
template void WF_lead_lag<int64_t>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
template void WF_lead_lag<uint64_t>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
template void WF_lead_lag<int128_t>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
template void WF_lead_lag<uint128_t>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
template void WF_lead_lag<float>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
template void WF_lead_lag<double>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
template void WF_lead_lag<string>::parseParms(const std::vector<execplan::SRCP>&);
|
||||
|
@ -83,10 +83,17 @@ boost::shared_ptr<WindowFunctionType> WF_min_max<T>::makeFunction(int id, const
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < 16)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->functionParms()[0]->resultType().colWidth;
|
||||
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_min_max<int64_t>(id, name));
|
||||
if (ct == CalpontSystemCatalog::UDECIMAL)
|
||||
func.reset(new WF_min_max<uint64_t>(id, name));
|
||||
else
|
||||
func.reset(new WF_min_max<int64_t>(id, name));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -94,19 +101,6 @@ boost::shared_ptr<WindowFunctionType> WF_min_max<T>::makeFunction(int id, const
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < 16)
|
||||
{
|
||||
func.reset(new WF_min_max<uint64_t>(id, name));
|
||||
}
|
||||
else
|
||||
{
|
||||
func.reset(new WF_min_max<uint128_t>(id, name));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
|
@ -86,11 +86,16 @@ boost::shared_ptr<WindowFunctionType> WF_nth_value<T>::makeFunction(int id, cons
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < datatypes::MAXDECIMALWIDTH)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->functionParms()[0]->resultType().colWidth;
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_nth_value<int64_t>(id, name));
|
||||
if (ct == CalpontSystemCatalog::UDECIMAL)
|
||||
func.reset(new WF_nth_value<uint64_t>(id, name));
|
||||
else
|
||||
func.reset(new WF_nth_value<int64_t>(id, name));
|
||||
}
|
||||
else if (wc->functionParms()[0]->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_nth_value<int128_t>(id, name));
|
||||
}
|
||||
|
@ -46,8 +46,6 @@ using namespace ordering;
|
||||
#include "constantcolumn.h"
|
||||
using namespace execplan;
|
||||
|
||||
#include "mcs_decimal.h"
|
||||
|
||||
#include "windowfunctionstep.h"
|
||||
using namespace joblist;
|
||||
|
||||
@ -93,11 +91,17 @@ boost::shared_ptr<WindowFunctionType> WF_percentile<T>::makeFunction(int id, con
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->resultType().colWidth < datatypes::MAXDECIMALWIDTH)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->resultType().colWidth;
|
||||
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_percentile<int64_t>(id, name));
|
||||
if (ct == CalpontSystemCatalog::UDECIMAL)
|
||||
func.reset(new WF_percentile<uint64_t>(id, name));
|
||||
else
|
||||
func.reset(new WF_percentile<int64_t>(id, name));
|
||||
}
|
||||
else if (wc->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_percentile<int128_t>(id, name));
|
||||
}
|
||||
|
@ -84,11 +84,16 @@ boost::shared_ptr<WindowFunctionType> WF_stats<T>::makeFunction(int id, const st
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < datatypes::MAXDECIMALWIDTH)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->functionParms()[0]->resultType().colWidth;
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_stats<int64_t>(id, name));
|
||||
if (ct == CalpontSystemCatalog::UDECIMAL)
|
||||
func.reset(new WF_stats<uint64_t>(id, name));
|
||||
else
|
||||
func.reset(new WF_stats<int64_t>(id, name));
|
||||
}
|
||||
else if (wc->functionParms()[0]->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_stats<int128_t>(id, name));
|
||||
}
|
||||
|
@ -181,11 +181,17 @@ boost::shared_ptr<WindowFunctionType> WF_sum_avg<T_IN, T_OUT>::makeFunction(int
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (wc->functionParms()[0]->resultType().colWidth < datatypes::MAXDECIMALWIDTH)
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
wc->functionParms()[0]->resultType().colWidth;
|
||||
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_sum_avg<int64_t, int128_t>(id, name));
|
||||
if (ct == CalpontSystemCatalog::UDECIMAL)
|
||||
func.reset(new WF_sum_avg<uint64_t, int128_t>(id, name));
|
||||
else
|
||||
func.reset(new WF_sum_avg<int64_t, int128_t>(id, name));
|
||||
}
|
||||
else if (wc->functionParms()[0]->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
func.reset(new WF_sum_avg<int128_t, int128_t>(id, name));
|
||||
}
|
||||
|
@ -550,7 +550,6 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut,
|
||||
static const static_any::any& uintTypeId = (unsigned int)1;
|
||||
static const static_any::any& ulongTypeId = (unsigned long)1;
|
||||
static const static_any::any& ullTypeId = (unsigned long long)1;
|
||||
static const static_any::any& uint128TypeId = (uint128_t)1;
|
||||
static const static_any::any& floatTypeId = (float)1;
|
||||
static const static_any::any& doubleTypeId = (double)1;
|
||||
static const std::string typeStr("");
|
||||
@ -565,7 +564,6 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut,
|
||||
int64_t intOut = 0;
|
||||
uint64_t uintOut = 0;
|
||||
int128_t int128Out = 0;
|
||||
uint128_t uint128Out = 0;
|
||||
float floatOut = 0.0;
|
||||
double doubleOut = 0.0;
|
||||
long double longdoubleOut = 0.0;
|
||||
@ -664,15 +662,6 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut,
|
||||
longdoubleOut = int128Out;
|
||||
oss << longdoubleOut;
|
||||
}
|
||||
else if (valOut.compatible(uint128TypeId))
|
||||
{
|
||||
uint128Out = valOut.cast<uint128_t>();
|
||||
uintOut = intOut = uint128Out; // may truncate
|
||||
floatOut = uint128Out;
|
||||
doubleOut = uint128Out;
|
||||
longdoubleOut = uint128Out;
|
||||
oss << longdoubleOut;
|
||||
}
|
||||
|
||||
if (valOut.compatible(strTypeId))
|
||||
{
|
||||
|
@ -58,7 +58,6 @@ using namespace joblist;
|
||||
#include "wf_stats.h"
|
||||
#include "wf_sum_avg.h"
|
||||
#include "wf_udaf.h"
|
||||
#include "mcs_decimal.h"
|
||||
|
||||
namespace windowfunction
|
||||
{
|
||||
@ -310,17 +309,7 @@ template<> void WindowFunctionType::getValue<string>(uint64_t i, string& t, CDT*
|
||||
|
||||
template<> void WindowFunctionType::getValue<int128_t>(uint64_t i, int128_t& t, CDT* cdt)
|
||||
{
|
||||
t = fRow.getInt128Field(i);
|
||||
|
||||
if (cdt)
|
||||
{
|
||||
*cdt = execplan::CalpontSystemCatalog::DECIMAL;
|
||||
}
|
||||
}
|
||||
|
||||
template<> void WindowFunctionType::getValue<uint128_t>(uint64_t i, uint128_t& t, CDT* cdt)
|
||||
{
|
||||
t = fRow.getUint128Field(i);
|
||||
fRow.getInt128Field(i, t);
|
||||
|
||||
if (cdt)
|
||||
{
|
||||
@ -362,11 +351,6 @@ template<> void WindowFunctionType::setValue<int128_t>(uint64_t i, int128_t& t)
|
||||
fRow.setInt128Field(t, i);
|
||||
}
|
||||
|
||||
template<> void WindowFunctionType::setValue<uint128_t>(uint64_t i, uint128_t& t)
|
||||
{
|
||||
fRow.setUint128Field(t, i);
|
||||
}
|
||||
|
||||
template<> void WindowFunctionType::setValue<string>(uint64_t i, string& t)
|
||||
{
|
||||
fRow.setStringField(t, i);
|
||||
@ -460,7 +444,7 @@ void WindowFunctionType::setValue(int ct, int64_t b, int64_t e, int64_t c, T* v)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint128_t iv = *v;
|
||||
int128_t iv = *v;
|
||||
setValue(i, iv);
|
||||
}
|
||||
break;
|
||||
@ -525,22 +509,22 @@ void WindowFunctionType::implicit2T(uint64_t i, T& t, int s)
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
uint32_t w = fRow.getColumnWidth(i);
|
||||
if (w < 16)
|
||||
t = (T) fRow.getIntField(i);
|
||||
else
|
||||
t = (T) fRow.getInt128Field(i);
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
uint32_t w = fRow.getColumnWidth(i);
|
||||
if (w < 16)
|
||||
t = (T) fRow.getUintField(i);
|
||||
else
|
||||
t = (T) fRow.getUint128Field(i);
|
||||
decltype(datatypes::MAXDECIMALWIDTH) width =
|
||||
fRow.getColumnWidth(i);;
|
||||
|
||||
if (width < datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
t = (ct == execplan::CalpontSystemCatalog::DECIMAL) ?
|
||||
(T) fRow.getIntField(i) :
|
||||
(T) fRow.getUintField(i);
|
||||
}
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
datatypes::TSInt128::assignPtrPtr(&t,
|
||||
fRow.getBinaryField<int128_t>(i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -615,12 +599,6 @@ void WindowFunctionType::getConstValue<int128_t>(ConstantColumn* cc, int128_t& t
|
||||
t = cc->getDecimalVal(fRow, b).s128Value;
|
||||
}
|
||||
|
||||
template<>
|
||||
void WindowFunctionType::getConstValue<uint128_t>(ConstantColumn* cc, uint128_t& t, bool& b)
|
||||
{
|
||||
t = cc->getDecimalVal(fRow, b).s128Value;
|
||||
}
|
||||
|
||||
template<>
|
||||
void WindowFunctionType::getConstValue<double>(ConstantColumn* cc, double& t, bool& b)
|
||||
{
|
||||
@ -651,15 +629,12 @@ 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::implicit2T<int128_t>(uint64_t, int128_t&, int);
|
||||
template void WindowFunctionType::implicit2T<uint128_t>(uint64_t, uint128_t&, 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*);
|
||||
template void WindowFunctionType::setValue<int128_t>(int, int64_t, int64_t, int64_t, int128_t*);
|
||||
template void WindowFunctionType::setValue<uint128_t>(int, int64_t, int64_t, int64_t, uint128_t*);
|
||||
|
||||
void* WindowFunctionType::getNullValueByType(int ct, int pos)
|
||||
{
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "rowgroup.h"
|
||||
#include "windowframe.h"
|
||||
#include "constantcolumn.h"
|
||||
#include "mcs_decimal.h"
|
||||
|
||||
namespace ordering
|
||||
{
|
||||
@ -222,14 +223,16 @@ protected:
|
||||
|
||||
virtual void* getNullValueByType(int, int);
|
||||
|
||||
// There are two types of getters for integral types and for
|
||||
// DTs wider then 8 bytes.
|
||||
void getInt128Value(uint64_t i, int128_t& x)
|
||||
{
|
||||
return fRow.getInt128Field(i, x);
|
||||
}
|
||||
int64_t getIntValue(uint64_t i)
|
||||
{
|
||||
return fRow.getIntField(i);
|
||||
}
|
||||
int128_t getInt128Value(uint64_t i)
|
||||
{
|
||||
return fRow.getInt128Field(i);
|
||||
}
|
||||
double getDoubleValue(uint64_t i)
|
||||
{
|
||||
return fRow.getDoubleField(i);
|
||||
|
Reference in New Issue
Block a user