You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +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:
@ -129,7 +129,6 @@ namespace anyimpl
|
||||
choose_policy<TYPE> { typedef big_any_policy<TYPE> type; };
|
||||
|
||||
BIG_POLICY(int128_t);
|
||||
BIG_POLICY(uint128_t);
|
||||
|
||||
/// Specializations for small types.
|
||||
#define SMALL_POLICY(TYPE) template<> struct \
|
||||
|
@ -242,7 +242,7 @@ double Func_mod::getDoubleVal(Row& row,
|
||||
int128_t value = d.s128Value / scaleDivisor;
|
||||
int128_t lefto = d.s128Value % scaleDivisor;
|
||||
__float128 tmp = (__float128) (value % div) + (__float128) lefto / scaleDivisor;
|
||||
mod = datatypes::Decimal::getDoubleFromFloat128(tmp);
|
||||
mod = datatypes::getDoubleFromFloat128(tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -365,7 +365,7 @@ long double Func_mod::getLongDoubleVal(Row& row,
|
||||
int128_t value = d.s128Value / scaleDivisor;
|
||||
int128_t lefto = d.s128Value % scaleDivisor;
|
||||
__float128 tmp = (__float128) (value % div) + (__float128) lefto / scaleDivisor;
|
||||
mod = datatypes::Decimal::getLongDoubleFromFloat128(tmp);
|
||||
mod = datatypes::getLongDoubleFromFloat128(tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -37,6 +37,7 @@ using namespace boost;
|
||||
#define BYTESTREAM_DLLEXPORT
|
||||
#include "bytestream.h"
|
||||
#undef BYTESTREAM_DLLEXPORT
|
||||
#include "datatypes/mcs_int128.h"
|
||||
|
||||
#define DEBUG_DUMP_STRINGS_LESS_THAN 0
|
||||
|
||||
@ -239,15 +240,8 @@ ByteStream& ByteStream::operator<<(const uint128_t& o)
|
||||
{
|
||||
if (fBuf == 0 || (fCurInPtr - fBuf + 16U > fMaxLen + ISSOverhead))
|
||||
growBuf(fMaxLen + BlockSize);
|
||||
|
||||
__asm__ volatile("movups %1,%0;"
|
||||
:"=m" ( *fCurInPtr ) // output
|
||||
:"v"( o ) // input
|
||||
: "memory" // clobbered
|
||||
);
|
||||
|
||||
datatypes::TSInt128::storeUnaligned(fCurInPtr, o);
|
||||
fCurInPtr += 16;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -255,14 +249,8 @@ ByteStream& ByteStream::operator<<(const int128_t& o)
|
||||
{
|
||||
if (fBuf == 0 || (fCurInPtr - fBuf + 16U > fMaxLen + ISSOverhead))
|
||||
growBuf(fMaxLen + BlockSize);
|
||||
|
||||
__asm__ volatile("movups %1,%0;"
|
||||
:"=m" ( *fCurInPtr ) // output
|
||||
:"v"( o ) // input
|
||||
: "memory" // clobbered
|
||||
);
|
||||
datatypes::TSInt128::storeUnaligned(fCurInPtr, o);
|
||||
fCurInPtr += 16;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -446,38 +434,16 @@ void ByteStream::peek(uint64_t& o) const
|
||||
|
||||
void ByteStream::peek(uint128_t& o) const
|
||||
{
|
||||
|
||||
if (length() < 16)
|
||||
throw underflow_error("ByteStream>uint128_t: not enough data in stream to fill datatype");
|
||||
|
||||
__asm__ volatile("movdqu %0,%%xmm0;"
|
||||
:
|
||||
:"m"( *fCurOutPtr ) // input
|
||||
:"xmm0" // clobbered
|
||||
);
|
||||
__asm__ volatile("movups %%xmm0,%0;"
|
||||
: "=m" (o)// output
|
||||
: // input
|
||||
: "memory", "xmm0" // clobbered
|
||||
);
|
||||
datatypes::TSInt128::assignPtrPtr(&o, fCurOutPtr);
|
||||
}
|
||||
|
||||
void ByteStream::peek(int128_t& o) const
|
||||
{
|
||||
|
||||
if (length() < 16)
|
||||
throw underflow_error("ByteStream>int128_t: not enough data in stream to fill datatype");
|
||||
|
||||
__asm__ volatile("movdqu %0,%%xmm0;"
|
||||
:
|
||||
:"m"( *fCurOutPtr ) // input
|
||||
:"xmm0" // clobbered
|
||||
);
|
||||
__asm__ volatile("movups %%xmm0,%0;"
|
||||
: "=m" (o)// output
|
||||
: // input
|
||||
: "memory", "xmm0" // clobbered
|
||||
);
|
||||
datatypes::TSInt128::assignPtrPtr(&o, fCurOutPtr);
|
||||
}
|
||||
|
||||
void ByteStream::peek(string& s) const
|
||||
|
@ -244,7 +244,6 @@ const static_any::any& RowAggregation::ushortTypeId((unsigned short)1);
|
||||
const static_any::any& RowAggregation::uintTypeId((unsigned int)1);
|
||||
const static_any::any& RowAggregation::ulongTypeId((unsigned long)1);
|
||||
const static_any::any& RowAggregation::ullTypeId((unsigned long long)1);
|
||||
const static_any::any& RowAggregation::uint128TypeId((uint128_t)1);
|
||||
const static_any::any& RowAggregation::floatTypeId((float)1);
|
||||
const static_any::any& RowAggregation::doubleTypeId((double)1);
|
||||
const static_any::any& RowAggregation::longdoubleTypeId((long double)1);
|
||||
@ -2184,7 +2183,10 @@ void RowAggregation::doUDAF(const Row& rowIn, int64_t colIn, int64_t colOut,
|
||||
if (LIKELY(fRowGroupIn.getColumnWidth(colIn)
|
||||
== datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
datum.columnData = rowIn.getInt128Field(colIn);
|
||||
// We can't control boost::any asignment
|
||||
// so let's get an aligned memory
|
||||
datatypes::TSInt128 val = rowIn.getTSInt128Field(colIn);
|
||||
datum.columnData = val.s128Value;
|
||||
}
|
||||
else if (fRowGroupIn.getColumnWidth(colIn) <= datatypes::MAXLEGACYWIDTH)
|
||||
{
|
||||
@ -2753,7 +2755,7 @@ void RowAggregationUM::calculateAvgColumns()
|
||||
bool isWideDecimal =
|
||||
datatypes::Decimal::isWideDecimalTypeByPrecision(precision);
|
||||
|
||||
if (LIKELY(!isWideDecimal))
|
||||
if (!isWideDecimal)
|
||||
{
|
||||
long double sum = 0.0;
|
||||
long double avg = 0.0;
|
||||
|
@ -725,7 +725,6 @@ protected:
|
||||
static const static_any::any& ushortTypeId;
|
||||
static const static_any::any& uintTypeId;
|
||||
static const static_any::any& ulongTypeId;
|
||||
static const static_any::any& uint128TypeId;
|
||||
static const static_any::any& ullTypeId;
|
||||
static const static_any::any& floatTypeId;
|
||||
static const static_any::any& doubleTypeId;
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "mcsv1_udaf.h"
|
||||
|
||||
#include "branchpred.h"
|
||||
#include "datatypes/mcs_int128.h"
|
||||
|
||||
#include "../winport/winport.h"
|
||||
|
||||
@ -386,8 +387,8 @@ public:
|
||||
return 0.0; // TODO: Do something here
|
||||
}
|
||||
inline long double getLongDoubleField(uint32_t colIndex) const;
|
||||
inline int128_t getInt128Field(uint32_t colIndex) const;
|
||||
inline uint128_t getUint128Field(uint32_t colIndex) const;
|
||||
inline void getInt128Field(uint32_t colIndex, int128_t& x) const;
|
||||
inline datatypes::TSInt128 getTSInt128Field(uint32_t colIndex) const;
|
||||
|
||||
inline uint64_t getBaseRid() const;
|
||||
inline uint64_t getRid() const;
|
||||
@ -418,7 +419,6 @@ public:
|
||||
inline void setDecimalField(double val, uint32_t colIndex) { }; // TODO: Do something here
|
||||
inline void setLongDoubleField(const long double& val, uint32_t colIndex);
|
||||
inline void setInt128Field(const int128_t& val, uint32_t colIndex);
|
||||
inline void setUint128Field(const uint128_t& val, uint32_t colIndex);
|
||||
|
||||
inline void setRid(uint64_t rid);
|
||||
|
||||
@ -429,11 +429,11 @@ public:
|
||||
void setStringField(const std::string& val, uint32_t colIndex);
|
||||
inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex);
|
||||
template<typename T>
|
||||
inline void setBinaryField(T* strdata, uint32_t width, uint32_t colIndex);
|
||||
inline void setBinaryField(const T* value, uint32_t width, uint32_t colIndex);
|
||||
template<typename T>
|
||||
inline void setBinaryField(T* strdata, uint32_t colIndex);
|
||||
inline void setBinaryField(const T* value, uint32_t colIndex);
|
||||
template<typename T>
|
||||
inline void setBinaryField_offset(T* strdata, uint32_t width, uint32_t colIndex);
|
||||
inline void setBinaryField_offset(const T* value, uint32_t width, uint32_t colIndex);
|
||||
// support VARBINARY
|
||||
// Add 2-byte length at the CHARSET_INFO*beginning of the field. NULL and zero length field are
|
||||
// treated the same, could use one of the length bit to distinguish these two cases.
|
||||
@ -821,44 +821,41 @@ inline uint32_t Row::getStringLength(uint32_t colIndex) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void Row::setBinaryField(T* value, uint32_t width, uint32_t colIndex)
|
||||
inline void Row::setBinaryField(const T* value, uint32_t width, uint32_t colIndex)
|
||||
{
|
||||
memcpy(&data[offsets[colIndex]], value, width);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void Row::setBinaryField(T* value, uint32_t colIndex)
|
||||
inline void Row::setBinaryField(const T* value, uint32_t colIndex)
|
||||
{
|
||||
*reinterpret_cast<T*>(&data[offsets[colIndex]]) = *value;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Row::setBinaryField<int128_t>(const int128_t* value, uint32_t colIndex)
|
||||
{
|
||||
datatypes::TSInt128::assignPtrPtr(&data[offsets[colIndex]], value);
|
||||
}
|
||||
|
||||
|
||||
// This method !cannot! be applied to uint8_t* buffers.
|
||||
template<typename T>
|
||||
inline void Row::setBinaryField_offset(T* value, uint32_t width, uint32_t offset)
|
||||
inline void Row::setBinaryField_offset(const T* value, uint32_t width, uint32_t offset)
|
||||
{
|
||||
*reinterpret_cast<T*>(&data[offset]) = *value;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Row::setBinaryField_offset<uint8_t>(uint8_t* value, uint32_t width, uint32_t offset)
|
||||
inline void Row::setBinaryField_offset<uint8_t>(const uint8_t* value, uint32_t width, uint32_t offset)
|
||||
{
|
||||
memcpy(&data[offset], value, width);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Row::setBinaryField_offset<int128_t>(int128_t* value, uint32_t width, uint32_t offset)
|
||||
inline void Row::setBinaryField_offset<int128_t>(const int128_t* value, uint32_t width, uint32_t offset)
|
||||
{
|
||||
int128_t *dst128Ptr = reinterpret_cast<int128_t*>(&data[offset]);
|
||||
__asm__ volatile("movdqu %0,%%xmm0;"
|
||||
:
|
||||
:"m"( *value ) // input
|
||||
:"xmm0" // clobbered
|
||||
);
|
||||
__asm__ volatile("movups %%xmm0,%0;"
|
||||
: "=m" (*dst128Ptr)// output
|
||||
: // input
|
||||
: "memory", "xmm0" // clobbered
|
||||
);
|
||||
datatypes::TSInt128::assignPtrPtr(&data[offset], value);
|
||||
}
|
||||
|
||||
inline void Row::setStringField(const uint8_t* strdata, uint32_t length, uint32_t colIndex)
|
||||
@ -975,18 +972,15 @@ inline long double Row::getLongDoubleField(uint32_t colIndex) const
|
||||
return *((long double*) &data[offsets[colIndex]]);
|
||||
}
|
||||
|
||||
// !!! Never ever try to remove inline from this f() b/c it returns
|
||||
// non-integral 16 byte DT
|
||||
inline int128_t Row::getInt128Field(uint32_t colIndex) const
|
||||
inline void Row::getInt128Field(uint32_t colIndex, int128_t& x) const
|
||||
{
|
||||
return *((int128_t*) &data[offsets[colIndex]]);
|
||||
datatypes::TSInt128::assignPtrPtr(&x, &data[offsets[colIndex]]);
|
||||
}
|
||||
|
||||
// !!! Never ever try to remove inline from this f() b/c it returns
|
||||
// non-integral 16 byte DT
|
||||
inline uint128_t Row::getUint128Field(uint32_t colIndex) const
|
||||
inline datatypes::TSInt128 Row::getTSInt128Field(uint32_t colIndex) const
|
||||
{
|
||||
return *((uint128_t*) &data[offsets[colIndex]]);
|
||||
const int128_t* ptr = getBinaryField<int128_t>(colIndex);
|
||||
return datatypes::TSInt128(ptr);
|
||||
}
|
||||
|
||||
inline uint64_t Row::getRid() const
|
||||
@ -1198,12 +1192,7 @@ inline void Row::setLongDoubleField(const long double& val, uint32_t colIndex)
|
||||
|
||||
inline void Row::setInt128Field(const int128_t& val, uint32_t colIndex)
|
||||
{
|
||||
*((int128_t*)&data[offsets[colIndex]]) = val;
|
||||
}
|
||||
|
||||
inline void Row::setUint128Field(const uint128_t& val, uint32_t colIndex)
|
||||
{
|
||||
*((uint128_t*)&data[offsets[colIndex]]) = val;
|
||||
setBinaryField<int128_t>(&val, colIndex);
|
||||
}
|
||||
|
||||
inline void Row::setVarBinaryField(const std::string& val, uint32_t colIndex)
|
||||
|
@ -285,7 +285,6 @@ const static_any::any& mcsv1_UDAF::ushortTypeId((unsigned short)1);
|
||||
const static_any::any& mcsv1_UDAF::uintTypeId((unsigned int)1);
|
||||
const static_any::any& mcsv1_UDAF::ulongTypeId((unsigned long)1);
|
||||
const static_any::any& mcsv1_UDAF::ullTypeId((unsigned long long)1);
|
||||
const static_any::any& mcsv1_UDAF::uint128TypeId((uint128_t)1);
|
||||
const static_any::any& mcsv1_UDAF::floatTypeId((float)1);
|
||||
const static_any::any& mcsv1_UDAF::doubleTypeId((double)1);
|
||||
const static_any::any& mcsv1_UDAF::strTypeId(typeStr);
|
||||
|
@ -644,7 +644,6 @@ protected:
|
||||
static const static_any::any& uintTypeId;
|
||||
static const static_any::any& ulongTypeId;
|
||||
static const static_any::any& ullTypeId;
|
||||
static const static_any::any& uint128TypeId;
|
||||
static const static_any::any& floatTypeId;
|
||||
static const static_any::any& doubleTypeId;
|
||||
static const static_any::any& strTypeId;
|
||||
@ -1075,10 +1074,6 @@ inline T mcsv1_UDAF::convertAnyTo(static_any::any& valIn)
|
||||
{
|
||||
val = valIn.cast<int128_t>();
|
||||
}
|
||||
else if (valIn.compatible(uint128TypeId))
|
||||
{
|
||||
val = valIn.cast<uint128_t>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("mcsv1_UDAF::convertAnyTo(): input param has unrecognized type");
|
||||
|
@ -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