1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-18 21:44:02 +03:00

chore(datatypes): this refactors the placement of the main SQL data types enum to enable templates that are parametrized with this enum(see mcs_datatype_basic.h changes for more details).

This commit is contained in:
Roman Nozdrin 2023-10-22 21:21:10 +00:00 committed by Leonid Fedorov
parent 244e0adc8e
commit eb744eafed
12 changed files with 935 additions and 917 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -26,39 +26,242 @@
needed in multiple mcs_TYPE.h files.
*/
namespace datatypes
{
class SystemCatalog
{
public:
/** the set of Calpont column widths
*
*/
enum ColWidth
{
ONE_BIT,
ONE_BYTE,
TWO_BYTE,
THREE_BYTE,
FOUR_BYTE,
FIVE_BYTE,
SIX_BYTE,
SEVEN_BYTE,
EIGHT_BYTE
};
/** the set of Calpont column data types
*
*/
enum ColDataType
{
BIT, /*!< BIT type */
TINYINT, /*!< TINYINT type */
CHAR, /*!< CHAR type */
SMALLINT, /*!< SMALLINT type */
DECIMAL, /*!< DECIMAL type */
MEDINT, /*!< MEDINT type */
INT, /*!< INT type */
FLOAT, /*!< FLOAT type */
DATE, /*!< DATE type */
BIGINT, /*!< BIGINT type */
DOUBLE, /*!< DOUBLE type */
DATETIME, /*!< DATETIME type */
VARCHAR, /*!< VARCHAR type */
VARBINARY, /*!< VARBINARY type */
CLOB, /*!< CLOB type */
BLOB, /*!< BLOB type */
UTINYINT, /*!< Unsigned TINYINT type */
USMALLINT, /*!< Unsigned SMALLINT type */
UDECIMAL, /*!< Unsigned DECIMAL type */
UMEDINT, /*!< Unsigned MEDINT type */
UINT, /*!< Unsigned INT type */
UFLOAT, /*!< Unsigned FLOAT type */
UBIGINT, /*!< Unsigned BIGINT type */
UDOUBLE, /*!< Unsigned DOUBLE type */
TEXT, /*!< TEXT type */
TIME, /*!< TIME type */
TIMESTAMP, /*!< TIMESTAMP type */
NUM_OF_COL_DATA_TYPE, /* NEW TYPES ABOVE HERE */
LONGDOUBLE, /* @bug3241, dev and variance calculation only */
STRINT, /* @bug3532, string as int for fast comparison */
UNDEFINED, /*!< Undefined - used in UDAF API */
};
};
template <SystemCatalog::ColDataType>
struct ColTypeToIntegral
{
using type = struct
{
};
};
template <>
struct ColTypeToIntegral<SystemCatalog::TINYINT>
{
using type = int8_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::UTINYINT>
{
using type = uint8_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::SMALLINT>
{
using type = int16_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::USMALLINT>
{
using type = uint16_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::MEDINT>
{
using type = int32_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::UMEDINT>
{
using type = uint32_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::INT>
{
using type = int32_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::UINT>
{
using type = uint32_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::BIGINT>
{
using type = int64_t;
};
template <>
struct ColTypeToIntegral<SystemCatalog::UBIGINT>
{
using type = uint64_t;
};
template <SystemCatalog::ColDataType CT>
struct ranges_limits
{
using T = ColTypeToIntegral<CT>::type;
static constexpr T min()
{
if constexpr (std::is_signed_v<T>)
return std::numeric_limits<T>::min() + 2;
else
return std::numeric_limits<T>::min();
}
static constexpr T max()
{
if constexpr (std::is_signed_v<T>)
return std::numeric_limits<T>::max();
else
return std::numeric_limits<T>::max() - 2;
}
};
template <>
struct ranges_limits<SystemCatalog::MEDINT>
{
using T = int32_t;
static constexpr T min()
{
return static_cast<T>(-(1ULL << 23));
}
static constexpr T max()
{
return static_cast<T>((1ULL << 23) - 1);
}
};
template <>
struct ranges_limits<SystemCatalog::UMEDINT>
{
using T = int32_t;
static constexpr T min()
{
return static_cast<T>(0);
}
static constexpr T max()
{
return static_cast<T>((1ULL << 24) - 1);
}
};
} // namespace datatypes
namespace
{
const int64_t MIN_TINYINT __attribute__((unused)) = std::numeric_limits<int8_t>::min() + 2; // -126;
const int64_t MAX_TINYINT __attribute__((unused)) = std::numeric_limits<int8_t>::max(); // 127;
const int64_t MIN_SMALLINT __attribute__((unused)) = std::numeric_limits<int16_t>::min() + 2; // -32766;
const int64_t MAX_SMALLINT __attribute__((unused)) = std::numeric_limits<int16_t>::max(); // 32767;
const int64_t MIN_MEDINT __attribute__((unused)) = -(1ULL << 23); // -8388608;
const int64_t MAX_MEDINT __attribute__((unused)) = (1ULL << 23) - 1; // 8388607;
const int64_t MIN_INT __attribute__((unused)) = std::numeric_limits<int32_t>::min() + 2; // -2147483646;
const int64_t MAX_INT __attribute__((unused)) = std::numeric_limits<int32_t>::max(); // 2147483647;
const int64_t MIN_BIGINT = std::numeric_limits<int64_t>::min() + 2; // -9223372036854775806LL;
const int64_t MAX_BIGINT = std::numeric_limits<int64_t>::max(); // 9223372036854775807
// Signed types
const int64_t MIN_TINYINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::TINYINT>::min(); // -126;
const int64_t MIN_SMALLINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::SMALLINT>::min(); // -32766;
const int64_t MIN_MEDINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::MEDINT>::min(); // -8388608;
const int64_t MIN_INT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::INT>::min(); // -2147483646;
const int64_t MIN_BIGINT =
datatypes::ranges_limits<datatypes::SystemCatalog::BIGINT>::min(); // -9223372036854775806LL;
const uint64_t MIN_UINT __attribute__((unused)) = 0;
const uint64_t MIN_UTINYINT __attribute__((unused)) = 0;
const uint64_t MIN_USMALLINT __attribute__((unused)) = 0;
const uint64_t MIN_UMEDINT __attribute__((unused)) = 0;
const uint64_t MIN_UBIGINT = 0;
const uint64_t MAX_UINT __attribute__((unused)) = std::numeric_limits<uint32_t>::max() - 2; // 4294967293
const uint64_t MAX_UTINYINT __attribute__((unused)) = std::numeric_limits<uint8_t>::max() - 2; // 253;
const uint64_t MAX_USMALLINT __attribute__((unused)) = std::numeric_limits<uint16_t>::max() - 2; // 65533;
const uint64_t MAX_UMEDINT __attribute__((unused)) = (1ULL << 24) - 1; // 16777215
const uint64_t MAX_UBIGINT = std::numeric_limits<uint64_t>::max() - 2; // 18446744073709551613
const int64_t MAX_TINYINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::TINYINT>::max(); // 127;
const int64_t MAX_SMALLINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::SMALLINT>::max(); // 32767;
const int64_t MAX_MEDINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::MEDINT>::max(); // 8388607;
const int64_t MAX_INT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::INT>::max(); // 2147483647;
const int64_t MAX_BIGINT =
datatypes::ranges_limits<datatypes::SystemCatalog::BIGINT>::max(); // 9223372036854775807
const float MAX_FLOAT __attribute__((unused)) = std::numeric_limits<float>::max(); // 3.402823466385289e+38
// Unsigned types
const uint64_t MIN_UTINYINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::UTINYINT>::min();
const uint64_t MIN_USMALLINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::USMALLINT>::min();
const uint64_t MIN_UMEDINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::UMEDINT>::min();
const uint64_t MIN_UINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::UINT>::min();
const uint64_t MIN_UBIGINT = datatypes::ranges_limits<datatypes::SystemCatalog::UBIGINT>::min();
const uint64_t MAX_UTINYINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::UTINYINT>::max(); // 253;
const uint64_t MAX_USMALLINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::USMALLINT>::max(); // 65533;
const uint64_t MAX_UMEDINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::UMEDINT>::max(); // 16777215
const uint64_t MAX_UINT __attribute__((unused)) =
datatypes::ranges_limits<datatypes::SystemCatalog::UINT>::max(); // 4294967293
const uint64_t MAX_UBIGINT =
datatypes::ranges_limits<datatypes::SystemCatalog::UBIGINT>::max(); // 18446744073709551613
// Floating point types
const float MIN_FLOAT __attribute__((unused)) = -std::numeric_limits<float>::max();
const double MAX_DOUBLE __attribute__((unused)) =
std::numeric_limits<double>::max(); // 1.7976931348623157e+308
const double MIN_DOUBLE __attribute__((unused)) = -std::numeric_limits<double>::max();
const long double MAX_LONGDOUBLE __attribute__((unused)) =
std::numeric_limits<long double>::max(); // 1.7976931348623157e+308
const long double MIN_LONGDOUBLE __attribute__((unused)) = -std::numeric_limits<long double>::max();
const float MAX_FLOAT __attribute__((unused)) = std::numeric_limits<float>::max(); // 3.402823466385289e+38
const double MAX_DOUBLE __attribute__((unused)) =
std::numeric_limits<double>::max(); // 1.7976931348623157e+308
const double MIN_DOUBLE __attribute__((unused)) = -std::numeric_limits<double>::max();
const uint64_t AUTOINCR_SATURATED __attribute__((unused)) = std::numeric_limits<uint64_t>::max();
} // namespace

View File

@ -134,13 +134,12 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
DictOID() : dictOID(0), listOID(0), treeOID(0), compressionType(0)
{
}
DictOID(OID dictOID_, OID listOID_, OID treeOID_, int compressionType_) :
dictOID(dictOID_), listOID(listOID_), treeOID(treeOID_),
compressionType(compressionType_)
DictOID(OID dictOID_, OID listOID_, OID treeOID_, int compressionType_)
: dictOID(dictOID_), listOID(listOID_), treeOID(treeOID_), compressionType(compressionType_)
{
}
DictOID(const DictOID& rhs)
: dictOID(rhs.dictOID), listOID(rhs.listOID), treeOID(rhs.treeOID), compressionType(rhs.compressionType)
: dictOID(rhs.dictOID), listOID(rhs.listOID), treeOID(rhs.treeOID), compressionType(rhs.compressionType)
{
}
OID dictOID;
@ -213,7 +212,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
*
* defaultValue is only meaningful when constraintType == DEFAULT_CONSTRAINT
*/
struct ColType : public datatypes::SystemCatalog::TypeHolderStd
struct ColType : public datatypes::TypeHolderStd
{
ConstraintType constraintType = NO_CONSTRAINT;
DictOID ddn;
@ -232,9 +231,9 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
public:
ColType() = default;
ColType(const ColType& rhs);
ColType(int32_t colWidth_, int32_t scale_, int32_t precision_,
const ConstraintType& constraintType_, const DictOID& ddn_, int32_t colPosition_,
int32_t compressionType_, OID columnOID_, const ColDataType& colDataType_);
ColType(int32_t colWidth_, int32_t scale_, int32_t precision_, const ConstraintType& constraintType_,
const DictOID& ddn_, int32_t colPosition_, int32_t compressionType_, OID columnOID_,
const ColDataType& colDataType_);
ColType& operator=(const ColType& rhs);
CHARSET_INFO* getCharset();
@ -1270,8 +1269,8 @@ const int OID_SYSCOLUMN_MINVALUE = SYSCOLUMN_BASE + 19; /** @brief min va
const int OID_SYSCOLUMN_MAXVALUE = SYSCOLUMN_BASE + 20; /** @brief max value col */
const int OID_SYSCOLUMN_COMPRESSIONTYPE = SYSCOLUMN_BASE + 21; /** @brief compression type */
const int OID_SYSCOLUMN_NEXTVALUE = SYSCOLUMN_BASE + 22; /** @brief next value */
const int OID_SYSCOLUMN_CHARSETNUM = SYSCOLUMN_BASE + 23; /** @brief character set number for the column */
const int SYSCOLUMN_MAX = SYSCOLUMN_BASE + 24; // be sure this is one more than the highest #
const int OID_SYSCOLUMN_CHARSETNUM = SYSCOLUMN_BASE + 23; /** @brief character set number for the column */
const int SYSCOLUMN_MAX = SYSCOLUMN_BASE + 24; // be sure this is one more than the highest #
/*****************************************************
* SYSTABLE columns dictionary OID definition

View File

@ -49,7 +49,6 @@ using namespace rowgroup;
#include "messageids.h"
using namespace logging;
namespace primitiveprocessor
{
extern int noVB;
@ -177,7 +176,7 @@ void ColumnCommand::_loadData()
{
// fill remaining blocks with empty values when col scan
uint32_t blockLen = BLOCK_SIZE / W;
auto attrs = datatypes::SystemCatalog::TypeAttributesStd(W, 0, -1);
auto attrs = datatypes::TypeAttributesStd(W, 0, -1);
const auto* typeHandler = datatypes::TypeHandler::find(colType.colDataType, attrs);
const uint8_t* emptyValue = typeHandler->getEmptyValueForType(attrs);
uint8_t* blockDataPtr = &bpp->blockData[i * BLOCK_SIZE];
@ -206,9 +205,9 @@ void ColumnCommand::_loadData()
uint8_t** blockPtrsAux = (uint8_t**)alloca(1 * sizeof(uint8_t*));
blockPtrsAux[0] = &bpp->blockDataAux[0];
lbidsAux[0] = lbidAux;
wasCached = primitiveprocessor::loadBlocks(lbidsAux, bpp->versionInfo, bpp->txnID, 2,
blockPtrsAux, &blocksRead, bpp->LBIDTrace, bpp->sessionID,
1, &wasVersioned, true, &bpp->vssCache);
wasCached = primitiveprocessor::loadBlocks(lbidsAux, bpp->versionInfo, bpp->txnID, 2, blockPtrsAux,
&blocksRead, bpp->LBIDTrace, bpp->sessionID, 1, &wasVersioned,
true, &bpp->vssCache);
bpp->cachedIO += wasCached;
bpp->physIO += blocksRead;
bpp->touchedBlocks += 1;
@ -631,8 +630,7 @@ void ColumnCommand::fillInPrimitiveMessageHeader(const int8_t outputType, const
size_t inputMsgBufSize = baseMsgLength + (LOGICAL_BLOCK_RIDS * sizeof(primitives::RIDType));
if (!inputMsg)
inputMsg.reset(new(std::align_val_t(utils::MAXCOLUMNWIDTH)) uint8_t[inputMsgBufSize]);
inputMsg.reset(new (std::align_val_t(utils::MAXCOLUMNWIDTH)) uint8_t[inputMsgBufSize]);
primMsg = (NewColRequestHeader*)inputMsg.get();
outMsg = (ColResultHeader*)bpp->outputMsg.get();

View File

@ -151,7 +151,7 @@ TEST(DataConvertTest, Strtoll128)
TEST(DataConvertTest, NumberIntValue)
{
datatypes::SystemCatalog::TypeAttributesStd ct;
datatypes::TypeAttributesStd ct;
int128_t res, valMax;
string data;

View File

@ -98,9 +98,8 @@ int64_t getSInt64LE(const char* ptr)
}
template <typename T>
void number_int_value(const string& data, cscDataType typeCode,
const datatypes::SystemCatalog::TypeAttributesStd& ct, bool& pushwarning,
bool noRoundup, T& intVal, bool* saturate)
void number_int_value(const string& data, cscDataType typeCode, const datatypes::TypeAttributesStd& ct,
bool& pushwarning, bool noRoundup, T& intVal, bool* saturate)
{
// copy of the original input
string valStr(data);
@ -487,16 +486,15 @@ void number_int_value(const string& data, cscDataType typeCode,
// Explicit template instantiation
template void number_int_value<int64_t>(const std::string& data, cscDataType typeCode,
const datatypes::SystemCatalog::TypeAttributesStd& ct,
bool& pushwarning, bool noRoundup, int64_t& intVal, bool* saturate);
const datatypes::TypeAttributesStd& ct, bool& pushwarning,
bool noRoundup, int64_t& intVal, bool* saturate);
template void number_int_value<int128_t>(const std::string& data, cscDataType typeCode,
const datatypes::SystemCatalog::TypeAttributesStd& ct,
bool& pushwarning, bool noRoundup, int128_t& intVal, bool* saturate);
const datatypes::TypeAttributesStd& ct, bool& pushwarning,
bool noRoundup, int128_t& intVal, bool* saturate);
uint64_t number_uint_value(const string& data, cscDataType typeCode,
const datatypes::SystemCatalog::TypeAttributesStd& ct, bool& pushwarning,
bool noRoundup)
uint64_t number_uint_value(const string& data, cscDataType typeCode, const datatypes::TypeAttributesStd& ct,
bool& pushwarning, bool noRoundup)
{
// copy of the original input
string valStr(data);
@ -1214,7 +1212,7 @@ bool stringToTimestampStruct(const string& data, TimeStamp& timeStamp, long time
return true;
}
boost::any DataConvert::StringToBit(const datatypes::SystemCatalog::TypeAttributesStd& colType,
boost::any DataConvert::StringToBit(const datatypes::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm, const std::string& dataOrig,
bool& pushWarning)
{
@ -1254,7 +1252,7 @@ boost::any DataConvert::StringToBit(const datatypes::SystemCatalog::TypeAttribut
return boost::any();
}
boost::any DataConvert::StringToSDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
boost::any DataConvert::StringToSDecimal(const datatypes::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm,
const std::string& data, bool& pushWarning)
{
@ -1299,7 +1297,7 @@ boost::any DataConvert::StringToSDecimal(const datatypes::SystemCatalog::TypeAtt
return boost::any();
}
boost::any DataConvert::StringToUDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
boost::any DataConvert::StringToUDecimal(const datatypes::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm,
const std::string& data, bool& pushWarning)
{
@ -1490,7 +1488,7 @@ boost::any DataConvert::StringToDouble(cscDataType typeCode, const std::string&
return value;
}
boost::any DataConvert::StringToString(const datatypes::SystemCatalog::TypeAttributesStd& colType,
boost::any DataConvert::StringToString(const datatypes::TypeAttributesStd& colType,
const std::string& dataOrig, bool& pushWarning)
{
@ -1546,8 +1544,8 @@ boost::any DataConvert::StringToDatetime(const std::string& data, bool& pushWarn
return value;
}
boost::any DataConvert::StringToTime(const datatypes::SystemCatalog::TypeAttributesStd& colType,
const std::string& data, bool& pushWarning)
boost::any DataConvert::StringToTime(const datatypes::TypeAttributesStd& colType, const std::string& data,
bool& pushWarning)
{
Time aTime;
@ -2907,8 +2905,8 @@ int64_t DataConvert::stringToTime(const string& data)
return getSInt64LE((const char*)&atime);
}
void DataConvert::joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& unionedType,
const datatypes::SystemCatalog::TypeHolderStd& type, unsigned int& rc)
void DataConvert::joinColTypeForUnion(datatypes::TypeHolderStd& unionedType,
const datatypes::TypeHolderStd& type, unsigned int& rc)
{
// limited support for VARBINARY, no implicit conversion.
if (type.colDataType == datatypes::SystemCatalog::VARBINARY ||

View File

@ -104,7 +104,6 @@ const int64_t IDB_pow[19] = {1,
100000000000000000LL,
1000000000000000000LL};
const int32_t SECS_PER_MIN = 60;
const int32_t MINS_PER_HOUR = 60;
const int32_t HOURS_PER_DAY = 24;
@ -1085,13 +1084,11 @@ inline uint64_t string_to_ull(const std::string& data, bool& bSaturate)
}
template <typename T>
void number_int_value(const std::string& data, cscDataType typeCode,
const datatypes::SystemCatalog::TypeAttributesStd& ct, bool& pushwarning,
bool noRoundup, T& intVal, bool* saturate = 0);
void number_int_value(const std::string& data, cscDataType typeCode, const datatypes::TypeAttributesStd& ct,
bool& pushwarning, bool noRoundup, T& intVal, bool* saturate = 0);
uint64_t number_uint_value(const string& data, cscDataType typeCode,
const datatypes::SystemCatalog::TypeAttributesStd& ct, bool& pushwarning,
bool noRoundup);
uint64_t number_uint_value(const string& data, cscDataType typeCode, const datatypes::TypeAttributesStd& ct,
bool& pushwarning, bool noRoundup);
/** @brief DataConvert is a component for converting string data to Calpont format
*/
@ -1266,19 +1263,18 @@ class DataConvert
EXPORT static int64_t stringToTime(const std::string& data);
EXPORT static int64_t stringToTime(const utils::NullString& data);
// bug4388, union type conversion
EXPORT static void joinColTypeForUnion(datatypes::SystemCatalog::TypeHolderStd& unionedType,
const datatypes::SystemCatalog::TypeHolderStd& type,
unsigned int& rc);
EXPORT static void joinColTypeForUnion(datatypes::TypeHolderStd& unionedType,
const datatypes::TypeHolderStd& type, unsigned int& rc);
static boost::any StringToBit(const datatypes::SystemCatalog::TypeAttributesStd& colType,
static boost::any StringToBit(const datatypes::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm, const std::string& dataOrig,
bool& pushWarning);
static boost::any StringToSDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
static boost::any StringToSDecimal(const datatypes::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm, const std::string& data,
bool& pushWarning);
static boost::any StringToUDecimal(const datatypes::SystemCatalog::TypeAttributesStd& colType,
static boost::any StringToUDecimal(const datatypes::TypeAttributesStd& colType,
const datatypes::ConvertFromStringParam& prm, const std::string& data,
bool& pushWarning);
@ -1286,15 +1282,15 @@ class DataConvert
static boost::any StringToDouble(cscDataType typeCode, const std::string& dataOrig, bool& pushWarning);
static boost::any StringToString(const datatypes::SystemCatalog::TypeAttributesStd& colType,
const std::string& dataOrig, bool& pushWarning);
static boost::any StringToString(const datatypes::TypeAttributesStd& colType, const std::string& dataOrig,
bool& pushWarning);
static boost::any StringToDate(const std::string& data, bool& pushWarning);
static boost::any StringToDatetime(const std::string& data, bool& pushWarning);
static boost::any StringToTime(const datatypes::SystemCatalog::TypeAttributesStd& colType,
const std::string& data, bool& pushWarning);
static boost::any StringToTime(const datatypes::TypeAttributesStd& colType, const std::string& data,
bool& pushWarning);
static boost::any StringToTimestamp(const datatypes::ConvertFromStringParam& prm, const std::string& data,
bool& pushWarning);
@ -1554,7 +1550,6 @@ inline int128_t strtoll128(const char* data, bool& saturate, char** ep)
return res;
}
template <class T>
T decimalRangeUp(int32_t precision)
{

View File

@ -57,7 +57,7 @@
#include "rowstorage.h"
//..comment out NDEBUG to enable assertions, uncomment NDEBUG to disable
//#define NDEBUG
// #define NDEBUG
#include "mcs_decimal.h"
using namespace std;
@ -315,7 +315,7 @@ void RowAggregation::updateStringMinMax(utils::NullString val1, utils::NullStrin
if (val1.isNull())
{
// as any comparison with NULL is false, it should not affect min/max ranges.
return ; // do nothing.
return; // do nothing.
}
CHARSET_INFO* cs = fRow.getCharset(col);
int tmp = cs->strnncoll(val1.str(), val1.length(), val2.str(), val2.length());
@ -816,8 +816,9 @@ void RowAggregation::aggregateRow(Row& row, const uint64_t* hash,
std::vector<mcsv1sdk::mcsv1Context>* rgContextColl)
{
uint32_t cnt = fRollupFlag ? fGroupByCols.size() : 1;
for (uint32_t z = 0; z < cnt; z++) {
// groupby column list is not empty, find the entry.
for (uint32_t z = 0; z < cnt; z++)
{
// groupby column list is not empty, find the entry.
if (!fGroupByCols.empty())
{
bool is_new_row;
@ -862,7 +863,8 @@ void RowAggregation::aggregateRow(Row& row, const uint64_t* hash,
updateEntry(row, rgContextColl);
// these quantities are unsigned and comparing z and cnt - 1 can be incorrect
// because cnt can be zero.
if ((z + 1 < cnt)) {
if ((z + 1 < cnt))
{
// if we are rolling up, we mark appropriate field as NULL and also increment
// value in the "mark" column, so that we can differentiate between data and
// various rollups.
@ -1175,8 +1177,8 @@ void RowAggregation::doMinMax(const Row& rowIn, int64_t colIn, int64_t colOut, i
{
if (LIKELY(rowIn.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH))
{
updateIntMinMax(rowIn.getTSInt128Field(colIn).getValue(), fRow.getTSInt128Field(colOut).getValue(), colOut,
funcType);
updateIntMinMax(rowIn.getTSInt128Field(colIn).getValue(), fRow.getTSInt128Field(colOut).getValue(),
colOut, funcType);
}
else if (rowIn.getColumnWidth(colIn) <= datatypes::MAXLEGACYWIDTH)
{
@ -2013,10 +2015,9 @@ void RowAggregation::doStatistics(const Row& rowIn, int64_t colIn, int64_t colOu
long double mean = fRow.getLongDoubleField(colAux);
long double scaledMomentum2 = fRow.getLongDoubleField(colAux + 1);
volatile long double delta = valIn - mean;
mean += delta/count;
mean += delta / count;
scaledMomentum2 += delta * (valIn - mean);
fRow.setDoubleField(count, colOut);
fRow.setLongDoubleField(mean, colAux);
fRow.setLongDoubleField(scaledMomentum2, colAux + 1);
@ -2066,8 +2067,7 @@ void RowAggregation::doUDAF(const Row& rowIn, int64_t colIn, int64_t colOut, int
cc = dynamic_cast<execplan::ConstantColumn*>(fFunctionCols[funcColsIdx]->fpConstCol.get());
}
if ((cc && cc->isNull()) ||
(!cc && isNull(&fRowGroupIn, rowIn, colIn) == true))
if ((cc && cc->isNull()) || (!cc && isNull(&fRowGroupIn, rowIn, colIn) == true))
{
if (udafContextsColl[origFuncColsIdx].getRunFlag(mcsv1sdk::UDAF_IGNORE_NULLS))
{
@ -2393,7 +2393,8 @@ void RowAggregation::loadEmptySet(messageqcpp::ByteStream& bs)
//------------------------------------------------------------------------------
RowAggregationUM::RowAggregationUM(const vector<SP_ROWAGG_GRPBY_t>& rowAggGroupByCols,
const vector<SP_ROWAGG_FUNC_t>& rowAggFunctionCols,
joblist::ResourceManager* r, boost::shared_ptr<int64_t> sessionLimit, bool withRollup)
joblist::ResourceManager* r, boost::shared_ptr<int64_t> sessionLimit,
bool withRollup)
: RowAggregation(rowAggGroupByCols, rowAggFunctionCols, r, sessionLimit, withRollup)
, fHasAvg(false)
, fHasStatsFunc(false)
@ -3115,7 +3116,7 @@ void RowAggregationUM::SetUDAFAnyValue(static_any::any& valOut, int64_t colOut)
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT: fRow.setStringField(strOut, colOut); break;
case execplan::CalpontSystemCatalog::TEXT: fRow.setStringField(strOut, colOut); break;
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::CLOB:
@ -3585,7 +3586,7 @@ void RowAggregationUM::doNotNullConstantAggregate(const ConstantAggData& aggData
auto width = fRow.getColumnWidth(colOut);
if (width == datatypes::MAXDECIMALWIDTH)
{
execplan::CalpontSystemCatalog::TypeHolderStd colType;
datatypes::TypeHolderStd colType;
colType.colWidth = width;
colType.precision = fRow.getPrecision(i);
colType.scale = fRow.getScale(i);
@ -3707,7 +3708,7 @@ void RowAggregationUM::doNotNullConstantAggregate(const ConstantAggData& aggData
auto width = fRow.getColumnWidth(colOut);
if (width == datatypes::MAXDECIMALWIDTH)
{
execplan::CalpontSystemCatalog::TypeHolderStd colType;
datatypes::TypeHolderStd colType;
colType.colWidth = width;
colType.precision = fRow.getPrecision(i);
colType.scale = fRow.getScale(i);
@ -4110,7 +4111,8 @@ bool RowAggregationUM::nextRowGroup()
//------------------------------------------------------------------------------
RowAggregationUMP2::RowAggregationUMP2(const vector<SP_ROWAGG_GRPBY_t>& rowAggGroupByCols,
const vector<SP_ROWAGG_FUNC_t>& rowAggFunctionCols,
joblist::ResourceManager* r, boost::shared_ptr<int64_t> sessionLimit, bool withRollup)
joblist::ResourceManager* r, boost::shared_ptr<int64_t> sessionLimit,
bool withRollup)
: RowAggregationUM(rowAggGroupByCols, rowAggFunctionCols, r, sessionLimit, withRollup)
{
}
@ -4328,7 +4330,8 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
{
if (LIKELY(cnt > 0))
{
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
;
int128_t sum = valOut + wideValue;
fRow.setInt128Field(sum, colOut);
fRow.setUintField(rowIn.getUintField(colAuxIn) + cnt, colAux);
@ -4387,7 +4390,8 @@ void RowAggregationUMP2::doStatistics(const Row& rowIn, int64_t colIn, int64_t c
{
volatile long double delta = mean - blockMean;
nextMean = (mean * count + blockMean * blockCount) / nextCount;
nextScaledMomentum2 = scaledMomentum2 + blockScaledMomentum2 + delta * delta * (count * blockCount / nextCount);
nextScaledMomentum2 =
scaledMomentum2 + blockScaledMomentum2 + delta * delta * (count * blockCount / nextCount);
}
fRow.setDoubleField(nextCount, colOut);
fRow.setLongDoubleField(nextMean, colAux);

View File

@ -47,7 +47,6 @@ using namespace std;
using namespace boost;
using namespace execplan;
namespace
{
const std::string INPUT_ERROR_WRONG_NO_COLUMNS = "Data contains wrong number of columns";
@ -79,13 +78,13 @@ inline void resizeRowDataArray(char** pRowData, unsigned int dataLength, unsigne
{
char* tmpRaw = new char[newArrayCapacity];
memcpy(tmpRaw, *pRowData, dataLength);
delete[] * pRowData;
delete[] *pRowData;
*pRowData = tmpRaw;
}
} // namespace
//#define DEBUG_TOKEN_PARSING 1
// #define DEBUG_TOKEN_PARSING 1
namespace WriteEngine
{
@ -516,7 +515,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength, bool nullFlag, unsign
if (column.cs->mbmaxlen > 1)
{
const CHARSET_INFO* cs = column.cs;
const char* start = (const char*) field;
const char* start = (const char*)field;
const char* end = (const char*)(field + fieldLength);
size_t numChars = cs->numchars(start, end);
size_t maxCharLength = column.definedWidth / cs->mbmaxlen;
@ -529,7 +528,7 @@ void BulkLoadBuffer::convert(char* field, int fieldLength, bool nullFlag, unsign
bufStats.satCount++;
}
}
else // cs->mbmaxlen == 1
else // cs->mbmaxlen == 1
{
if (fieldLength > column.definedWidth)
{
@ -1193,8 +1192,8 @@ void BulkLoadBuffer::convert(char* field, int fieldLength, bool nullFlag, unsign
// number_int_value(), and the bSatVal flag is set to true
dataconvert::number_int_value(
string(field), column.dataType,
datatypes::SystemCatalog::TypeAttributesStd(column.width, column.scale, column.precision),
dummy, false, bigllVal, &bSatVal);
datatypes::TypeAttributesStd(column.width, column.scale, column.precision), dummy, false,
bigllVal, &bSatVal);
}
}

View File

@ -86,7 +86,7 @@ bool BlockOp::calculateRowId(RID rowId, const int epb, const int width, int& fbo
const uint8_t* BlockOp::getEmptyRowValue(const CalpontSystemCatalog::ColDataType colDataType,
const int width) const
{
auto attrs = datatypes::SystemCatalog::TypeAttributesStd(width, 0, -1);
auto attrs = datatypes::TypeAttributesStd(width, 0, -1);
// Bulk operation runtime should have m_typeHandler nullptr calling this
// Non-bulk operations runtime branch
if (m_typeHandler)
@ -224,7 +224,7 @@ void BlockOp::findTypeHandler(const int colWidth,
const execplan::CalpontSystemCatalog::ColDataType colDataType)
{
auto attrs = datatypes::SystemCatalog::TypeAttributesStd(colWidth, 0, -1);
auto attrs = datatypes::TypeAttributesStd(colWidth, 0, -1);
m_typeHandler = datatypes::TypeHandler::find(colDataType, attrs);
}

View File

@ -36,7 +36,7 @@ using namespace std;
#include <boost/lexical_cast.hpp>
using namespace boost;
//#include "we_simplesyslog.h"
// #include "we_simplesyslog.h"
#include "we_sdhandler.h"
#include "brm.h"
@ -331,8 +331,7 @@ bool WEBrmUpdater::prepareCasualPartitionInfo()
if (datatypes::isWideDecimalType(cpInfoMerge.type, cpInfoMerge.colWidth))
{
datatypes::SystemCatalog::TypeAttributesStd tyAttr(cpInfoMerge.colWidth, 0,
datatypes::INT128MAXPRECISION);
datatypes::TypeAttributesStd tyAttr(cpInfoMerge.colWidth, 0, datatypes::INT128MAXPRECISION);
pTok = strtok(NULL, " ");
@ -479,7 +478,7 @@ bool WEBrmUpdater::prepareHighWaterMarkInfo()
}
//------------------------------------------------------------------------------
//#ROWS: numRowsRead numRowsInserted
// #ROWS: numRowsRead numRowsInserted
bool WEBrmUpdater::prepareRowsInsertedInfo(std::string Entry, int64_t& TotRows, int64_t& InsRows)
{
@ -527,7 +526,7 @@ bool WEBrmUpdater::prepareRowsInsertedInfo(std::string Entry, int64_t& TotRows,
}
//------------------------------------------------------------------------------
//#DATA: columnNumber columnType columnName numOutOfRangeValues
// #DATA: columnNumber columnType columnName numOutOfRangeValues
bool WEBrmUpdater::prepareColumnOutOfRangeInfo(std::string Entry, int& ColNum,
execplan::CalpontSystemCatalog::ColDataType& ColType,
@ -609,7 +608,7 @@ bool WEBrmUpdater::prepareColumnOutOfRangeInfo(std::string Entry, int& ColNum,
}
//------------------------------------------------------------------------------
//#ERR: error message file
// #ERR: error message file
bool WEBrmUpdater::prepareErrorFileInfo(std::string Entry, std::string& ErrFileName)
{
@ -650,7 +649,7 @@ bool WEBrmUpdater::prepareErrorFileInfo(std::string Entry, std::string& ErrFileN
}
//------------------------------------------------------------------------------
//#BAD: bad data file, with rejected rows
// #BAD: bad data file, with rejected rows
bool WEBrmUpdater::prepareBadDataFileInfo(std::string Entry, std::string& BadFileName)
{