1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-24 14:20:59 +03:00

MCOL-4174 Review/refactor frontend/connector code

This commit is contained in:
Alexander Barkov
2020-10-20 15:35:36 +04:00
committed by Roman Nozdrin
parent 68244ab957
commit 129d5b5a0f
70 changed files with 6982 additions and 4927 deletions

View File

@@ -34,7 +34,6 @@
#include "we_log.h"
#include "cacheutils.h"
#include "IDBPolicy.h"
#include "widedecimalutils.h"
#include "mcs_decimal.h"
#include "dataconvert.h"
@@ -301,7 +300,7 @@ void BRMReporter::sendCPToFile( )
{
if (fCPInfo.size() > 0)
{
char buf[utils::MAXLENGTH16BYTES];
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
std::ostringstream oss;
oss << "Writing " << fCPInfo.size() << " CP updates for table " <<
fTableName << " to report file " << fRptFileName;
@@ -309,7 +308,7 @@ void BRMReporter::sendCPToFile( )
for (unsigned int i = 0; i < fCPInfo.size(); i++)
{
if (!datatypes::Decimal::isWideDecimalType(fCPInfo[i].type, fCPInfo[i].colWidth))
if (!datatypes::isWideDecimalType(fCPInfo[i].type, fCPInfo[i].colWidth))
{
fRptFile << "CP: " << fCPInfo[i].startLbid << ' ' <<
fCPInfo[i].max << ' ' <<
@@ -322,10 +321,10 @@ void BRMReporter::sendCPToFile( )
{
std::string bigMin, bigMax;
dataconvert::DataConvert::decimalToString(&fCPInfo[i].bigMin, 0, buf, utils::MAXLENGTH16BYTES, fCPInfo[i].type);
dataconvert::DataConvert::decimalToString(&fCPInfo[i].bigMin, 0, buf, (uint8_t) sizeof(buf), fCPInfo[i].type);
bigMin = buf;
dataconvert::DataConvert::decimalToString(&fCPInfo[i].bigMax, 0, buf, utils::MAXLENGTH16BYTES, fCPInfo[i].type);
dataconvert::DataConvert::decimalToString(&fCPInfo[i].bigMax, 0, buf, (uint8_t) sizeof(buf), fCPInfo[i].type);
bigMax = buf;
fRptFile << "CP: " << fCPInfo[i].startLbid << ' ' <<

View File

@@ -40,7 +40,6 @@
#include "dataconvert.h"
#include "exceptclasses.h"
#include "mcs_decimal.h"
#include "widedecimalutils.h"
#include "joblisttypes.h"

View File

@@ -31,7 +31,6 @@
#include "we_columninfo.h"
#include "calpontsystemcatalog.h"
#include "dataconvert.h"
#include "widedecimalutils.h"
namespace WriteEngine
{

View File

@@ -27,7 +27,6 @@
#include "we_colextinf.h"
#include "dataconvert.h"
#include "widedecimalutils.h"
#include <iostream>
#include <sstream>

View File

@@ -41,7 +41,6 @@
#include "brmtypes.h"
#include "we_type.h"
#include "dataconvert.h"
#include "widedecimalutils.h"
namespace WriteEngine
{

View File

@@ -15,7 +15,8 @@ set(WriteEngineServer_SRCS
we_cleartablelockcmd.cpp
we_cpifeederthread.cpp
we_getfilesizes.cpp
../../utils/common/crashtrace.cpp)
../../utils/common/crashtrace.cpp
../../datatypes/mcs_datatype.cpp)
add_executable(WriteEngineServer ${WriteEngineServer_SRCS})

View File

@@ -213,12 +213,12 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string& err)
else if (INIT_COL == column.tableColName.column)
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
else if (NEXT_COL == column.tableColName.column)
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
else if (AUTOINC_COL == column.tableColName.column)
{
@@ -226,7 +226,7 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string& err)
}
else
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
colStruct.dataOid = column.oid;
@@ -588,7 +588,7 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
else
{
tmpStr = "";
//colTuple.data = getNullValueForType(column.colType);
//colTuple.data = column.colType.getNullValueForType();
}
}
@@ -629,16 +629,16 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
}
else
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
}
else if (LISTOBJID_COL == column.tableColName.column)
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
else if (TREEOBJID_COL == column.tableColName.column)
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
else if (MINVAL_COL == column.tableColName.column)
{
@@ -664,7 +664,7 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
}
else
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
colStruct.dataOid = column.oid;
@@ -982,7 +982,7 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
else
{
tmpStr = "";
//colTuple.data = getNullValueForType(column.colType);
//colTuple.data = column.colType.getNullValueForType();
}
}
@@ -1023,16 +1023,16 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
}
else
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
}
else if (LISTOBJID_COL == column.tableColName.column)
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
else if (TREEOBJID_COL == column.tableColName.column)
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
else if (MINVAL_COL == column.tableColName.column)
{
@@ -1058,7 +1058,7 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
}
else
{
colTuple.data = getNullValueForType(column.colType);
colTuple.data = column.colType.getNullValueForType();
}
colStruct.dataOid = column.oid;
@@ -3646,7 +3646,7 @@ uint8_t WE_DDLCommandProc::fillNewColumn(ByteStream& bs, std::string& err)
colType.scale = scale;
colType.precision = precision;
bool pushWarning = false;
defaultVal.data = DataConvert::convertColumnData(colType, defaultValStr, pushWarning, timeZone, isNULL, false, false);
defaultVal.data = colType.convertColumnData(defaultValStr, pushWarning, timeZone, isNULL, false, false);
fWEWrapper.setTransId(txnID);
fWEWrapper.setIsInsert(true);
fWEWrapper.setBulkFlag(true);

View File

@@ -143,239 +143,6 @@ inline void getColumnsForTable(uint32_t sessionID, std::string schema, std::str
}
inline boost::any getNullValueForType(const execplan::CalpontSystemCatalog::ColType& colType)
{
boost::any value;
switch (colType.colDataType)
{
case execplan::CalpontSystemCatalog::BIT:
break;
case execplan::CalpontSystemCatalog::TINYINT:
{
char tinyintvalue = joblist::TINYINTNULL;
value = tinyintvalue;
}
break;
case execplan::CalpontSystemCatalog::UTINYINT:
{
uint8_t tinyintvalue = joblist::UTINYINTNULL;
value = tinyintvalue;
}
break;
case execplan::CalpontSystemCatalog::SMALLINT:
{
short smallintvalue = joblist::SMALLINTNULL;
value = smallintvalue;
}
break;
case execplan::CalpontSystemCatalog::USMALLINT:
{
uint16_t smallintvalue = joblist::USMALLINTNULL;
value = smallintvalue;
}
break;
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::INT:
{
int intvalue = joblist::INTNULL;
value = intvalue;
}
break;
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UINT:
{
uint32_t intvalue = joblist::UINTNULL;
value = intvalue;
}
break;
case execplan::CalpontSystemCatalog::BIGINT:
{
long long bigint = joblist::BIGINTNULL;
value = bigint;
}
break;
case execplan::CalpontSystemCatalog::UBIGINT:
{
uint64_t bigint = joblist::UBIGINTNULL;
value = bigint;
}
break;
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
{
short smallintvalue = joblist::SMALLINTNULL;
value = smallintvalue;
}
else if (colType.colWidth <= 9)
{
int intvalue = joblist::INTNULL;
value = intvalue;
}
else if (colType.colWidth <= 18)
{
long long eightbyte = joblist::BIGINTNULL;
value = eightbyte;
}
else
{
WriteEngine::Token nullToken;
value = nullToken;
}
}
break;
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
{
uint32_t jlfloatnull = joblist::FLOATNULL;
float* fp = reinterpret_cast<float*>(&jlfloatnull);
value = *fp;
}
break;
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
{
uint64_t jldoublenull = joblist::DOUBLENULL;
double* dp = reinterpret_cast<double*>(&jldoublenull);
value = *dp;
}
break;
case execplan::CalpontSystemCatalog::DATE:
{
int d = joblist::DATENULL;
value = d;
}
break;
case execplan::CalpontSystemCatalog::DATETIME:
{
long long d = joblist::DATETIMENULL;
value = d;
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
long long d = joblist::TIMENULL;
value = d;
}
break;
case execplan::CalpontSystemCatalog::TIMESTAMP:
{
long long d = joblist::TIMESTAMPNULL;
value = d;
}
break;
case execplan::CalpontSystemCatalog::CHAR:
{
std::string charnull;
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
{
//charnull = joblist::CHAR1NULL;
charnull = "\376";
value = charnull;
}
else if (colType.colWidth == execplan::CalpontSystemCatalog::TWO_BYTE)
{
//charnull = joblist::CHAR2NULL;
charnull = "\377\376";
value = charnull;
}
else if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
{
//charnull = joblist::CHAR4NULL;
charnull = "\377\377\377\376";
value = charnull;
}
else
{
WriteEngine::Token nullToken;
value = nullToken;
}
}
break;
case execplan::CalpontSystemCatalog::VARCHAR:
{
std::string charnull;
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
{
//charnull = joblist::CHAR2NULL;
charnull = "\377\376";
value = charnull;
}
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
{
//charnull = joblist::CHAR4NULL;
charnull = "\377\377\377\376";
value = charnull;
}
else
{
WriteEngine::Token nullToken;
value = nullToken;
}
}
break;
case execplan::CalpontSystemCatalog::BLOB:
case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::VARBINARY:
{
std::string charnull;
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
{
//charnull = joblist::CHAR2NULL;
charnull = "\377\376";
value = charnull;
}
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
{
//charnull = joblist::CHAR4NULL;
charnull = "\377\377\377\376";
value = charnull;
}
else
{
WriteEngine::Token nullToken;
value = nullToken;
}
}
break;
default:
throw std::runtime_error("getNullValueForType: unkown column data type");
break;
}
return value;
}
inline int convertDataType(int dataType)
{

View File

@@ -370,7 +370,7 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std:
try
{
datavalue = DataConvert::convertColumnData(colType, indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
datavalue = colType.convertColumnData(indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
}
catch (exception&)
{
@@ -1245,7 +1245,7 @@ uint8_t WE_DMLCommandProc::processBatchInsert(messageqcpp::ByteStream& bs, std::
try
{
datavalue = DataConvert::convertColumnData(colType, indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
datavalue = colType.convertColumnData(indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
}
catch (exception&)
{
@@ -2996,12 +2996,12 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
if (fetchColColwidths[fetchColPos] == datatypes::MAXDECIMALWIDTH)
{
int128_t* dec;
char buf[utils::MAXLENGTH16BYTES];
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
dec = row.getBinaryField<int128_t>(fetchColPos);
dataconvert::DataConvert::decimalToString(dec,
(unsigned)fetchColScales[fetchColPos], buf,
sizeof(buf), fetchColTypes[fetchColPos]);
(uint8_t) sizeof(buf), fetchColTypes[fetchColPos]);
value.assign(buf);
@@ -3362,12 +3362,12 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
{
// WIP MCOL-641
int128_t* dec;
char buf[utils::MAXLENGTH16BYTES];
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
dec = row.getBinaryField<int128_t>(fetchColPos);
dataconvert::DataConvert::decimalToString(dec,
(unsigned)fetchColScales[fetchColPos], buf,
sizeof(buf), fetchColTypes[fetchColPos]);
(uint8_t) sizeof(buf), fetchColTypes[fetchColPos]);
value = buf;
@@ -3527,7 +3527,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
try
{
datavalue = DataConvert::convertColumnData(colType, colType.defaultValue, pushWarn, timeZone, isNull, false, false);
datavalue = colType.convertColumnData(colType.defaultValue, pushWarn, timeZone, isNull, false, false);
}
catch (exception&)
{
@@ -3559,7 +3559,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
{
try
{
datavalue = DataConvert::convertColumnData(colType, value, pushWarn, timeZone, isNull, false, false);
datavalue = colType.convertColumnData(value, pushWarn, timeZone, isNull, false, false);
}
catch (exception&)
{
@@ -3656,7 +3656,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
try
{
datavalue = DataConvert::convertColumnData(colType, inData, pushWarn, timeZone, isNull, false, false);
datavalue = colType.convertColumnData(inData, pushWarn, timeZone, isNull, false, false);
}
catch (exception&)
{
@@ -3702,7 +3702,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
{
try
{
datavalue = DataConvert::convertColumnData(colType, colType.defaultValue, pushWarn, timeZone, isNull, false, false);
datavalue = colType.convertColumnData(colType.defaultValue, pushWarn, timeZone, isNull, false, false);
}
catch (exception&)
{
@@ -3735,7 +3735,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
{
try
{
datavalue = DataConvert::convertColumnData(colType, inData, pushWarn, timeZone, isNull, false, true);
datavalue = colType.convertColumnData(inData, pushWarn, timeZone, isNull, false, true);
}
catch (exception& ex)
{

View File

@@ -40,7 +40,6 @@ using namespace std;
using namespace execplan;
#include "dataconvert.h"
#include "widedecimalutils.h"
#include "IDBDataFile.h"
#include "IDBPolicy.h"

View File

@@ -58,7 +58,6 @@ using namespace execplan;
#include "MonitorProcMem.h"
using namespace idbdatafile;
#include "dataconvert.h"
#include "widedecimalutils.h"
#ifdef _MSC_VER
#define isnan _isnan
@@ -3898,9 +3897,9 @@ void WriteEngineWrapper::printInputValue(const ColStructList& colStructList,
else if (curTuple.data.type() == typeid(int128_t))
{
// WIP replace with a single call
char buf[utils::MAXLENGTH16BYTES];
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
int128_t val = boost::any_cast<int128_t>(curTuple.data);
dataconvert::DataConvert::decimalToString(&val, 0, buf, utils::MAXLENGTH16BYTES, curColStruct.colDataType);
dataconvert::DataConvert::decimalToString(&val, 0, buf, (uint8_t) sizeof(buf), curColStruct.colDataType);
curStr.assign(buf);
}
else if (curTuple.data.type() == typeid(double))