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

MCOL-641 Simple INSERT with one record works with this commit.

This commit is contained in:
Roman Nozdrin
2020-01-09 13:22:56 +00:00
parent df65543dd4
commit 63dcaa387f
5 changed files with 144 additions and 11 deletions

View File

@@ -1627,9 +1627,9 @@ inline void p_Col_bin_ridArray(NewColRequestHeader* in,
rfs[argIndex] = args->rf; rfs[argIndex] = args->rf;
memcpy(argVals[argIndex],args->val, W); memcpy(argVals[argIndex],args->val, W);
regex[argIndex].used = false;
} }
regex[argIndex].used = false;
} }

View File

@@ -1161,11 +1161,73 @@ bool stringToTimestampStruct(const string& data, TimeStamp& timeStamp, const str
} }
// WIP
#include <stdio.h>
using int128_t = __int128;
using uint128_t = unsigned __int128;
struct uint128_pod
{
uint64_t lo;
uint64_t hi;
};
inline void toString(uint128_t i, char *p)
{
uint64_t div = 10000000000000000000ULL;
size_t div_log = 19;
uint128_t high = i;
uint128_t low;
low = high % div;
high /= div;
uint128_t mid;
mid = high % div;
high /= div;
uint128_pod *high_pod = reinterpret_cast<uint128_pod*>(&high);
uint128_pod *mid_pod = reinterpret_cast<uint128_pod*>(&mid);
uint128_pod *low_pod = reinterpret_cast<uint128_pod*>(&low);
int printed_chars = 0;
// WIP replace snprintf with streams
if (high_pod->lo != 0) {
printed_chars = snprintf(p, div_log+1, "%ld", high_pod->lo);
p += printed_chars;
printed_chars = snprintf(p, div_log+1, "%019lu", mid_pod->lo);
p += printed_chars;
} else if (mid_pod->lo != 0) {
printed_chars = snprintf(p, div_log+1, "%lu", mid_pod->lo);
p += printed_chars;
}
snprintf(p, div_log+1, "%019ld", low_pod->lo);
}
// Template this
// result must be calloc-ed
void atoi_(const string &arg, int128_t &res, size_t &size)
{
// WIP
//char buf[40];
//int128_t *res_ptr = reinterpret_cast<int128_t*>(result);
res = 0;
for (int j = 0; j < arg.size(); j++)
{
// WIP
res = res*10 + arg[j] - '0';
}
//toString(res, buf);
//std::cerr << "atoi_ " << buf <<endl;
//*res_ptr = res;
size = 16;
}
boost::any boost::any
DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType, DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
const std::string& dataOrig, bool& pushWarning, const std::string& timeZone, bool nulFlag, bool noRoundup, bool isUpdate) const std::string& dataOrig, bool& pushWarning, const std::string& timeZone, bool nulFlag, bool noRoundup, bool isUpdate)
{ {
boost::any value; boost::any value;
// WIP
std::string data( dataOrig ); std::string data( dataOrig );
pushWarning = false; pushWarning = false;
CalpontSystemCatalog::ColDataType type = colType.colDataType; CalpontSystemCatalog::ColDataType type = colType.colDataType;
@@ -1225,10 +1287,15 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
break; break;
// MCOL-641 WIP // MCOL-641 WIP
// use string2BCD conversion here + set sign
case CalpontSystemCatalog::DECIMAL: case CalpontSystemCatalog::DECIMAL:
if (colType.colWidth == 16) if (colType.colWidth == 16)
value = data; {
//value = data;
size_t size;
int128_t bigint;
atoi_(data, bigint, size);
value = bigint;
}
else if (colType.colWidth == 1) else if (colType.colWidth == 1)
value = (char) number_int_value(data, colType, pushWarning, noRoundup); value = (char) number_int_value(data, colType, pushWarning, noRoundup);
else if (colType.colWidth == 2) else if (colType.colWidth == 2)

View File

@@ -638,6 +638,7 @@ void Convertor::convertColType(ColStruct* curStruct)
break; break;
default: default:
// WIP replace with BINARY
*internalType = WriteEngine::WR_INT128; *internalType = WriteEngine::WR_INT128;
break; break;
} }
@@ -772,8 +773,10 @@ int Convertor::getCorrectRowWidth(CalpontSystemCatalog::ColDataType dataType, in
newWidth = 2; newWidth = 2;
else if (width <= 4) else if (width <= 4)
newWidth = 4; newWidth = 4;
else else if (width <= 8)
newWidth = 8; newWidth = 8;
else
newWidth = 16;
break; break;

View File

@@ -1561,6 +1561,10 @@ void ColumnOp::setColParam(Column& column,
column.compressionType = compressionType; column.compressionType = compressionType;
} }
// WIP
using int128_t = __int128;
using uint128_t = unsigned __int128;
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
@@ -1680,10 +1684,12 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray,
if (!bDelete) pVal = &((uint64_t*) valArray)[i]; if (!bDelete) pVal = &((uint64_t*) valArray)[i];
break; break;
case WriteEngine::WR_BINARY:
case WriteEngine::WR_INT128: case WriteEngine::WR_INT128:
pVal = &((uint128_t*) valArray)[i];
break;
case WriteEngine::WR_BINARY:
if (!bDelete) pVal = (uint8_t*) valArray + i * curCol.colWidth; if (!bDelete) pVal = (uint8_t*) valArray + i * curCol.colWidth;
break; break;
default : default :

View File

@@ -218,6 +218,50 @@ void WriteEngineWrapper::findSmallestColumn(uint32_t& colId, ColStructList colSt
} }
} }
// MCOL-641 WIP
using int128_t = __int128;
using uint128_t = unsigned __int128;
struct uint128_pod
{
uint64_t lo;
uint64_t hi;
};
inline void toString(uint128_t i, char *p)
{
uint64_t div = 10000000000000000000ULL;
size_t div_log = 19;
uint128_t high = i;
uint128_t low;
low = high % div;
high /= div;
uint128_t mid;
mid = high % div;
high /= div;
uint128_pod *high_pod = reinterpret_cast<uint128_pod*>(&high);
uint128_pod *mid_pod = reinterpret_cast<uint128_pod*>(&mid);
uint128_pod *low_pod = reinterpret_cast<uint128_pod*>(&low);
int printed_chars = 0;
// WIP replace snprintf with streams
if (high_pod->lo != 0) {
printed_chars = snprintf(p, div_log+1, "%ld", high_pod->lo);
p += printed_chars;
printed_chars = snprintf(p, div_log+1, "%019lu", mid_pod->lo);
p += printed_chars;
} else if (mid_pod->lo != 0) {
printed_chars = snprintf(p, div_log+1, "%lu", mid_pod->lo);
p += printed_chars;
}
snprintf(p, div_log+1, "%019ld", low_pod->lo);
}
/*@convertValArray - Convert interface values to internal values /*@convertValArray - Convert interface values to internal values
*/ */
/*********************************************************** /***********************************************************
@@ -389,8 +433,14 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* value, boost:
} }
break; break;
case WriteEngine::WR_BINARY:
case WriteEngine::WR_INT128: case WriteEngine::WR_INT128:
{
int128_t val = boost::any_cast<int128_t>(data);
size = 16;
// WIP Why do we use memcpy here?
memcpy(value, &val, size);
}
case WriteEngine::WR_BINARY:
{ {
char val = boost::any_cast<char>(data); char val = boost::any_cast<char>(data);
//TODO:FIXME how to determine size ? 16, 32,48 ? //TODO:FIXME how to determine size ? 16, 32,48 ?
@@ -416,7 +466,6 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* value, boost:
void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, const size_t pos, boost::any& data, bool fromList) void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, const size_t pos, boost::any& data, bool fromList)
{ {
string curStr; string curStr;
// ColTuple curTuple;
if (fromList) if (fromList)
{ {
@@ -505,11 +554,15 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con
break; break;
case WriteEngine::WR_BINARY: case WriteEngine::WR_BINARY:
case WriteEngine::WR_INT128:
curStr = boost::any_cast<string>(data); curStr = boost::any_cast<string>(data);
memcpy((char*)valArray + pos * curStr.length(), curStr.c_str(), curStr.length()); memcpy((char*)valArray + pos * curStr.length(), curStr.c_str(), curStr.length());
break; break;
case WriteEngine::WR_INT128:
int128_t val = boost::any_cast<int128_t>(data);
size_t size = 16;
// WIP Why do we use memcpy here?
memcpy((uint8_t*)valArray+pos*size, &val, size);
break;
} // end of switch (colType) } // end of switch (colType)
} }
else else
@@ -576,8 +629,12 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con
data = ((Token*)valArray)[pos]; data = ((Token*)valArray)[pos];
break; break;
case WriteEngine::WR_BINARY :
case WriteEngine::WR_INT128: case WriteEngine::WR_INT128:
{
data = ((int128_t*)valArray)[pos];
break;
}
case WriteEngine::WR_BINARY :
{ {
char tmp[16]; char tmp[16];
//TODO:FIXME how to determine size ? 16, 32,48 ? //TODO:FIXME how to determine size ? 16, 32,48 ?