1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +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:
Roman Nozdrin
2020-11-06 10:52:43 +00:00
parent d5c6645ba1
commit 3eb26c0d4a
35 changed files with 505 additions and 364 deletions

View File

@ -1,6 +1,7 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
set(datatypes_LIB_SRCS
mcs_int128.cpp
mcs_decimal.cpp)
add_library(datatypes SHARED ${datatypes_LIB_SRCS})

View File

@ -198,6 +198,14 @@ namespace datatypes
std::string Decimal::toString(VDecimal& value)
{
char buf[Decimal::MAXLENGTH16BYTES];
if (value.s128Value == Decimal128Null)
{
return std::string("NULL");
}
else if (value.s128Value == Decimal128Empty)
{
return std::string("EMPTY");
}
dataconvert::DataConvert::decimalToString(&value.s128Value,
value.scale, buf, (uint8_t) sizeof(buf),
datatypes::SystemCatalog::DECIMAL);
@ -209,6 +217,23 @@ namespace datatypes
return toString(const_cast<VDecimal&>(value));
}
std::string Decimal::toString(const int128_t& value)
{
char buf[Decimal::MAXLENGTH16BYTES];
if (value == Decimal128Null)
{
return std::string("NULL");
}
else if (value == Decimal128Empty)
{
return std::string("EMPTY");
}
int128_t& constLessValue = const_cast<int128_t&>(value);
dataconvert::DataConvert::decimalToString(&constLessValue,
0, buf, sizeof(buf), datatypes::SystemCatalog::DECIMAL);
return std::string(buf);
}
int Decimal::compare(const VDecimal& l, const VDecimal& r)
{
int128_t divisorL, divisorR;

View File

@ -24,11 +24,12 @@
#include "mcs_basic_types.h"
#include "exceptclasses.h"
#include "widedecimalutils.h"
#include "mcs_int128.h"
namespace datatypes
{
struct VDecimal;
class VDecimal;
}
// A class by Fabio Fernandes pulled off of stackoverflow
@ -259,10 +260,11 @@ class Decimal
VDecimal& result);
/**
@brief Convenience method to put decimal into a std::string.
@brief Convenience methods to put decimal into a std::string.
*/
static std::string toString(VDecimal& value);
static std::string toString(const VDecimal& value);
static std::string toString(const int128_t& value);
/**
@brief The method detects whether decimal type is wide
@ -339,20 +341,7 @@ class Decimal
return static_cast<uint64_t>(value);
}
/**
@brief The method converts a __float128 value to a double.
*/
static inline double getDoubleFromFloat128(const __float128& value)
{
if (value > static_cast<__float128>(DBL_MAX))
return DBL_MAX;
else if (value < -static_cast<__float128>(DBL_MAX))
return -DBL_MAX;
return static_cast<double>(value);
}
/**
/**
@brief The method converts a wide decimal value to a double.
*/
static inline double getDoubleFromWideDecimal(const int128_t& value, int8_t scale)
@ -374,19 +363,6 @@ class Decimal
return getDoubleFromFloat128(static_cast<__float128>(value));
}
/**
@brief The method converts a __float128 value to a long double.
*/
static inline long double getLongDoubleFromFloat128(const __float128& value)
{
if (value > static_cast<__float128>(LDBL_MAX))
return LDBL_MAX;
else if (value < -static_cast<__float128>(LDBL_MAX))
return -LDBL_MAX;
return static_cast<long double>(value);
}
/**
@brief The method converts a wide decimal value to a long double.
*/
@ -568,19 +544,19 @@ struct NoOverflowCheck {
* @brief VDecimal type
*
*/
struct VDecimal
class VDecimal: public TSInt128
{
VDecimal(): s128Value(0), value(0), scale(0), precision(0)
public:
VDecimal(): value(0), scale(0), precision(0)
{
}
VDecimal(int64_t val, int8_t s, uint8_t p, const int128_t &val128 = 0) :
s128Value(val128),
TSInt128(val128),
value(val),
scale(s),
precision(p)
{
}
{ }
int decimalComp(const VDecimal& d) const
{
@ -843,7 +819,6 @@ struct VDecimal
}
}
int128_t s128Value;
int64_t value;
int8_t scale; // 0~38
uint8_t precision; // 1~38

82
datatypes/mcs_int128.cpp Normal file
View File

@ -0,0 +1,82 @@
/*
Copyright (C) 2020 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include "mcs_int128.h"
namespace datatypes
{
// The method converts a wide decimal s128Value to a double.
inline double TSInt128::getDoubleFromWideDecimal()
{
return getDoubleFromFloat128(static_cast<__float128>(s128Value));
}
// The method converts a wide decimal s128Value to a long double.
inline long double TSInt128::getLongDoubleFromWideDecimal()
{
return getLongDoubleFromFloat128(static_cast<__float128>(s128Value));
}
// The method converts a wide decimal s128Value to an int64_t,
// saturating the s128Value if necessary.
inline int64_t TSInt128::getInt64FromWideDecimal()
{
if (s128Value > static_cast<int128_t>(INT64_MAX))
return INT64_MAX;
else if (s128Value < static_cast<int128_t>(INT64_MIN))
return INT64_MIN;
return static_cast<int64_t>(s128Value);
}
// The method converts a wide decimal s128Value to an uint32_t.
inline uint32_t TSInt128::getUInt32FromWideDecimal()
{
if (s128Value > static_cast<int128_t>(UINT32_MAX))
return UINT32_MAX;
else if (s128Value < 0)
return 0;
return static_cast<uint32_t>(s128Value);
}
// The method converts a wide decimal s128Value to an uint64_t.
inline uint64_t TSInt128::getUInt64FromWideDecimal()
{
if (s128Value > static_cast<int128_t>(UINT64_MAX))
return UINT64_MAX;
else if (s128Value < 0)
return 0;
return static_cast<uint64_t>(s128Value);
}
// The method converts a wide decimal s128Value to an int32_t.
inline int32_t TSInt128::getInt32FromWideDecimal()
{
if (s128Value > static_cast<int128_t>(INT32_MAX))
return INT32_MAX;
else if (s128Value < static_cast<int128_t>(INT32_MIN))
return INT32_MIN;
return static_cast<int32_t>(s128Value);
}
} // end of namespace datatypes
// vim:ts=2 sw=2:

187
datatypes/mcs_int128.h Normal file
View File

@ -0,0 +1,187 @@
/*
Copyright (C) 2020 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#ifndef MCS_INT128_H_INCLUDED
#define MCS_INT128_H_INCLUDED
#include <cfloat>
#include <cstdint>
#include <limits>
#include <type_traits>
// Inline asm has three argument lists: output, input and clobber list
#if defined(__GNUC__) && (__GNUC___ > 7)
#define MACRO_VALUE_PTR_128(dst, \
dst_restrictions, \
src, \
src_restrictions, \
clobb) \
__asm__ volatile("movups %1,%0" \
:dst_restrictions ( *(dst) ) \
:src_restrictions ( (src) ) \
:clobb \
);
#define MACRO_PTR_PTR_128(dst, \
dst_restrictions, \
src, \
src_restrictions, \
clobb) \
::memcpy((dst), (src), sizeof(int128_t));
#else
#define MACRO_VALUE_PTR_128(dst, \
dst_restrictions, \
src, \
src_restrictions, \
clobb) \
__asm__ volatile("movups %1,%0" \
:dst_restrictions ( *(dst) ) \
:src_restrictions ( (src) ) \
:clobb \
);
#define MACRO_PTR_PTR_128(dst, \
dst_restrictions, \
src, \
src_restrictions, \
clobb) \
__asm__ volatile("movdqu %1,%%xmm0;" \
"movups %%xmm0,%0;" \
:dst_restrictions ( *(dst) ) \
:src_restrictions ( *(src) ) \
:"memory", clobb \
);
#endif
namespace datatypes
{
using int128_t = __int128;
// Type traits
template <typename T>
struct is_allowed_numeric {
static const bool value = false;
};
template <>
struct is_allowed_numeric<int> {
static const bool value = true;
};
template <>
struct is_allowed_numeric<int128_t> {
static const bool value = true;
};
// The method converts a __float128 s128Value to a double.
static inline double getDoubleFromFloat128(const __float128& value)
{
if (value > static_cast<__float128>(DBL_MAX))
return DBL_MAX;
else if (value < -static_cast<__float128>(DBL_MAX))
return -DBL_MAX;
return static_cast<double>(value);
}
// The method converts a __float128 value to a long double.
static inline long double getLongDoubleFromFloat128(const __float128& value)
{
if (value > static_cast<__float128>(LDBL_MAX))
return LDBL_MAX;
else if (value < -static_cast<__float128>(LDBL_MAX))
return -LDBL_MAX;
return static_cast<long double>(value);
}
class TSInt128
{
public:
// A variety of ctors for aligned and unaligned arguments
TSInt128(): s128Value(0) { }
// aligned argument
TSInt128(const int128_t& x) { s128Value = x; }
// unaligned argument
TSInt128(const int128_t* x) { assignPtrPtr(&s128Value, x); }
// unaligned argument
TSInt128(const unsigned char* x) { assignPtrPtr(&s128Value, x); }
// The method copies 16 bytes from one memory cell
// into another using memcpy or SIMD.
// memcpy in gcc >= 7 is replaced with SIMD instructions
template <typename D, typename S>
static inline void assignPtrPtr(D* dst, const S* src)
{
MACRO_PTR_PTR_128(dst, "=m", src, "m", "xmm0")
}
template <typename D>
static inline void storeUnaligned(D* dst, const int128_t& src)
{
MACRO_VALUE_PTR_128(dst, "=m", src, "x", "memory")
}
// operators
template<typename T,
typename = std::enable_if<is_allowed_numeric<T>::value> >
inline bool operator<(const T& x) const
{
return s128Value < static_cast<int128_t>(x);
}
template<typename T,
typename = std::enable_if<is_allowed_numeric<T>::value> >
inline bool operator==(const T& x) const
{
return s128Value == static_cast<int128_t>(x);
}
// The method converts a wide decimal s128Value to a double.
inline double getDoubleFromWideDecimal();
// The method converts a wide decimal s128Value to a long double.
inline long double getLongDoubleFromWideDecimal();
// The method converts a wide decimal s128Value to an int64_t,
// saturating the s128Value if necessary.
inline int64_t getInt64FromWideDecimal();
// The method converts a wide decimal s128Value to an uint32_t.
inline uint32_t getUInt32FromWideDecimal();
// The method converts a wide decimal s128Value to an uint64_t.
inline uint64_t getUInt64FromWideDecimal();
// The method converts a wide decimal s128Value to an int32_t.
inline int32_t getInt32FromWideDecimal();
int128_t s128Value;
}; // end of class
} //end of namespace datatypes
#endif // MCS_TSINT128_H_INCLUDED
// vim:ts=2 sw=2:

View File

@ -635,8 +635,8 @@ void SimpleColumn::evaluate(Row& row, bool& isNull)
{
case 16:
{
fResult.decimalVal.s128Value =
*row.getBinaryField_offset<decltype(fResult.decimalVal.s128Value)>(fInputOffset);
datatypes::TSInt128::assignPtrPtr(&fResult.decimalVal.s128Value,
row.getBinaryField_offset<int128_t>(fInputOffset));
break;
}
case 1:

View File

@ -61,6 +61,12 @@ class IDB_Decimal: public datatypes::VDecimal
{
public:
using datatypes::VDecimal::VDecimal;
inline void operator=(const datatypes::TSInt128& rhs)
{
value = 0; scale = 0; precision = 0;
datatypes::TSInt128::operator=(rhs);
}
};

View File

@ -687,12 +687,12 @@ void WindowFunctionColumn::evaluate(Row& row, bool& isNull)
case 16:
{
int128_t dec = row.getInt128Field(fInputIndex);
datatypes::TSInt128 dec(row.getBinaryField<int128_t>(fInputIndex));
if (dec == datatypes::Decimal128Null)
isNull = true;
else
{
fResult.decimalVal.s128Value = dec;
fResult.decimalVal = dec;
fResult.decimalVal.scale = (unsigned)fResultType.scale;
}

View File

@ -736,7 +736,7 @@ void BatchPrimitiveProcessorJL::getRowGroupData(ByteStream& in, vector<RGData>*
uint32_t threadID, bool* hasWideColumn, const execplan::CalpontSystemCatalog::ColType& colType) const
{
uint64_t tmp64;
uint128_t tmp128;
int128_t tmp128;
uint8_t tmp8;
RGData rgData;
uint32_t rowCount;

View File

@ -236,23 +236,15 @@ bool LBIDList::GetMinMax(T& min, T& max, int64_t& seq, int64_t lbid,
if (isUnsigned(colDataType))
{
if (typeid(T) == typeid(int128_t))
{
mmp->bigMax = 0;
mmp->bigMin = -1;
}
else
{
mmp->max = 0;
mmp->min = static_cast<int64_t>(numeric_limits<uint64_t>::max());
}
mmp->max = 0;
mmp->min = static_cast<int64_t>(numeric_limits<uint64_t>::max());
}
else
{
if (typeid(T) == typeid(int128_t))
{
utils::int128Min(mmp->bigMax);
utils::int128Max(mmp->bigMin);
mmp->bigMax = datatypes::Decimal::minInt128;
mmp->bigMin = datatypes::Decimal::maxInt128;
}
else
{
@ -296,23 +288,15 @@ bool LBIDList::GetMinMax(T* min, T* max, int64_t* seq,
if (isUnsigned(colDataType))
{
if (typeid(T) == typeid(int128_t))
{
mmp->bigMax = 0;
mmp->bigMin = -1;
}
else
{
mmp->max = 0;
mmp->min = static_cast<int64_t>(numeric_limits<uint64_t>::max());
}
mmp->max = 0;
mmp->min = static_cast<int64_t>(numeric_limits<uint64_t>::max());
}
else
{
if (typeid(T) == typeid(int128_t))
{
utils::int128Min(mmp->bigMax);
utils::int128Max(mmp->bigMin);
mmp->bigMax = datatypes::Decimal::minInt128;
mmp->bigMin = datatypes::Decimal::maxInt128;
}
else
{
@ -327,6 +311,7 @@ bool LBIDList::GetMinMax(T* min, T* max, int64_t* seq,
return false;
}
// *DRRTUY min/max should be 16 aligned here
if (typeid(T) == typeid(int128_t))
{
*min = entry.partition.cprange.bigLoVal;
@ -356,6 +341,7 @@ int LBIDList::getMinMaxFromEntries(T& min, T& max, int32_t& seq,
if (lbid >= EMEntries[i].range.start && lbid <= lastLBID)
{
// *DRRTUY min/max should be 16 aligned here
if (typeid(T) == typeid(int128_t))
{
min = EMEntries[i].partition.cprange.bigLoVal;
@ -426,32 +412,25 @@ void LBIDList::UpdateMinMax(T min, T max, int64_t lbid, CalpontSystemCatalog::Co
}
else if (datatypes::isUnsigned(type))
{
if (typeid(T) == typeid(int128_t))
{
if (static_cast<uint128_t>(min) < static_cast<uint128_t>(mmp->bigMin))
mmp->bigMin = min;
if (static_cast<uint64_t>(min) < static_cast<uint64_t>(mmp->min))
mmp->min = min;
if (static_cast<uint128_t>(max) > static_cast<uint128_t>(mmp->bigMax))
mmp->bigMax = max;
}
else
{
if (static_cast<uint64_t>(min) < static_cast<uint64_t>(mmp->min))
mmp->min = min;
if (static_cast<uint64_t>(max) > static_cast<uint64_t>(mmp->max))
mmp->max = max;
}
if (static_cast<uint64_t>(max) > static_cast<uint64_t>(mmp->max))
mmp->max = max;
}
else
{
if (typeid(T) == typeid(int128_t))
{
if (min < mmp->bigMin)
{
mmp->bigMin = min;
}
if (max > mmp->bigMax)
{
mmp->bigMax = max;
}
}
else
{
@ -694,16 +673,8 @@ bool LBIDList::checkSingleValue(T min, T max, T value,
}
else if (isUnsigned(type))
{
if (typeid(T) == typeid(int128_t))
{
return (static_cast<uint128_t>(value) >= static_cast<uint128_t>(min) &&
static_cast<uint128_t>(value) <= static_cast<uint128_t>(max));
}
else
{
return (static_cast<uint64_t>(value) >= static_cast<uint64_t>(min) &&
static_cast<uint64_t>(value) <= static_cast<uint64_t>(max));
}
return (static_cast<uint64_t>(value) >= static_cast<uint64_t>(min) &&
static_cast<uint64_t>(value) <= static_cast<uint64_t>(max));
}
else
{
@ -727,16 +698,8 @@ bool LBIDList::checkRangeOverlap(T min, T max, T tmin, T tmax,
}
else if (isUnsigned(type))
{
if (typeid(T) == typeid(int128_t))
{
return (static_cast<uint128_t>(tmin) <= static_cast<uint128_t>(max) &&
static_cast<uint128_t>(tmax) >= static_cast<uint128_t>(min));
}
else
{
return (static_cast<uint64_t>(tmin) <= static_cast<uint64_t>(max) &&
static_cast<uint64_t>(tmax) >= static_cast<uint64_t>(min));
}
return (static_cast<uint64_t>(tmin) <= static_cast<uint64_t>(max) &&
static_cast<uint64_t>(tmax) >= static_cast<uint64_t>(min));
}
else
{
@ -806,13 +769,6 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
value = static_cast<int64_t>(val);
break;
}
case 16:
{
uint128_t val = *(int128_t*)MsgDataPtr;
bigValue = static_cast<int128_t>(val);
break;
}
}
}
else
@ -849,21 +805,17 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
case 16:
{
int128_t val = *(int128_t*)MsgDataPtr;
bigValue = val;
datatypes::TSInt128::assignPtrPtr(&bigValue, MsgDataPtr);
break;
}
}
}
// Should we also check for empty here?
// TODO MCOL-641
if (ct.isWideDecimalType())
if (ct.isWideDecimalType() && execplan::isNull(bigValue, ct))
{
if (isNull(bigValue, ct))
continue;
}
else if (isNull(value, ct)) // This will work even if the data column is unsigned.
else if (execplan::isNull(value, ct)) // This will work even if the data column is unsigned.
{
continue;
}
@ -885,14 +837,7 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
}
else if (bIsUnsigned)
{
if (ct.colWidth != datatypes::MAXDECIMALWIDTH)
{
scan = compareVal(static_cast<uint64_t>(cpRange.loVal), static_cast<uint64_t>(cpRange.hiVal), static_cast<uint64_t>(value), op, lcf);
}
else
{
scan = compareVal(static_cast<uint128_t>(cpRange.bigLoVal), static_cast<uint128_t>(cpRange.bigHiVal), static_cast<uint128_t>(bigValue), op, lcf);
}
scan = compareVal(static_cast<uint64_t>(cpRange.loVal), static_cast<uint64_t>(cpRange.hiVal), static_cast<uint64_t>(value), op, lcf);
}
else
{

View File

@ -91,7 +91,7 @@ public:
// Functions to handle min/max values per lbid for casual partitioning;
// If pEMEntries is provided, then min/max will be extracted from that
// vector, else extents in BRM will be searched. If type is unsigned, caller
// should static cast returned min and max to uint64_t/uint128_t
// should static cast returned min and max to uint64_t/int128_t
template<typename T>
bool GetMinMax(T& min, T& max, int64_t& seq, int64_t lbid,
const std::vector<struct BRM::EMEntry>* pEMEntries,

View File

@ -42,6 +42,7 @@ using namespace boost;
#include "primproc.h"
#include "dataconvert.h"
#include "mcs_decimal.h"
using namespace logging;
using namespace dbbc;
using namespace primitives;
@ -765,6 +766,8 @@ inline void store(const NewColRequestHeader* in,
default:
std::cout << __func__ << " WARNING!!! unspecified column width." << std::endl;
[[fallthrough]];
case 8:
ptr2 += (rid << 3);
memcpy(ptr1, ptr2, 8);
@ -1723,22 +1726,31 @@ inline void p_Col_bin_ridArray(NewColRequestHeader* in,
// Set the min and max if necessary. Ignore nulls.
if (out->ValidMinMax && !isNull && !isEmpty)
{
if (in->DataType == CalpontSystemCatalog::CHAR || in->DataType == CalpontSystemCatalog::VARCHAR)
{
// !!! colCompare is overloaded with int128_t only yet.
if (colCompare(out->Min, val, COMPARE_GT, false, in->DataType, W, placeholderRegex))
{
out->Min = val;
}
if (colCompare(out->Max, val, COMPARE_LT, false, in->DataType, W, placeholderRegex))
{
out->Max = val;
}
}
else
{
if (out->Min > val)
{
out->Min = val;
}
if (out->Max < val)
{
out->Max = val;
}
}
}
@ -1828,6 +1840,7 @@ void PrimitiveProcessor::p_Col(NewColRequestHeader* in, NewColResultHeader* out,
case 32:
std::cout << __func__ << " WARNING!!! Not implemented for 32 byte data types." << std::endl;
[[fallthrough]];
default:
idbassert(0);
@ -1956,7 +1969,11 @@ boost::shared_ptr<ParsedColumnFilter> parseColumnFilter
break;
case 16:
ret->prestored_argVals128[argIndex] = *reinterpret_cast<const int128_t*>(args->val);
{
datatypes::TSInt128::assignPtrPtr(&(ret->prestored_argVals128[argIndex]),
args->val);
break;
}
}
}

View File

@ -21,8 +21,6 @@ set(PrimProc_SRCS
umsocketselector.cpp
../../utils/common/crashtrace.cpp)
#PrimProc_CXXFLAGS = $(march_flags) $(AM_CXXFLAGS)
add_executable(PrimProc ${PrimProc_SRCS})
add_dependencies(PrimProc loggingcpp)

View File

@ -40,6 +40,7 @@ using namespace std;
#include "primitiveserver.h"
#include "primproc.h"
#include "stats.h"
#include "datatypes/mcs_int128.h"
using namespace messageqcpp;
using namespace rowgroup;
@ -231,11 +232,7 @@ void ColumnCommand::loadData()
{
ByteStream::hexbyte h;
utils::getEmptyRowValue(colType.colDataType, colType.colWidth, (uint8_t*)&h);
__asm__ volatile("movups %1,%0"
:"=m" ( hPtr[idx] ) // output
:"v"( h ) // input
: "memory" // clobbered
);
datatypes::TSInt128::storeUnaligned(hPtr + idx, h);
}
}
@ -332,18 +329,7 @@ void ColumnCommand::process_OT_BOTH()
bpp->relRids[i] = *((uint16_t*) &bpp->outputMsg[pos]);
pos += 2;
int128_t* int128Ptr = reinterpret_cast<int128_t*>(&bpp->outputMsg[pos]);
__asm__ volatile("movdqu %0,%%xmm0;"
:
:"m"( *int128Ptr ) // input
:"xmm0" // clobbered
);
__asm__ volatile("movups %%xmm0,%0;"
: "=m" (wide128Values[i])// output
: // input
: "memory", "xmm0" // clobbered
);
datatypes::TSInt128::assignPtrPtr(&wide128Values[i], &bpp->outputMsg[pos]);
pos += 16;
}

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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");

View File

@ -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:

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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>&);

View File

@ -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
{
@ -95,19 +102,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:
{

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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))
{

View File

@ -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)
{

View File

@ -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);

View File

@ -2992,7 +2992,6 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
// WIP MCOL-641
if (fetchColColwidths[fetchColPos] == datatypes::MAXDECIMALWIDTH)
{
int128_t* dec;
@ -3007,9 +3006,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
break;
}
// else
// fall through to integer cases
[[fallthrough]];
}
/* fall through */
@ -3360,7 +3357,6 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
{
if (fetchColColwidths[fetchColPos] == datatypes::MAXDECIMALWIDTH)
{
// WIP MCOL-641
int128_t* dec;
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
dec = row.getBinaryField<int128_t>(fetchColPos);
@ -3373,9 +3369,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
break;
}
// else
// fall through to integer cases
[[fallthrough]];
}
/* fall through */