1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-07 03:22:57 +03:00

Bugfixes from develop (#2095)

* MaxConcurrentTransactions were not cleared when config is wrong (#2093)

* Wrong concatenation in between predicate (#2092)

* We forgot to initilize longdoublenull value (#2091)

* WriteBatchFieldMariaDB m_type was wrong (#2090)

* moda returned local object pointer (#2089)

* Wrong power of 2 in esimator` (#2088)

* targetDbroot should be assined, not compared (#2087)

* obviously wrong bytesTx assignment (#2086)

* GetInterrupted returned bool instead of bool * (#2085)
This commit is contained in:
Leonid Fedorov
2021-08-19 18:02:09 +03:00
committed by GitHub
parent e79c9ef1a3
commit ea622eec93
9 changed files with 72 additions and 120 deletions

View File

@@ -1211,7 +1211,7 @@ string BetweenPredicate::getPredicateString() const
between_predicate += fRH1ScalarExpression; between_predicate += fRH1ScalarExpression;
between_predicate += " "; between_predicate += " ";
between_predicate += fOperator2; between_predicate += fOperator2;
between_predicate + " "; between_predicate += " ";
between_predicate += fRH2ScalarExpression; between_predicate += fRH2ScalarExpression;
return between_predicate; return between_predicate;

View File

@@ -159,16 +159,16 @@ uint32_t RowEstimator::estimateDistinctValues(const execplan::CalpontSystemCatal
// Return limit/2 for integers where limit is number of possible values. // Return limit/2 for integers where limit is number of possible values.
case CalpontSystemCatalog::TINYINT: case CalpontSystemCatalog::TINYINT:
return (2 ^ 8) / 2; return (1 << 8) / 2;
case CalpontSystemCatalog::UTINYINT: case CalpontSystemCatalog::UTINYINT:
return (2 ^ 8); return (1 << 8);
case CalpontSystemCatalog::SMALLINT: case CalpontSystemCatalog::SMALLINT:
return (2 ^ 16) / 2; return (1 << 16) / 2;
case CalpontSystemCatalog::USMALLINT: case CalpontSystemCatalog::USMALLINT:
return (2 ^ 16); return (1 << 16);
// Next group all have range greater than 8M (# of rows in an extent), use 8M/2 as the estimate. // Next group all have range greater than 8M (# of rows in an extent), use 8M/2 as the estimate.
case CalpontSystemCatalog::MEDINT: case CalpontSystemCatalog::MEDINT:

View File

@@ -206,7 +206,7 @@ public:
const CalpontSystemCatalog::ColType & m_type; const CalpontSystemCatalog::ColType & m_type;
uint32_t m_mbmaxlen; uint32_t m_mbmaxlen;
WriteBatchFieldMariaDB(Field *field, WriteBatchFieldMariaDB(Field *field,
const CalpontSystemCatalog::ColType type, const CalpontSystemCatalog::ColType & type,
uint32_t mbmaxlen) uint32_t mbmaxlen)
:m_field(field), m_type(type), m_mbmaxlen(mbmaxlen) :m_field(field), m_type(type), m_mbmaxlen(mbmaxlen)
{ } { }

View File

@@ -61,7 +61,7 @@ void Func::init()
double* dp = reinterpret_cast<double*>(&dni); double* dp = reinterpret_cast<double*>(&dni);
fDoubleNullVal = *dp; fDoubleNullVal = *dp;
fDoubleNullVal = joblist::LONGDOUBLENULL; fLongDoubleNullVal = joblist::LONGDOUBLENULL;
} }

View File

@@ -3,7 +3,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <string.h> #include <string.h>
#include <tr1/unordered_map> #include <unordered_map>
#include <algorithm> #include <algorithm>
#include "idb_mysql.h" #include "idb_mysql.h"
@@ -32,9 +32,10 @@ struct moda_data
long double fSum; long double fSum;
uint64_t fCount; uint64_t fCount;
enum Item_result fReturnType; enum Item_result fReturnType;
std::tr1::unordered_map<int64_t, uint32_t> mapINT; std::unordered_map<int64_t, uint32_t> mapINT;
std::tr1::unordered_map<double, uint32_t> mapREAL; std::unordered_map<double, uint32_t> mapREAL;
std::tr1::unordered_map<long double, uint32_t> mapDECIMAL; std::unordered_map<long double, uint32_t> mapDECIMAL;
std::string result;
void clear() void clear()
{ {
fSum = 0.0; fSum = 0.0;
@@ -44,9 +45,39 @@ struct moda_data
mapDECIMAL.clear(); mapDECIMAL.clear();
} }
}; };
} }
template<class TYPE, class CONTAINER>
char * moda(CONTAINER & container, struct moda_data* data)
{
TYPE avg = (TYPE)data->fCount ? data->fSum / data->fCount : 0;
TYPE val = 0.0;
uint32_t maxCnt = 0.0;
for (auto iter = container.begin(); iter != container.end(); ++iter)
{
if (iter->second > maxCnt)
{
val = iter->first;
maxCnt = iter->second;
}
else if (iter->second == maxCnt)
{
// Tie breaker: choose the closest to avg. If still tie, choose smallest
if ((abs(val-avg) > abs(iter->first-avg))
|| ((abs(val-avg) == abs(iter->first-avg)) && (abs(val) > abs(iter->first))))
{
val = iter->first;
}
}
}
data->result = std::to_string(val);
return const_cast<char*>(data->result.c_str());
}
extern "C" extern "C"
{ {
@@ -188,101 +219,22 @@ void moda_remove(UDF_INIT* initid, UDF_ARGS* args,
#ifdef _MSC_VER #ifdef _MSC_VER
__declspec(dllexport) __declspec(dllexport)
#endif #endif
char* moda(UDF_INIT* initid, UDF_ARGS* args __attribute__((unused)), char* moda(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error __attribute__((unused)))
char* is_null, char* error __attribute__((unused)))
{ {
struct moda_data* data = (struct moda_data*)initid->ptr; struct moda_data* data = (struct moda_data*)initid->ptr;
uint32_t maxCnt = 0.0;
switch (args->arg_type[0]) switch (args->arg_type[0])
{ {
case INT_RESULT: case INT_RESULT:
{ return moda<int64_t>(data->mapINT, data);
typename std::tr1::unordered_map<int64_t, uint32_t>::iterator iter;
int64_t avg = (int64_t)data->fCount ? data->fSum / data->fCount : 0;
int64_t val = 0.0;
for (iter = data->mapINT.begin(); iter != data->mapINT.end(); ++iter)
{
if (iter->second > maxCnt)
{
val = iter->first;
maxCnt = iter->second;
}
else if (iter->second == maxCnt)
{
// Tie breaker: choose the closest to avg. If still tie, choose smallest
if ((abs(val-avg) > abs(iter->first-avg))
|| ((abs(val-avg) == abs(iter->first-avg)) && (abs(val) > abs(iter->first))))
{
val = iter->first;
}
}
}
std::ostringstream oss;
oss << val;
return const_cast<char*>(oss.str().c_str());
break;
}
case REAL_RESULT: case REAL_RESULT:
{ return moda<double>(data->mapREAL, data);
typename std::tr1::unordered_map<double, uint32_t>::iterator iter;
double avg = data->fCount ? data->fSum / data->fCount : 0;
double val = 0.0;
for (iter = data->mapREAL.begin(); iter != data->mapREAL.end(); ++iter)
{
if (iter->second > maxCnt)
{
val = iter->first;
maxCnt = iter->second;
}
else if (iter->second == maxCnt)
{
// Tie breaker: choose the closest to avg. If still tie, choose smallest
if ((abs(val-avg) > abs(iter->first-avg))
|| ((abs(val-avg) == abs(iter->first-avg)) && (abs(val) > abs(iter->first))))
{
val = iter->first;
}
}
}
std::ostringstream oss;
oss << val;
return const_cast<char*>(oss.str().c_str());
break;
}
case DECIMAL_RESULT: case DECIMAL_RESULT:
case STRING_RESULT: case STRING_RESULT:
{ return moda<long double>(data->mapDECIMAL, data);
typename std::tr1::unordered_map<long double, uint32_t>::iterator iter;
long double avg = data->fCount ? data->fSum / data->fCount : 0;
long double val = 0.0;
for (iter = data->mapDECIMAL.begin(); iter != data->mapDECIMAL.end(); ++iter)
{
if (iter->second > maxCnt)
{
val = iter->first;
maxCnt = iter->second;
}
else if (iter->second == maxCnt)
{
long double thisVal = iter->first;
// Tie breaker: choose the closest to avg. If still tie, choose smallest
if ((abs(val-avg) > abs(thisVal-avg))
|| ((abs(val-avg) == abs(thisVal-avg)) && (abs(val) > abs(thisVal))))
{
val = thisVal;
}
}
}
std::ostringstream oss;
oss << val;
return const_cast<char*>(oss.str().c_str());
break;
}
default: default:
break;
}
return NULL; return NULL;
} }
return NULL;
}
} // Extern "C" } // Extern "C"

View File

@@ -74,7 +74,7 @@ public:
{ {
return bInterrupted; return bInterrupted;
} }
bool getInterruptedPtr() bool * getInterruptedPtr()
{ {
return &bInterrupted; return &bInterrupted;
} }

View File

@@ -100,7 +100,7 @@ SessionManagerServer::SessionManagerServer() : unique32(0), unique64(0)
catch (const std::exception& e) catch (const std::exception& e)
{ {
cout << e.what() << endl; cout << e.what() << endl;
stmp.empty(); stmp.clear();
} }
if (stmp != "") if (stmp != "")

View File

@@ -460,7 +460,7 @@ int RedistributeControlThread::makeRedistributePlan()
{ {
if (targetDbroot == targetDbroots.end()) if (targetDbroot == targetDbroots.end())
{ {
targetDbroot == targetDbroots.begin(); targetDbroot = targetDbroots.begin();
} }
if (dbPartVec[*targetDbroot].size() < partCount) if (dbPartVec[*targetDbroot].size() < partCount)

View File

@@ -213,7 +213,7 @@ public:
void setBytesTx(uint32_t BytesTx) void setBytesTx(uint32_t BytesTx)
{ {
boost::mutex::scoped_lock aLock(fTxMutex); boost::mutex::scoped_lock aLock(fTxMutex);
BytesTx = BytesTx; fBytesTx = BytesTx;
aLock.unlock(); aLock.unlock();
} }
void updateBytesTx(uint32_t fBytes) void updateBytesTx(uint32_t fBytes)