You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-4957 Fix performance slowdown for processing TIMESTAMP columns.
Part 1: As part of MCOL-3776 to address synchronization issue while accessing the fTimeZone member of the Func class, mutex locks were added to the accessor and mutator methods. However, this slows down processing of TIMESTAMP columns in PrimProc significantly as all threads across all concurrently running queries would serialize on the mutex. This is because PrimProc only has a single global object for the functor class (class derived from Func in utils/funcexp/functor.h) for a given function name. To fix this problem: (1) We remove the fTimeZone as a member of the Func derived classes (hence removing the mutexes) and instead use the fOperationType member of the FunctionColumn class to propagate the timezone values down to the individual functor processing functions such as FunctionColumn::getStrVal(), FunctionColumn::getIntVal(), etc. (2) To achieve (1), a timezone member is added to the execplan::CalpontSystemCatalog::ColType class. Part 2: Several functors in the Funcexp code call dataconvert::gmtSecToMySQLTime() and dataconvert::mySQLTimeToGmtSec() functions for conversion between seconds since unix epoch and broken-down representation. These functions in turn call the C library function localtime_r() which currently has a known bug of holding a global lock via a call to __tz_convert. This significantly reduces performance in multi-threaded applications where multiple threads concurrently call localtime_r(). More details on the bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16145 This bug in localtime_r() caused processing of the Functors in PrimProc to slowdown significantly since a query execution causes Functors code to be processed in a multi-threaded manner. As a fix, we remove the calls to localtime_r() from gmtSecToMySQLTime() and mySQLTimeToGmtSec() by performing the timezone-to-offset conversion (done in dataconvert::timeZoneToOffset()) during the execution plan creation in the plugin. Note that localtime_r() is only called when the time_zone system variable is set to "SYSTEM". This fix also required changing the timezone type from a std::string to a long across the system.
This commit is contained in:
@ -183,7 +183,8 @@ void AggregateColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
(*rcit)->serialize(b);
|
||||
|
||||
b << fData;
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
// b << fAlias;
|
||||
b << fTableAlias;
|
||||
b << static_cast<ByteStream::doublebyte>(fAsc);
|
||||
@ -236,7 +237,9 @@ void AggregateColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
}
|
||||
|
||||
b >> fData;
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
// b >> fAlias;
|
||||
b >> fTableAlias;
|
||||
b >> reinterpret_cast<ByteStream::doublebyte&>(fAsc);
|
||||
|
@ -313,12 +313,12 @@ class AggregateColumn : public ReturnedColumn
|
||||
return false;
|
||||
}
|
||||
|
||||
inline const std::string timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -346,7 +346,7 @@ class AggregateColumn : public ReturnedColumn
|
||||
ColumnList fGroupByColList;
|
||||
ColumnList fProjectColList;
|
||||
SRCP fConstCol;
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
|
||||
public:
|
||||
/***********************************************************
|
||||
|
@ -72,7 +72,8 @@ ostream& operator<<(ostream& output, const ArithmeticOperator& rhs)
|
||||
void ArithmeticOperator::serialize(messageqcpp::ByteStream& b) const
|
||||
{
|
||||
b << (ObjectReader::id_t)ObjectReader::ARITHMETICOPERATOR;
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
const messageqcpp::ByteStream::byte tmp = fDecimalOverflowCheck;
|
||||
b << tmp;
|
||||
Operator::serialize(b);
|
||||
@ -81,7 +82,9 @@ void ArithmeticOperator::serialize(messageqcpp::ByteStream& b) const
|
||||
void ArithmeticOperator::unserialize(messageqcpp::ByteStream& b)
|
||||
{
|
||||
ObjectReader::checkType(b, ObjectReader::ARITHMETICOPERATOR);
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
messageqcpp::ByteStream::byte tmp;
|
||||
b >> tmp;
|
||||
fDecimalOverflowCheck = tmp;
|
||||
|
@ -59,11 +59,11 @@ class ArithmeticOperator : public Operator
|
||||
return new ArithmeticOperator(*this);
|
||||
}
|
||||
|
||||
inline const std::string& timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -207,7 +207,7 @@ class ArithmeticOperator : public Operator
|
||||
template <typename result_t>
|
||||
inline result_t execute(result_t op1, result_t op2, bool& isNull);
|
||||
inline void execute(IDB_Decimal& result, IDB_Decimal op1, IDB_Decimal op2, bool& isNull);
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
bool fDecimalOverflowCheck;
|
||||
};
|
||||
|
||||
|
@ -500,7 +500,8 @@ void CalpontSelectExecutionPlan::serialize(messageqcpp::ByteStream& b) const
|
||||
b << fDJSPartitionSize;
|
||||
b << fUMMemLimit;
|
||||
b << (uint8_t)fIsDML;
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
}
|
||||
|
||||
void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
@ -695,7 +696,9 @@ void CalpontSelectExecutionPlan::unserialize(messageqcpp::ByteStream& b)
|
||||
b >> fUMMemLimit;
|
||||
b >> tmp8;
|
||||
fIsDML = tmp8;
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
|
||||
bool CalpontSelectExecutionPlan::operator==(const CalpontSelectExecutionPlan& t) const
|
||||
|
@ -706,11 +706,11 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
|
||||
return fIsDML;
|
||||
}
|
||||
|
||||
void timeZone(const std::string& timezone)
|
||||
void timeZone(const long timezone)
|
||||
{
|
||||
fTimeZone = timezone;
|
||||
}
|
||||
const std::string timeZone() const
|
||||
long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
@ -923,7 +923,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
|
||||
int64_t fUMMemLimit;
|
||||
bool fIsDML;
|
||||
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
|
||||
std::vector<execplan::ParseTree*> fDynamicParseTreeVec;
|
||||
};
|
||||
|
@ -6105,8 +6105,8 @@ const string CalpontSystemCatalog::ColType::toString() const
|
||||
}
|
||||
|
||||
boost::any CalpontSystemCatalog::ColType::convertColumnData(const std::string& data, bool& pushWarning,
|
||||
const std::string& timeZone, bool nulFlag,
|
||||
bool noRoundup, bool isUpdate) const
|
||||
long timeZone, bool nulFlag, bool noRoundup,
|
||||
bool isUpdate) const
|
||||
{
|
||||
pushWarning = false;
|
||||
const datatypes::TypeHandler* h = typeHandler();
|
||||
|
@ -205,7 +205,6 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
||||
*/
|
||||
struct ColType : public datatypes::SystemCatalog::TypeHolderStd
|
||||
{
|
||||
ColType();
|
||||
ConstraintType constraintType;
|
||||
DictOID ddn;
|
||||
std::string defaultValue;
|
||||
@ -216,11 +215,25 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
||||
uint64_t nextvalue; // next autoincrement value
|
||||
uint32_t charsetNumber;
|
||||
const CHARSET_INFO* cs;
|
||||
private:
|
||||
long timeZone;
|
||||
|
||||
public:
|
||||
ColType();
|
||||
ColType(const ColType& rhs);
|
||||
ColType& operator=(const ColType& rhs);
|
||||
|
||||
CHARSET_INFO* getCharset();
|
||||
|
||||
long getTimeZone() const
|
||||
{
|
||||
return timeZone;
|
||||
}
|
||||
void setTimeZone(long timeZone_)
|
||||
{
|
||||
timeZone = timeZone_;
|
||||
}
|
||||
|
||||
// for F&E use. only serialize necessary info for now
|
||||
void serialize(messageqcpp::ByteStream& b) const
|
||||
{
|
||||
@ -254,7 +267,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog
|
||||
* @param nRoundtrip
|
||||
* @param isUpdate
|
||||
*/
|
||||
boost::any convertColumnData(const std::string& data, bool& bSaturate, const std::string& timeZone,
|
||||
boost::any convertColumnData(const std::string& data, bool& bSaturate, long timeZone,
|
||||
bool nulFlag = false, bool noRoundup = false, bool isUpdate = false) const;
|
||||
|
||||
const std::string toString() const;
|
||||
|
@ -254,7 +254,8 @@ void ConstantColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
b << (uint32_t)fType;
|
||||
// b << fAlias;
|
||||
b << fData;
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
b << static_cast<ByteStream::doublebyte>(fReturnAll);
|
||||
b << (uint64_t)fResult.intVal;
|
||||
b << fResult.uintVal;
|
||||
@ -278,7 +279,9 @@ void ConstantColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
b >> fConstval;
|
||||
b >> (uint32_t&)fType;
|
||||
b >> fData;
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
b >> reinterpret_cast<ByteStream::doublebyte&>(fReturnAll);
|
||||
b >> (uint64_t&)fResult.intVal;
|
||||
b >> fResult.uintVal;
|
||||
|
@ -113,14 +113,14 @@ class ConstantColumn : public ReturnedColumn
|
||||
/**
|
||||
* accessor
|
||||
*/
|
||||
inline const std::string& timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
/**
|
||||
* mutator
|
||||
*/
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -204,7 +204,7 @@ class ConstantColumn : public ReturnedColumn
|
||||
std::string fConstval;
|
||||
int fType;
|
||||
std::string fData;
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
|
||||
/***********************************************************
|
||||
* F&E framework *
|
||||
|
@ -272,7 +272,8 @@ void FunctionColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
|
||||
b << fTableAlias;
|
||||
b << fData;
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
}
|
||||
|
||||
void FunctionColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
@ -303,10 +304,11 @@ void FunctionColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
|
||||
b >> fTableAlias;
|
||||
b >> fData;
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
FuncExp* funcExp = FuncExp::instance();
|
||||
fFunctor = funcExp->getFunctor(fFunctionName);
|
||||
fFunctor->timeZone(fTimeZone);
|
||||
fFunctor->fix(*this);
|
||||
|
||||
// @bug 3506. Special treatment for rand() function. reset the seed
|
||||
|
@ -121,12 +121,12 @@ class FunctionColumn : public ReturnedColumn
|
||||
fTableAlias = tableAlias;
|
||||
}
|
||||
|
||||
inline const std::string timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -181,7 +181,7 @@ class FunctionColumn : public ReturnedColumn
|
||||
std::string fFunctionName; /// function name
|
||||
std::string fTableAlias; /// table alias which has the column
|
||||
std::string fData; /// SQL representation
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
@ -217,31 +217,38 @@ class FunctionColumn : public ReturnedColumn
|
||||
public:
|
||||
virtual const std::string& getStrVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
fResult.strVal = fFunctor->getStrVal(row, fFunctionParms, isNull, fOperationType);
|
||||
return fResult.strVal;
|
||||
}
|
||||
virtual int64_t getIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getIntVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual uint64_t getUintVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getUintVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual float getFloatVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getFloatVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual double getDoubleVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getDoubleVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual long double getLongDoubleVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getLongDoubleVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual IDB_Decimal getDecimalVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
IDB_Decimal decimal = fFunctor->getDecimalVal(row, fFunctionParms, isNull, fOperationType);
|
||||
|
||||
if (UNLIKELY(fResultType.colWidth == utils::MAXLEGACYWIDTH && fResultType.scale == decimal.scale))
|
||||
@ -276,10 +283,9 @@ class FunctionColumn : public ReturnedColumn
|
||||
if (fResultType.scale > decimal.scale)
|
||||
decimal.value *= IDB_pow[fResultType.scale - decimal.scale];
|
||||
else
|
||||
decimal.value =
|
||||
(int64_t)(decimal.value > 0
|
||||
? (double)decimal.value / IDB_pow[decimal.scale - fResultType.scale] + 0.5
|
||||
: (double)decimal.value / IDB_pow[decimal.scale - fResultType.scale] - 0.5);
|
||||
decimal.value = (int64_t)(
|
||||
decimal.value > 0 ? (double)decimal.value / IDB_pow[decimal.scale - fResultType.scale] + 0.5
|
||||
: (double)decimal.value / IDB_pow[decimal.scale - fResultType.scale] - 0.5);
|
||||
}
|
||||
|
||||
decimal.scale = fResultType.scale;
|
||||
@ -288,22 +294,27 @@ class FunctionColumn : public ReturnedColumn
|
||||
}
|
||||
virtual bool getBoolVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getBoolVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual int32_t getDateIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getDateIntVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual int64_t getDatetimeIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getDatetimeIntVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual int64_t getTimestampIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getTimestampIntVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
virtual int64_t getTimeIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
fOperationType.setTimeZone(fTimeZone);
|
||||
return fFunctor->getTimeIntVal(row, fFunctionParms, isNull, fOperationType);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,8 @@ void MCSAnalyzeTableExecutionPlan::serialize(messageqcpp::ByteStream& bs) const
|
||||
bs << fSchemaName;
|
||||
bs << fTableName;
|
||||
bs << fLocalQuery;
|
||||
bs << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
bs << timeZone;
|
||||
bs << fTraceFlags;
|
||||
}
|
||||
|
||||
@ -149,7 +150,9 @@ void MCSAnalyzeTableExecutionPlan::unserialize(messageqcpp::ByteStream& bs)
|
||||
bs >> fSchemaName;
|
||||
bs >> fTableName;
|
||||
bs >> fLocalQuery;
|
||||
bs >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
bs >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
bs >> fTraceFlags;
|
||||
}
|
||||
} // namespace execplan
|
||||
|
@ -169,12 +169,12 @@ class MCSAnalyzeTableExecutionPlan : public CalpontExecutionPlan
|
||||
return fUuid;
|
||||
}
|
||||
|
||||
void timeZone(const std::string& timezone)
|
||||
void timeZone(long timezone)
|
||||
{
|
||||
fTimeZone = timezone;
|
||||
}
|
||||
|
||||
const std::string timeZone() const
|
||||
long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
@ -256,7 +256,7 @@ class MCSAnalyzeTableExecutionPlan : public CalpontExecutionPlan
|
||||
std::string fTableName;
|
||||
uint32_t fTraceFlags;
|
||||
boost::uuids::uuid fUuid;
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
uint32_t fStatementID;
|
||||
uint64_t fStringScanThreshold;
|
||||
std::string fData;
|
||||
|
@ -345,7 +345,8 @@ void SimpleColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
b << fColumnName;
|
||||
b << fIndexName;
|
||||
b << fViewName;
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
b << (uint32_t)fOid;
|
||||
b << fData;
|
||||
b << fTableAlias;
|
||||
@ -362,7 +363,9 @@ void SimpleColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
b >> fColumnName;
|
||||
b >> fIndexName;
|
||||
b >> fViewName;
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
b >> (uint32_t&)fOid;
|
||||
b >> fData;
|
||||
b >> fTableAlias;
|
||||
|
@ -151,11 +151,11 @@ class SimpleColumn : public ReturnedColumn
|
||||
if (lower_case_table_names)
|
||||
boost::algorithm::to_lower(fViewName);
|
||||
}
|
||||
inline const std::string& timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -259,7 +259,7 @@ class SimpleColumn : public ReturnedColumn
|
||||
std::string fIndexName;
|
||||
// if belong to view, view name is non-empty
|
||||
std::string fViewName;
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
bool fisColumnStore;
|
||||
|
||||
/** @brief parse SimpleColumn text
|
||||
@ -349,7 +349,7 @@ class SimpleColumn : public ReturnedColumn
|
||||
inline int64_t getDatetimeIntVal(rowgroup::Row& row, bool& isNull)
|
||||
{
|
||||
evaluate(row, isNull);
|
||||
return TreeNode::getDatetimeIntVal();
|
||||
return TreeNode::getDatetimeIntVal(fTimeZone);
|
||||
}
|
||||
|
||||
inline int64_t getTimestampIntVal(rowgroup::Row& row, bool& isNull)
|
||||
|
@ -55,7 +55,7 @@ SimpleFilter::SimpleFilter(const string& sql) : Filter(sql)
|
||||
parse(sql);
|
||||
}
|
||||
|
||||
SimpleFilter::SimpleFilter(const SOP& op, ReturnedColumn* lhs, ReturnedColumn* rhs, const string& timeZone)
|
||||
SimpleFilter::SimpleFilter(const SOP& op, ReturnedColumn* lhs, ReturnedColumn* rhs, const long timeZone)
|
||||
: fOp(op), fLhs(lhs), fRhs(rhs), fIndexFlag(NOINDEX), fJoinFlag(EQUA), fTimeZone(timeZone)
|
||||
{
|
||||
convertConstant();
|
||||
@ -314,7 +314,8 @@ void SimpleFilter::serialize(messageqcpp::ByteStream& b) const
|
||||
|
||||
b << static_cast<uint32_t>(fIndexFlag);
|
||||
b << static_cast<uint32_t>(fJoinFlag);
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
}
|
||||
|
||||
void SimpleFilter::unserialize(messageqcpp::ByteStream& b)
|
||||
@ -330,7 +331,9 @@ void SimpleFilter::unserialize(messageqcpp::ByteStream& b)
|
||||
fRhs = dynamic_cast<ReturnedColumn*>(ObjectReader::createTreeNode(b));
|
||||
b >> reinterpret_cast<uint32_t&>(fIndexFlag);
|
||||
b >> reinterpret_cast<uint32_t&>(fJoinFlag);
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
|
||||
fSimpleColumnList.clear();
|
||||
fAggColumnList.clear();
|
||||
|
@ -67,7 +67,7 @@ class SimpleFilter : public Filter
|
||||
|
||||
SimpleFilter();
|
||||
SimpleFilter(const std::string& sql);
|
||||
SimpleFilter(const SOP& op, ReturnedColumn* lhs, ReturnedColumn* rhs, const std::string& timeZone = "");
|
||||
SimpleFilter(const SOP& op, ReturnedColumn* lhs, ReturnedColumn* rhs, const long timeZone = 0);
|
||||
SimpleFilter(const SimpleFilter& rhs);
|
||||
|
||||
virtual ~SimpleFilter();
|
||||
@ -92,12 +92,12 @@ class SimpleFilter : public Filter
|
||||
return fLhs;
|
||||
}
|
||||
|
||||
inline const std::string& timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -220,7 +220,7 @@ class SimpleFilter : public Filter
|
||||
ReturnedColumn* fRhs; /// right operand
|
||||
int fIndexFlag; /// which side col is index
|
||||
int fJoinFlag; /// hash join type
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
|
||||
void parse(std::string);
|
||||
|
||||
|
@ -325,7 +325,7 @@ class TreeNode
|
||||
}
|
||||
|
||||
inline bool getBoolVal();
|
||||
inline const std::string& getStrVal(const std::string& timeZone);
|
||||
inline const std::string& getStrVal(const long timeZone);
|
||||
inline int64_t getIntVal();
|
||||
inline uint64_t getUintVal();
|
||||
inline float getFloatVal();
|
||||
@ -333,7 +333,7 @@ class TreeNode
|
||||
inline long double getLongDoubleVal();
|
||||
inline IDB_Decimal getDecimalVal();
|
||||
inline int32_t getDateIntVal();
|
||||
inline int64_t getDatetimeIntVal();
|
||||
inline int64_t getDatetimeIntVal(long timeZone = 0);
|
||||
inline int64_t getTimestampIntVal();
|
||||
inline int64_t getTimeIntVal();
|
||||
|
||||
@ -457,7 +457,7 @@ inline bool TreeNode::getBoolVal()
|
||||
return fResult.boolVal;
|
||||
}
|
||||
|
||||
inline const std::string& TreeNode::getStrVal(const std::string& timeZone)
|
||||
inline const std::string& TreeNode::getStrVal(const long timeZone)
|
||||
{
|
||||
switch (fResultType.colDataType)
|
||||
{
|
||||
@ -1052,7 +1052,7 @@ inline IDB_Decimal TreeNode::getDecimalVal()
|
||||
return fResult.decimalVal;
|
||||
}
|
||||
|
||||
inline int64_t TreeNode::getDatetimeIntVal()
|
||||
inline int64_t TreeNode::getDatetimeIntVal(long timeZone)
|
||||
{
|
||||
if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATE)
|
||||
return (fResult.intVal & 0x00000000FFFFFFC0LL) << 32;
|
||||
@ -1083,6 +1083,17 @@ inline int64_t TreeNode::getDatetimeIntVal()
|
||||
else if (fResultType.colDataType == execplan::CalpontSystemCatalog::DATETIME)
|
||||
// return (fResult.intVal & 0xFFFFFFFFFFF00000LL);
|
||||
return (fResult.intVal);
|
||||
else if (fResultType.colDataType == execplan::CalpontSystemCatalog::TIMESTAMP)
|
||||
{
|
||||
dataconvert::TimeStamp timestamp(fResult.intVal);
|
||||
int64_t seconds = timestamp.second;
|
||||
dataconvert::MySQLTime m_time;
|
||||
dataconvert::gmtSecToMySQLTime(seconds, m_time, timeZone);
|
||||
dataconvert::DateTime dt(m_time.year, m_time.month, m_time.day, m_time.hour, m_time.minute, m_time.second,
|
||||
timestamp.msecond);
|
||||
memcpy(&fResult.intVal, &dt, 8);
|
||||
return fResult.intVal;
|
||||
}
|
||||
else
|
||||
return getIntVal();
|
||||
}
|
||||
|
@ -288,7 +288,8 @@ void WindowFunctionColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
|
||||
fOrderBy.serialize(b);
|
||||
udafContext.serialize(b);
|
||||
b << fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone = fTimeZone;
|
||||
b << timeZone;
|
||||
}
|
||||
|
||||
void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
@ -320,7 +321,9 @@ void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
|
||||
fOrderBy.unserialize(b);
|
||||
udafContext.unserialize(b);
|
||||
b >> fTimeZone;
|
||||
messageqcpp::ByteStream::octbyte timeZone;
|
||||
b >> timeZone;
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
|
||||
void WindowFunctionColumn::addToPartition(vector<SRCP>& groupByList)
|
||||
|
@ -146,12 +146,12 @@ class WindowFunctionColumn : public ReturnedColumn
|
||||
return udafContext;
|
||||
}
|
||||
|
||||
inline const std::string timeZone() const
|
||||
inline long timeZone() const
|
||||
{
|
||||
return fTimeZone;
|
||||
}
|
||||
|
||||
inline void timeZone(const std::string& timeZone)
|
||||
inline void timeZone(const long timeZone)
|
||||
{
|
||||
fTimeZone = timeZone;
|
||||
}
|
||||
@ -180,7 +180,7 @@ class WindowFunctionColumn : public ReturnedColumn
|
||||
// UDAnF support
|
||||
mcsv1sdk::mcsv1Context udafContext;
|
||||
|
||||
std::string fTimeZone;
|
||||
long fTimeZone;
|
||||
/***********************************************************
|
||||
* F&E framework *
|
||||
***********************************************************/
|
||||
|
Reference in New Issue
Block a user