You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
MCOL-1822 add LONG DOUBLE support
This commit is contained in:
@@ -871,7 +871,7 @@ bool mysql_str_to_datetime( const string& input, DateTime& output, bool& isDate
|
||||
|
||||
bool mysql_str_to_time( const string& input, Time& output, long decimals )
|
||||
{
|
||||
int32_t datesepct = 0;
|
||||
// int32_t datesepct = 0;
|
||||
uint32_t dtend = 0;
|
||||
bool isNeg = false;
|
||||
|
||||
@@ -2995,6 +2995,7 @@ CalpontSystemCatalog::ColType DataConvert::convertUnionColType(vector<CalpontSys
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3022,6 +3023,7 @@ CalpontSystemCatalog::ColType DataConvert::convertUnionColType(vector<CalpontSys
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
unionedType.colDataType = CalpontSystemCatalog::CHAR;
|
||||
unionedType.scale = 0;
|
||||
unionedType.colWidth = 20;
|
||||
@@ -3070,6 +3072,7 @@ CalpontSystemCatalog::ColType DataConvert::convertUnionColType(vector<CalpontSys
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
case CalpontSystemCatalog::TIME:
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
unionedType.colDataType = CalpontSystemCatalog::CHAR;
|
||||
unionedType.scale = 0;
|
||||
unionedType.colWidth = 26;
|
||||
@@ -3159,6 +3162,63 @@ CalpontSystemCatalog::ColType DataConvert::convertUnionColType(vector<CalpontSys
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
switch (unionedType.colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::DATE:
|
||||
unionedType.colDataType = CalpontSystemCatalog::CHAR;
|
||||
unionedType.scale = 0;
|
||||
unionedType.colWidth = 20;
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
unionedType.colDataType = CalpontSystemCatalog::CHAR;
|
||||
unionedType.scale = 0;
|
||||
unionedType.colWidth = 26;
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
if (unionedType.colWidth < 20)
|
||||
unionedType.colWidth = 20;
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
if (unionedType.colWidth < 21)
|
||||
unionedType.colWidth = 21;
|
||||
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::TINYINT:
|
||||
case CalpontSystemCatalog::SMALLINT:
|
||||
case CalpontSystemCatalog::MEDINT:
|
||||
case CalpontSystemCatalog::INT:
|
||||
case CalpontSystemCatalog::BIGINT:
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::FLOAT:
|
||||
case CalpontSystemCatalog::DOUBLE:
|
||||
case CalpontSystemCatalog::UTINYINT:
|
||||
case CalpontSystemCatalog::USMALLINT:
|
||||
case CalpontSystemCatalog::UMEDINT:
|
||||
case CalpontSystemCatalog::UINT:
|
||||
case CalpontSystemCatalog::UBIGINT:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
unionedType.colDataType = CalpontSystemCatalog::LONGDOUBLE;
|
||||
unionedType.scale = 0;
|
||||
unionedType.colWidth = sizeof(long double);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
@@ -3180,6 +3240,7 @@ CalpontSystemCatalog::ColType DataConvert::convertUnionColType(vector<CalpontSys
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
case CalpontSystemCatalog::UFLOAT:
|
||||
case CalpontSystemCatalog::UDOUBLE:
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
unionedType.scale = 0;
|
||||
unionedType.colWidth = (types[i].colWidth > 20) ? types[i].colWidth : 20;
|
||||
break;
|
||||
|
@@ -196,6 +196,24 @@ inline bool getBool(rowgroup::Row& row,
|
||||
numericLE(val, pm[2]->data()->getDoubleVal(row, isNull));
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
long double val = pm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
if (notBetween)
|
||||
{
|
||||
if (!numericGE(val, pm[1]->data()->getLongDoubleVal(row, isNull)) && !isNull)
|
||||
return true;
|
||||
|
||||
isNull = false;
|
||||
return (!numericLE(val, pm[2]->data()->getLongDoubleVal(row, isNull)) && !isNull);
|
||||
}
|
||||
|
||||
return !isNull &&
|
||||
numericGE(val, pm[1]->data()->getLongDoubleVal(row, isNull)) &&
|
||||
numericLE(val, pm[2]->data()->getLongDoubleVal(row, isNull));
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
|
@@ -123,6 +123,12 @@ int64_t Func_ceil::getIntVal(Row& row,
|
||||
}
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
ret = (int64_t) ceill(parm[0]->data()->getLongDoubleVal(row, isNull));
|
||||
}
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::TEXT:
|
||||
|
@@ -103,6 +103,21 @@ string Func_hex::getStrVal(rowgroup::Row& row,
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
char buf[256];
|
||||
long double val = parm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
sprintf(buf, "%llA", val);
|
||||
|
||||
#else
|
||||
sprintf(buf, "%LA", val);
|
||||
#endif
|
||||
retval = buf;
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::VARBINARY:
|
||||
case CalpontSystemCatalog::BLOB:
|
||||
{
|
||||
|
@@ -61,7 +61,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
if (isNull)
|
||||
return "";
|
||||
|
||||
int64_t count = fp[2]->data()->getIntVal(row, isNull);
|
||||
size_t count = fp[2]->data()->getIntVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
return "";
|
||||
@@ -71,7 +71,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
|
||||
size_t end = strlen(str.c_str());
|
||||
|
||||
if ( count > (int64_t) end )
|
||||
if ( count > end )
|
||||
return str;
|
||||
|
||||
if (( count < 0 ) && ((count * -1) > end))
|
||||
@@ -83,7 +83,7 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
{
|
||||
int pointer = 0;
|
||||
|
||||
for ( int i = 0 ; i < count ; i ++ )
|
||||
for ( size_t i = 0 ; i < count ; i ++ )
|
||||
{
|
||||
string::size_type pos = str.find(delim, pointer);
|
||||
|
||||
@@ -102,13 +102,13 @@ std::string Func_substring_index::getStrVal(rowgroup::Row& row,
|
||||
int pointer = end;
|
||||
int start = 0;
|
||||
|
||||
for ( int i = 0 ; i < count ; i ++ )
|
||||
for ( size_t i = 0 ; i < count ; i ++ )
|
||||
{
|
||||
string::size_type pos = str.rfind(delim, pointer);
|
||||
|
||||
if (pos != string::npos)
|
||||
{
|
||||
if ( count > (int64_t) end )
|
||||
if ( count > end )
|
||||
return "";
|
||||
|
||||
pointer = pos - 1;
|
||||
|
@@ -439,6 +439,18 @@ void FuncExp::evaluate(rowgroup::Row& row, std::vector<execplan::SRCP>& expressi
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
long double val = expression[i]->getLongDoubleVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
row.setLongDoubleField(LONGDOUBLENULL, expression[i]->outputIndex());
|
||||
else
|
||||
row.setLongDoubleField(val, expression[i]->outputIndex());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
|
@@ -57,6 +57,14 @@ public:
|
||||
return strtod(getStrVal(row, fp, isNull, op_ct).c_str(), NULL);
|
||||
}
|
||||
|
||||
double getLongDoubleVal(rowgroup::Row& row,
|
||||
FunctionParm& fp,
|
||||
bool& isNull,
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
return strtold(getStrVal(row, fp, isNull, op_ct).c_str(), NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
std::string getStrVal(rowgroup::Row& row,
|
||||
FunctionParm& fp,
|
||||
@@ -105,12 +113,16 @@ protected:
|
||||
// Bug3788, use the shorter of fixed or scientific notation for floating point values.
|
||||
// [ the default format in treenode.h is fixed-point notation ]
|
||||
char buf[20];
|
||||
double floatVal;
|
||||
int exponent;
|
||||
double base;
|
||||
long double floatVal;
|
||||
int64_t exponent;
|
||||
long double base;
|
||||
|
||||
switch (fp->data()->resultType().colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||
floatVal = fp->data()->getLongDoubleVal(row, isNull);
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
floatVal = fp->data()->getDoubleVal(row, isNull);
|
||||
break;
|
||||
@@ -125,19 +137,19 @@ protected:
|
||||
break;
|
||||
}
|
||||
|
||||
exponent = (int)floor(log10( fabs(floatVal)));
|
||||
exponent = (int)floor(log10( fabsl(floatVal)));
|
||||
base = floatVal * pow(10, -1.0 * exponent);
|
||||
|
||||
if (isnan(exponent) || isnan(base))
|
||||
{
|
||||
snprintf(buf, 20, "%f", floatVal);
|
||||
snprintf(buf, 20, "%Lf", floatVal);
|
||||
fFloatStr = execplan::removeTrailing0(buf, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buf, 20, "%.5f", base);
|
||||
snprintf(buf, 20, "%.5Lf", base);
|
||||
fFloatStr = execplan::removeTrailing0(buf, 20);
|
||||
snprintf(buf, 20, "e%02d", exponent);
|
||||
snprintf(buf, 20, "e%02ld", exponent);
|
||||
fFloatStr += buf;
|
||||
}
|
||||
|
||||
|
@@ -118,7 +118,6 @@ JoinPartition::JoinPartition(const JoinPartition& jp, bool splitMode) :
|
||||
totalBytesWritten(0), maxLargeSize(0), maxSmallSize(0),
|
||||
nextSmallOffset(0), nextLargeOffset(0)
|
||||
{
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
boost::posix_time::ptime t;
|
||||
ostringstream os;
|
||||
|
||||
|
@@ -636,6 +636,18 @@ ByteStream& ByteStream::operator<<(const double d)
|
||||
|
||||
return *this;
|
||||
}
|
||||
ByteStream& ByteStream::operator<<(const long double d)
|
||||
{
|
||||
int sz = sizeof(long double);
|
||||
|
||||
if (fBuf == 0 || (fCurInPtr - fBuf + sz > fMaxLen + ISSOverhead))
|
||||
growBuf(fMaxLen + BlockSize);
|
||||
|
||||
*((long double*) fCurInPtr) = d;
|
||||
fCurInPtr += sz;
|
||||
|
||||
return *this;
|
||||
}
|
||||
ByteStream& ByteStream::operator>>(float& f)
|
||||
{
|
||||
peek(f);
|
||||
@@ -648,6 +660,12 @@ ByteStream& ByteStream::operator>>(double& d)
|
||||
fCurOutPtr += sizeof(double);
|
||||
return *this;
|
||||
}
|
||||
ByteStream& ByteStream::operator>>(long double& d)
|
||||
{
|
||||
peek(d);
|
||||
fCurOutPtr += sizeof(long double);
|
||||
return *this;
|
||||
}
|
||||
void ByteStream::peek(float& f) const
|
||||
{
|
||||
if (length() < sizeof(float))
|
||||
@@ -663,6 +681,14 @@ void ByteStream::peek(double& d) const
|
||||
d = *((double*) fCurOutPtr);
|
||||
}
|
||||
|
||||
void ByteStream::peek(long double& d) const
|
||||
{
|
||||
if (length() < sizeof(long double))
|
||||
throw underflow_error("ByteStream>int64_t: not enough data in stream to fill datatype");
|
||||
|
||||
d = *((long double*) fCurOutPtr);
|
||||
}
|
||||
|
||||
|
||||
}//namespace messageqcpp
|
||||
|
||||
|
@@ -153,6 +153,11 @@ public:
|
||||
* whatever the native byte order is.
|
||||
*/
|
||||
EXPORT ByteStream& operator<<(const double d);
|
||||
/**
|
||||
* push a long double onto the end of the stream. The byte
|
||||
* order is whatever the native byte order is.
|
||||
*/
|
||||
EXPORT ByteStream& operator<<(const long double d);
|
||||
/**
|
||||
* push a std::string onto the end of the stream.
|
||||
*/
|
||||
@@ -212,6 +217,11 @@ public:
|
||||
* order is whatever the native byte order is.
|
||||
*/
|
||||
EXPORT ByteStream& operator>>(double& d);
|
||||
/**
|
||||
* extract a long double from the front of the stream. The byte
|
||||
* order is whatever the native byte order is.
|
||||
*/
|
||||
EXPORT ByteStream& operator>>(long double& d);
|
||||
/**
|
||||
* extract a std::string from the front of the stream.
|
||||
*/
|
||||
@@ -277,6 +287,11 @@ public:
|
||||
* order is whatever the native byte order is.
|
||||
*/
|
||||
EXPORT void peek(double& f) const;
|
||||
/**
|
||||
* Peek at a long double from the front of the stream. The byte
|
||||
* order is whatever the native byte order is.
|
||||
*/
|
||||
EXPORT void peek(long double& f) const;
|
||||
/**
|
||||
* Peek at a std::string from the front of the stream.
|
||||
*/
|
||||
|
@@ -702,6 +702,9 @@ void Row::initToNull()
|
||||
*((uint64_t*) &data[offsets[i]]) = joblist::DOUBLENULL;
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
*((long double*) &data[offsets[i]]) = joblist::LONGDOUBLENULL;
|
||||
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
*((uint64_t*) &data[offsets[i]]) = joblist::DATETIMENULL;
|
||||
break;
|
||||
@@ -804,13 +807,6 @@ void Row::initToNull()
|
||||
*((uint64_t*) &data[offsets[i]]) = joblist::UBIGINTNULL;
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
{
|
||||
// no NULL value for long double yet, this is a nan.
|
||||
memset(&data[offsets[i]], 0xFF, getColumnWidth(i));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ostringstream os;
|
||||
os << "Row::initToNull(): got bad column type (" << types[i] <<
|
||||
@@ -956,7 +952,7 @@ bool Row::isNullValue(uint32_t colIndex) const
|
||||
return (*((uint64_t*) &data[offsets[colIndex]]) == joblist::UBIGINTNULL);
|
||||
|
||||
case CalpontSystemCatalog::LONGDOUBLE:
|
||||
// return false; // no NULL value for long double yet
|
||||
return (*((long double*) &data[offsets[colIndex]]) == joblist::LONGDOUBLENULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -330,6 +330,7 @@ public:
|
||||
template<int len> inline int64_t getIntField(uint32_t colIndex) const;
|
||||
inline int64_t getIntField(uint32_t colIndex) const;
|
||||
template<int len> inline bool equals(uint64_t val, uint32_t colIndex) const;
|
||||
inline bool equals(long double val, uint32_t colIndex) const;
|
||||
inline bool equals(const std::string& val, uint32_t colIndex) const;
|
||||
|
||||
inline double getDoubleField(uint32_t colIndex) const;
|
||||
@@ -616,6 +617,11 @@ inline bool Row::equals(uint64_t val, uint32_t colIndex) const
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Row::equals(long double val, uint32_t colIndex) const
|
||||
{
|
||||
return *((long double*) &data[offsets[colIndex]]) == val;
|
||||
}
|
||||
|
||||
inline bool Row::equals(const std::string& val, uint32_t colIndex) const
|
||||
{
|
||||
if (inStringTable(colIndex))
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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:
|
||||
{
|
||||
|
@@ -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));
|
||||
|
@@ -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;
|
||||
|
@@ -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] + ")";
|
||||
|
@@ -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] + ")";
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user