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

MCOL-641 PoC version for DECIMAL(38) using BINARY as a basis.

This commit is contained in:
Roman Nozdrin
2019-10-29 01:21:17 -05:00
parent 32f6167067
commit c9f42fb5cc
16 changed files with 70 additions and 40 deletions

View File

@@ -199,14 +199,12 @@ void ColumnDef::convertDecimal()
}
else if ((fType->fPrecision > 0) && (fType->fPrecision < 3))
{
//dataType = CalpontSystemCatalog::TINYINT;
fType->fType = DDL_TINYINT;
fType->fLength = 1;
}
else if (fType->fPrecision < 5 && (fType->fPrecision > 2))
{
//dataType = CalpontSystemCatalog::SMALLINT;
fType->fType = DDL_SMALLINT;
fType->fLength = 2;
}
@@ -217,15 +215,19 @@ void ColumnDef::convertDecimal()
}
else if (fType->fPrecision > 6 && fType->fPrecision < 10)
{
//dataType = CalpontSystemCatalog::INT;
fType->fType = DDL_INT;
fType->fLength = 4;
}
else if (fType->fPrecision > 9 && fType->fPrecision < 19)
{
//dataType = CalpontSystemCatalog::BIGINT;
fType->fType = DDL_BIGINT;
fType->fLength = 8;
}
else if (fType->fPrecision > 19 && fType->fPrecision <39)
{
fType->fType = DDL_BINARY;
fType->fLength = 16;
}
}
}
} // end of namespace

View File

@@ -76,7 +76,7 @@ PassThruCommandJL::PassThruCommandJL(const PassThruStep& p)
case 16:
case 32:
tableColumnType = TableColumn::STRING;
tableColumnType = TableColumn::STRING;
break;
default:

View File

@@ -148,11 +148,6 @@ pColScanStep::pColScanStep(
int err, i, mask;
BRM::LBIDRange_v::iterator it;
//pthread_mutex_init(&mutex, NULL);
//pthread_mutex_init(&dlMutex, NULL);
//pthread_mutex_init(&cpMutex, NULL);
//pthread_cond_init(&condvar, NULL);
//pthread_cond_init(&condvarWakeupProducer, NULL);
finishedSending = false;
recvWaiting = 0;
recvExited = 0;
@@ -178,7 +173,10 @@ pColScanStep::pColScanStep(
fColType.colWidth = 8;
fIsDict = true;
}
else if (fColType.colWidth > 8 && fColType.colDataType != CalpontSystemCatalog::BINARY)
// MCOL-641 WIP
else if (fColType.colWidth > 8
&& fColType.colDataType != CalpontSystemCatalog::BINARY
&& fColType.colDataType != CalpontSystemCatalog::DECIMAL)
{
fColType.colWidth = 8;
fIsDict = true;

View File

@@ -177,7 +177,10 @@ pColStep::pColStep(
fColType.colWidth = 8;
fIsDict = true;
}
else if (fColType.colWidth > 8 && fColType.colDataType != CalpontSystemCatalog::BINARY )
// WIP MCOL-641
else if (fColType.colWidth > 8
&& fColType.colDataType != CalpontSystemCatalog::BINARY
&& fColType.colDataType != CalpontSystemCatalog::DECIMAL)
{
fColType.colWidth = 8;
fIsDict = true;

View File

@@ -801,7 +801,14 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
intColVal = row.getIntField(s);
if (row.getPrecision(s) > 18)
{
sscanf(row.getBinaryField(s).c_str(), "%ld",&intColVal);
}
else
{
intColVal = row.getIntField(s);
}
storeNumericField(f, intColVal, colType);
break;
}

View File

@@ -285,7 +285,11 @@ template<>
inline bool isEmptyVal<16>(uint8_t type, const uint8_t* ival) // For BINARY
{
const uint64_t* val = reinterpret_cast<const uint64_t*>(ival);
return ((val[0] == joblist::BINARYEMPTYROW) && (val[1] == joblist::BINARYEMPTYROW));
// WIP ugly speed hack
return ((val[0] == joblist::BINARYEMPTYROW) && (val[1] == joblist::BINARYEMPTYROW)
|| (val[0] == joblist::BIGINTEMPTYROW) && (val[1] == joblist::BIGINTEMPTYROW))
;
}
template<>

View File

@@ -1224,8 +1224,12 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
value = (long long) number_int_value(data, colType, pushWarning, noRoundup);
break;
// MCOL-641 WIP
// use string2BCD conversion here + set sign
case CalpontSystemCatalog::DECIMAL:
if (colType.colWidth == 1)
if (colType.colWidth == 16)
value = data;
else if (colType.colWidth == 1)
value = (char) number_int_value(data, colType, pushWarning, noRoundup);
else if (colType.colWidth == 2)
value = (short) number_int_value(data, colType, pushWarning, noRoundup);
@@ -1233,9 +1237,11 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
value = (int) number_int_value(data, colType, pushWarning, noRoundup);
else if (colType.colWidth == 8)
value = (long long) number_int_value(data, colType, pushWarning, noRoundup);
else if (colType.colWidth == 32)
value = data;
break;
// MCOL-641 Implement UDECIMAL
case CalpontSystemCatalog::UDECIMAL:
// UDECIMAL numbers may not be negative

View File

@@ -746,6 +746,7 @@ inline int64_t Row::getIntField(uint32_t colIndex) const
return *((int64_t*) &data[offsets[colIndex]]);
default:
std::cout << "Row::getIntField getColumnWidth(colIndex) " << getColumnWidth(colIndex) << std::endl;
idbassert(0);
throw std::logic_error("Row::getIntField(): bad length.");
}

View File

@@ -458,9 +458,11 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
{
if (colDefPtr->fType->fPrecision > 18) //@Bug 5717 precision cannot be over 18.
{
ostringstream os;
os << "Syntax error: The maximum precision (total number of digits) that can be specified is 18";
throw std::runtime_error(os.str());
// WIP MCOL-641
//ostringstream os;
//os << "Syntax error: The maximum precision (total number of digits) that can be specified is 18";
//throw std::runtime_error(os.str());
colDefPtr->convertDecimal();
}
else if (colDefPtr->fType->fPrecision < colDefPtr->fType->fScale)
{
@@ -507,7 +509,7 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
}
else if (dataType == CalpontSystemCatalog::BINARY
&& ! (colDefPtr->fType->fLength == 16
&& ! (colDefPtr->fType->fLength == 16
|| colDefPtr->fType->fLength == 32))
{
ostringstream os;

View File

@@ -412,8 +412,8 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std:
// call the write engine to write the rows
int error = NO_ERROR;
//fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3);
//cout << "inserting a row with transaction id " << txnid.id << endl;
fWEWrapper.setDebugLevel(WriteEngine::DEBUG_3);
cout << "inserting a row with transaction id " << txnid.id << endl;
fWEWrapper.setIsInsert(true);
fWEWrapper.setBulkFlag(true);
fWEWrapper.setTransId(txnid.id);

View File

@@ -106,12 +106,12 @@ private:
WriteEngineWrapper fWEWrapper;
boost::scoped_ptr<RBMetaWriter> fRBMetaWriter;
std::vector<boost::shared_ptr<DBRootExtentTracker> > dbRootExtTrackerVec;
inline bool isDictCol ( execplan::CalpontSystemCatalog::ColType colType )
inline bool isDictCol ( execplan::CalpontSystemCatalog::ColType &colType )
{
if (((colType.colDataType == execplan::CalpontSystemCatalog::CHAR) && (colType.colWidth > 8))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::VARCHAR) && (colType.colWidth > 7))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 18))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::UDECIMAL) && (colType.precision > 18))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::DECIMAL) && (colType.precision > 65))
|| ((colType.colDataType == execplan::CalpontSystemCatalog::UDECIMAL) && (colType.precision > 65))
|| (colType.colDataType == execplan::CalpontSystemCatalog::VARBINARY)
|| (colType.colDataType == execplan::CalpontSystemCatalog::BLOB)
|| (colType.colDataType == execplan::CalpontSystemCatalog::TEXT))

View File

@@ -633,9 +633,13 @@ void Convertor::convertColType(ColStruct* curStruct)
*internalType = WriteEngine::WR_INT;
break;
default:
case 8:
*internalType = WriteEngine::WR_LONGLONG;
break;
default:
*internalType = WriteEngine::WR_BCDECIMAL;
break;
}
break;

View File

@@ -111,7 +111,8 @@ enum ColType /** @brief Column type enumeration*/
WR_TEXT = 17, /** @brief TEXT */
WR_MEDINT = 18, /** @brief Medium Int */
WR_UMEDINT = 19, /** @brief Unsigned Medium Int */
WR_BINARY = 20 /** @brief BINARY */
WR_BINARY = 20, /** @brief BINARY */
WR_BCDECIMAL = 21 /** @brief BINARY CODED DECIMAL */
};
// Describes relation of field to column for a bulk load

View File

@@ -1687,9 +1687,9 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray,
break;
case WriteEngine::WR_BINARY:
case WriteEngine::WR_BCDECIMAL:
if (!bDelete) pVal = (uint8_t*) valArray + i * curCol.colWidth;
//pOldVal = (uint8_t*) oldValArray + i * curCol.colWidth;
break;
default :

View File

@@ -503,6 +503,7 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con
break;
case WriteEngine::WR_BINARY:
case WriteEngine::WR_BCDECIMAL:
curStr = boost::any_cast<string>(data);
memcpy((char*)valArray + pos * curStr.length(), curStr.c_str(), curStr.length());
break;
@@ -5157,6 +5158,7 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid,
break;
case WriteEngine::WR_BINARY:
case WriteEngine::WR_BCDECIMAL:
valArray = calloc(colStructList[i].colWidth, totalRow1);
break;
}

View File

@@ -621,7 +621,17 @@ public:
*/
// todo: add implementation when we work on version control
// int endTran(const TransID transOid) { return NO_ERROR; }
// WIP
void setDebugLevel(const DebugLevel level)
{
WEObj::setDebugLevel(level);
for (int i = 0; i < TOTAL_COMPRESS_OP; i++)
{
m_colOp[i]->setDebugLevel(level);
m_dctnry[i]->setDebugLevel(level);
}
} // todo: cleanup
/************************************************************************
* Internal use definitions
@@ -676,17 +686,7 @@ private:
std::vector<BRM::VBRange>& freeList, std::vector<std::vector<uint32_t> >& fboLists,
std::vector<std::vector<BRM::LBIDRange> >& rangeLists, std::vector<BRM::LBIDRange>& rangeListTot);
void setDebugLevel(const DebugLevel level)
{
WEObj::setDebugLevel(level);
for (int i = 0; i < TOTAL_COMPRESS_OP; i++)
{
m_colOp[i]->setDebugLevel(level);
m_dctnry[i]->setDebugLevel(level);
}
} // todo: cleanup
/**
* @brief Common methods to write values to a column
*/