1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-05 16:15:50 +03:00

Merge pull request #2029 from tntnatbry/MCOL-641-cleanup

MCOL-641 Cleanup.
This commit is contained in:
Roman Nozdrin
2021-07-06 14:35:21 +03:00
committed by GitHub
29 changed files with 59 additions and 85 deletions

View File

@@ -663,7 +663,7 @@ int TypeHandlerBinary::storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const
{
Field_varstring* f2 = static_cast<Field_varstring*>(f);
// WIP MCOL-641 Binary representation could contain \0.
// TODO MCOL-641 Binary representation could contain \0.
char* binaryString = row.getBinaryField<char>(pos);
return f2->store(binaryString, colType.colWidth, f2->charset());
}

View File

@@ -629,15 +629,16 @@ namespace datatypes
// decimal part
left = sizeof(buf) - (p - buf);
p += writeFractionalPart(tempValue, p, left);
*p = '\0';
uint8_t written = p - buf;
if (sizeof(buf) <= written)
{
throw logging::QueryDataExcept("Decimal::toString() char buffer overflow.",
logging::formatErr);
}
*p = '\0';
return std::string(buf);
}

View File

@@ -265,6 +265,13 @@ class TSInt128
return toTFloat128();
}
// unaligned argument
inline TSInt128& operator=(const int128_t* x)
{
assignPtrPtr(&s128Value, x);
return *this;
}
inline TSInt128 operator%(const int64_t& rhs) const
{
return TSInt128(s128Value % rhs);

View File

@@ -47,7 +47,7 @@ ArithmeticOperator::ArithmeticOperator(const string& operatorName): Operator(ope
ArithmeticOperator::ArithmeticOperator(const ArithmeticOperator& rhs):
Operator(rhs),
fTimeZone(rhs.timeZone()),
fDecimalOverflowCheck(false)
fDecimalOverflowCheck(rhs.getOverflowCheck())
{
}

View File

@@ -129,7 +129,7 @@ ColumnCommandDataType::ColumnCommandDataType(const CalpontSystemCatalog::DataTyp
colWidth = 8;
mIsDict = true;
}
// MCOL-641 WIP
// TODO MCOL-641
else if (colWidth > 8
&& colDataType != CalpontSystemCatalog::DECIMAL
&& colDataType != CalpontSystemCatalog::UDECIMAL)

View File

@@ -264,7 +264,7 @@ public:
{
if (scaleDiff > 0)
{
// WIP MCOL-641 Unconditional overflow check
// TODO MCOL-641 Unconditional overflow check
datatypes::MultiplicationNoOverflowCheck mul;
mul(decimal.s128Value, scaleMultiplier, decimal.s128Value);
}

View File

@@ -118,15 +118,15 @@ public:
void setOpType(Type& l, Type& r);
private:
inline bool numericCompare(IDB_Decimal& op1, IDB_Decimal& op2);
inline bool numericCompare(const IDB_Decimal& op1, const IDB_Decimal& op2);
template <typename result_t>
inline bool numericCompare(result_t op1, result_t op2);
inline bool numericCompare(const result_t op1, const result_t op2);
inline bool strTrimCompare(const std::string& op1, const std::string& op2);
const CHARSET_INFO* cs;
};
inline bool PredicateOperator::numericCompare(IDB_Decimal& op1, IDB_Decimal& op2)
inline bool PredicateOperator::numericCompare(const IDB_Decimal& op1, const IDB_Decimal& op2)
{
switch (fOp)
{
@@ -158,7 +158,7 @@ inline bool PredicateOperator::numericCompare(IDB_Decimal& op1, IDB_Decimal& op2
}
template <typename result_t>
inline bool PredicateOperator::numericCompare(result_t op1, result_t op2)
inline bool PredicateOperator::numericCompare(const result_t op1, const result_t op2)
{
switch (fOp)
{

View File

@@ -483,7 +483,7 @@ void SimpleColumn::setDerivedTable()
// @todo make aggregate filter to having clause. not optimize it for now
if (fDerivedRefCol &&
// WIP replace with typeid()
// TODO replace with typeid()
(dynamic_cast<AggregateColumn*>(fDerivedRefCol) ||
dynamic_cast<WindowFunctionColumn*>(fDerivedRefCol)))
fDerivedTable = "";
@@ -502,7 +502,7 @@ bool SimpleColumn::singleTable(CalpontSystemCatalog::TableAliasName& tan)
// @todo move to inline
void SimpleColumn::evaluate(Row& row, bool& isNull)
{
// WIP Move this block into an appropriate place
// TODO Move this block into an appropriate place
if (UNLIKELY((int)(fInputOffset == (uint32_t)-1)))
{
fInputOffset = row.getOffset(fInputIndex);

View File

@@ -143,7 +143,7 @@ void SimpleColumn_Decimal<len>::setNullVal()
fNullVal = joblist::TINYINTNULL;
break;
case 16:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
// TODO MCOL-641
//fallthrough
default:
fNullVal = joblist::BIGINTNULL;
@@ -233,8 +233,8 @@ void SimpleColumn_Decimal<len>::serialize(messageqcpp::ByteStream& b) const
case 8:
b << (ObjectReader::id_t) ObjectReader::SIMPLECOLUMN_DECIMAL8;
break;
case 16:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
// TODO MCOL-641
// case 16:
}
SimpleColumn::serialize(b);
@@ -260,8 +260,8 @@ void SimpleColumn_Decimal<len>::unserialize(messageqcpp::ByteStream& b)
case 8:
ObjectReader::checkType(b, ObjectReader::SIMPLECOLUMN_DECIMAL8);
break;
case 16:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << std::endl;
// TODO MCOL-641
// case 16:
}
SimpleColumn::unserialize(b);

View File

@@ -142,8 +142,8 @@ void SimpleColumn_UINT<len>::setNullVal()
case 1:
fNullVal = joblist::UTINYINTNULL;
break;
// TODO MCOL-641
case 16:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << std::endl;
//fallthrough
default:
fNullVal = joblist::UBIGINTNULL;
@@ -245,8 +245,9 @@ void SimpleColumn_UINT<len>::serialize(messageqcpp::ByteStream& b) const
case 8:
b << (ObjectReader::id_t) ObjectReader::SIMPLECOLUMN_UINT8;
break;
case 16:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << std::endl;
// TODO MCOL-641
// case 16:
}
SimpleColumn::serialize(b);
@@ -272,8 +273,9 @@ void SimpleColumn_UINT<len>::unserialize(messageqcpp::ByteStream& b)
case 8:
ObjectReader::checkType(b, ObjectReader::SIMPLECOLUMN_UINT8);
break;
case 16:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << std::endl;
// TODO MCOL-641
// case 16:
}
SimpleColumn::unserialize(b);

View File

@@ -489,8 +489,9 @@ void WindowFunctionColumn::evaluate(Row& row, bool& isNull)
fResult.origIntVal = row.getUintField<8>(fInputIndex);
break;
// TODO MCOL-641
case 16:
cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << endl;
//fallthrough
default:
if (row.equals(CPNULLSTRMARK, fInputIndex))

View File

@@ -680,8 +680,9 @@ void BatchPrimitiveProcessorJL::getTuples(messageqcpp::ByteStream& in,
columnData[j]++;
pos++;
break;
// TODO MCOL-641
case 16:
cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << endl;
//fallthrough
default:
cout << "BPP::getTuples(): bad column width of " << colWidths[j]

View File

@@ -256,9 +256,11 @@ uint8_t ColumnCommandJL::getTableColumnType()
case 1:
return TableColumn::UINT8;
// TODO MCOL-641
case 16:
cout << __FILE__<< ":" <<__LINE__ << " Fix 16 Bytes ?" << endl;
//fallthrough
default:
throw logic_error("ColumnCommandJL: bad column width");
}

View File

@@ -1885,9 +1885,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo)
#else
bool isNull = ConstantColumn::NULLDATA == cc->type();
// WIP MCOL-641 width check must be a f() not a literal
// make a template from convertValueNum to avoid extra if
// this condition doesn't support UDECIMAL
if (ct.isWideDecimalType())
convertValueNum(constval, ct, isNull, rf, jobInfo.timeZone, value128);
else

View File

@@ -597,7 +597,6 @@ void pColStep::addFilter(int8_t COP, int64_t value, uint8_t roundFlag)
fFilterCount++;
}
// WIP MCOL-641
void pColStep::addFilter(int8_t COP, const int128_t& value, uint8_t roundFlag)
{
fFilterString << (uint8_t) COP;

View File

@@ -196,7 +196,6 @@ public:
*/
void addFilter(int8_t COP, int64_t value, uint8_t roundFlag = 0);
void addFilter(int8_t COP, float value);
// WIP MCOL-641
void addFilter(int8_t COP, const int128_t& value, uint8_t roundFlag = 0);
/** @brief Sets the DataList to get RID values from.

View File

@@ -380,8 +380,8 @@ float RowEstimator::estimateRowReturnFactor(const BRM::EMEntry& emEntry,
if (ct.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
ct.colDataType == execplan::CalpontSystemCatalog::UDECIMAL)
{
uint128_t val = *(uint128_t*)msgDataPtr;
bigValue = static_cast<int128_t>(val);
datatypes::TSInt128 val(reinterpret_cast<const int128_t*>(msgDataPtr));
bigValue = val.getValue();
break;
}
}
@@ -426,8 +426,8 @@ float RowEstimator::estimateRowReturnFactor(const BRM::EMEntry& emEntry,
if (ct.colDataType == execplan::CalpontSystemCatalog::DECIMAL ||
ct.colDataType == execplan::CalpontSystemCatalog::UDECIMAL)
{
int128_t val = *(int128_t*)msgDataPtr;
bigValue = static_cast<int128_t>(val);
datatypes::TSInt128 val(reinterpret_cast<const int128_t*>(msgDataPtr));
bigValue = val.getValue();
break;
}
}

View File

@@ -1484,7 +1484,7 @@ bool TupleBPS::processSingleFilterString(int8_t BOP, int8_t colWidth, T val, con
{
int8_t COP;
int64_t val2;
int128_t bigVal2;
datatypes::TSInt128 bigVal2;
bool thisPredicate;
COP = *filterString++;
filterString++; // skip the round var, don't think that applies here
@@ -1512,7 +1512,7 @@ bool TupleBPS::processSingleFilterString(int8_t BOP, int8_t colWidth, T val, con
break;
case 16:
bigVal2 = *((int128_t*) filterString);
bigVal2 = reinterpret_cast<const int128_t*>(filterString);
filterString += 16;
break;
@@ -1524,7 +1524,7 @@ bool TupleBPS::processSingleFilterString(int8_t BOP, int8_t colWidth, T val, con
if (static_cast<uint8_t>(colWidth) < datatypes::MAXDECIMALWIDTH)
thisPredicate = compareSingleValue(COP, (int64_t) val, val2);
else
thisPredicate = compareSingleValue(COP, (int128_t) val, bigVal2);
thisPredicate = compareSingleValue(COP, (int128_t) val, bigVal2.getValue());
if (j == 0)
ret = thisPredicate;

View File

@@ -5148,9 +5148,9 @@ because it has multiple arguments.";
// adjust decimal result type according to internalDecimalScale
bool isWideDecimal = ac->resultType().isWideDecimalType();
// This must be also valid for UDECIMAL
if (!isWideDecimal && gwi.internalDecimalScale >= 0
&& ac->resultType().colDataType == CalpontSystemCatalog::DECIMAL)
if (!isWideDecimal && gwi.internalDecimalScale >= 0 &&
(ac->resultType().colDataType == CalpontSystemCatalog::DECIMAL ||
ac->resultType().colDataType == CalpontSystemCatalog::UDECIMAL))
{
CalpontSystemCatalog::ColType ct = ac->resultType();
ct.scale = gwi.internalDecimalScale;

View File

@@ -208,13 +208,6 @@ inline bool colStrCompare_(uint64_t val1, uint64_t val2, uint8_t COP, uint8_t rf
template<int>
inline bool isEmptyVal(uint8_t type, const uint8_t* val8);
template<>
inline bool isEmptyVal<32>(uint8_t type, const uint8_t* ival) // For BINARY
{
std::cout << __func__ << " WARNING!!! Not implemented for 32 byte data types." << std::endl;
return false;
}
template<>
inline bool isEmptyVal<16>(uint8_t type, const uint8_t* ival) // For BINARY
{
@@ -354,15 +347,6 @@ inline bool isNullVal<16>(uint8_t type, const uint8_t* ival)
return *val == datatypes::Decimal128Null;
}
template<>
inline bool isNullVal<32>(uint8_t type, const uint8_t* ival)
{
std::cout << __func__ << " WARNING!!! Not implemented for 32 byte data types."
<< std::endl;
return false;
}
template<>
inline bool isNullVal<8>(uint8_t type, const uint8_t* ival)
{
@@ -505,7 +489,6 @@ inline bool isNullVal(uint32_t length, uint8_t type, const uint8_t* val8)
case 1:
return isNullVal<1>(type, val8);
};
std::cout << __func__ << " WARNING!!! Not implemented for " << length << " bytes data types." << std::endl;
return false;
}
@@ -693,17 +676,12 @@ inline void store(const NewColRequestHeader* in,
switch (in->colType.DataSize)
{
case 32:
std::cout << __func__ << " WARNING!!! Not implemented for 32 byte data types." << std::endl;
break;
case 16:
ptr2 += (rid << 4);
memcpy(ptr1, ptr2, 16);
break;
default:
std::cout << __func__ << " WARNING!!! unspecified column width." << std::endl;
// fallthrough
case 8:
@@ -1636,10 +1614,6 @@ void PrimitiveProcessor::p_Col(NewColRequestHeader* in, NewColResultHeader* out,
p_Col_bin_ridArray<16, int128_t>(in, out, outSize, written, block, fStatsPtr, itemsPerBlk, parsedColumnFilter);
break;
case 32:
std::cout << __func__ << " WARNING!!! Not implemented for 32 byte data types." << std::endl;
// fallthrough
default:
idbassert(0);
break;

View File

@@ -319,7 +319,6 @@ private:
int dict_OffsetIndex, currentOffsetIndex; // used by p_dictionary
int fDebugLevel;
dbbc::Stats* fStatsPtr; // pointer for pmstats
// To be removed b/c always true
bool logicalBlockMode;
boost::shared_ptr<ParsedColumnFilter> parsedColumnFilter;

View File

@@ -485,8 +485,6 @@ void ColumnCommand::createCommand(ByteStream& bs)
bs >> filterCount;
deserializeInlineVector(bs, lastLbid);
// cout << __func__ << " colType.colWidth " << colType.colWidth << endl;
// cout << "lastLbid count=" << lastLbid.size() << endl;
// for (uint32_t i = 0; i < lastLbid.size(); i++)
// cout << " " << lastLbid[i];

View File

@@ -1511,7 +1511,7 @@ double Func_cast_decimal::getDoubleVal(Row& row,
isNull,
operationColType);
// WIP MCOL-641 This could deliver wrong result b/c wide DECIMAL might have
// TODO MCOL-641 This could deliver wrong result b/c wide DECIMAL might have
// p <= INT64MAXPRECISION || p > INT128MAXPRECISION
if (decimal.isTSInt128ByPrecision())
{

View File

@@ -338,7 +338,6 @@ void RowAggregation::updateStringMinMax(string val1, string val2, int64_t col, i
inline bool RowAggregation::isNull(const RowGroup* pRowGroup, const Row& row, int64_t col)
{
/* TODO: Can we replace all of this with a call to row.isNullValue(col)? */
// WIP MCOL-641 Yes. We can
bool ret = false;
int colDataType = (pRowGroup->getColTypes())[col];

View File

@@ -1023,14 +1023,13 @@ bool Row::isNullValue(uint32_t colIndex) const
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
// WIP MCOL-641 Allmighty hack.
// TODO MCOL-641 Allmighty hack.
switch (getColumnWidth(colIndex))
{
// MCOL-641
case 16:
return isNullValue_offset
<execplan::CalpontSystemCatalog::DECIMAL,16>(offsets[colIndex]);
case 1 :
return (data[offsets[colIndex]] == joblist::TINYINTNULL);

View File

@@ -808,8 +808,6 @@ TType TCompactProtocolT<Transport_>::getTType(int8_t type) {
case detail::compact::CT_STRUCT:
return T_STRUCT;
default:
cout << __FILE__<< __LINE__ << __func__<< endl;
throw TException(std::string("don't know what type: ") + (char)type);
}
return T_STOP;

View File

@@ -457,7 +457,6 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
if (dataType == CalpontSystemCatalog::DECIMAL ||
dataType == CalpontSystemCatalog::UDECIMAL)
{
// WIP MCOL-641
if (colDefPtr->fType->fPrecision > 38) // precision cannot be over 38.
{
ostringstream os;

View File

@@ -149,7 +149,7 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std:
{
DMLColumn* columnPtr = *column_iterator;
tableColName.column = columnPtr->get_Name();
// WIP MCOL-641 replace with getColRidsOidsTypes()
// TODO MCOL-641 replace with getColRidsOidsTypes()
CalpontSystemCatalog::ROPair roPair = systemCatalogPtr->columnRID(tableColName);
CalpontSystemCatalog::OID oid = systemCatalogPtr->lookupOID(tableColName);
@@ -216,7 +216,7 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std:
const DMLColumn* columnPtr = rowPtr->get_ColumnAt(i);
tableColName.column = columnPtr->get_Name();
// WIP MCOL-641 remove these calls
// TODO MCOL-641 remove these calls
CalpontSystemCatalog::OID oid = systemCatalogPtr->lookupOID(tableColName);
CalpontSystemCatalog::ColType colType;

View File

@@ -3576,7 +3576,7 @@ int WriteEngineWrapper::insertColumnRec_Single(const TxnID& txnid,
}
bool newFile;
// WIP
#ifdef PROFILE
timer.start("allocRowId");
#endif
@@ -5520,9 +5520,8 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid,
((uint16_t*)valArray)[j] = tmp16;
break;
// WIP
case WriteEngine::WR_BINARY:
((uint64_t*)valArray)[j] = curValue; //FIXME maybe
((uint64_t*)valArray)[j] = curValue;
break;
}
@@ -5671,9 +5670,8 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid,
((uint16_t*)valArray)[j] = tmp16;
break;
// WIP
case WriteEngine::WR_BINARY:
((uint64_t*)valArray)[j] = curValue; // FIXME maybe
((uint64_t*)valArray)[j] = curValue;
break;
}
}