You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
get rid of pointers for 128 fields
This commit is contained in:
@ -552,8 +552,7 @@ int TypeHandlerXDecimal::storeValueToField64(rowgroup::Row& row, int pos, StoreF
|
||||
|
||||
int TypeHandlerXDecimal::storeValueToField128(rowgroup::Row& row, int pos, StoreField* f) const
|
||||
{
|
||||
int128_t* decPtr = row.getTSInt128Field(pos).getValPtr();
|
||||
return f->store_decimal128(datatypes::Decimal(0, f->scale(), f->precision(), decPtr));
|
||||
return f->store_decimal128(datatypes::Decimal(row.getTSInt128Field(pos), f->scale(), f->precision()));
|
||||
}
|
||||
|
||||
int TypeHandlerStr::storeValueToFieldBlobText(rowgroup::Row& row, int pos, StoreField* f) const
|
||||
|
@ -306,11 +306,6 @@ class TSInt128
|
||||
return s128Value;
|
||||
}
|
||||
|
||||
inline int128_t* getValPtr()
|
||||
{
|
||||
return &s128Value;
|
||||
}
|
||||
|
||||
// print int128_t parts represented as PODs
|
||||
uint8_t printPodParts(char* buf, const int128_t& high, const int128_t& mid, const int128_t& low) const;
|
||||
|
||||
|
@ -50,7 +50,6 @@ ReturnedColumn::ReturnedColumn()
|
||||
, fColPosition(-1)
|
||||
, fHasAggregate(false)
|
||||
, fInputIndex(-1)
|
||||
, fInputOffset(-1)
|
||||
, fOutputIndex(-1)
|
||||
, fExpressionId((uint32_t)-1)
|
||||
{
|
||||
@ -71,7 +70,6 @@ ReturnedColumn::ReturnedColumn(const string& sql)
|
||||
, fHasAggregate(false)
|
||||
, fData(sql)
|
||||
, fInputIndex(-1)
|
||||
, fInputOffset(-1)
|
||||
, fOutputIndex(-1)
|
||||
, fExpressionId((uint32_t)-1)
|
||||
{
|
||||
@ -91,7 +89,6 @@ ReturnedColumn::ReturnedColumn(const uint32_t sessionID, const bool returnAll)
|
||||
, fColPosition(-1)
|
||||
, fHasAggregate(false)
|
||||
, fInputIndex(-1)
|
||||
, fInputOffset(-1)
|
||||
, fOutputIndex(-1)
|
||||
, fExpressionId((uint32_t)-1)
|
||||
{
|
||||
@ -113,7 +110,6 @@ ReturnedColumn::ReturnedColumn(const ReturnedColumn& rhs, const uint32_t session
|
||||
, fHasAggregate(rhs.fHasAggregate)
|
||||
, fData(rhs.fData)
|
||||
, fInputIndex(rhs.fInputIndex)
|
||||
, fInputOffset(rhs.fInputOffset)
|
||||
, fOutputIndex(rhs.fOutputIndex)
|
||||
, fExpressionId(rhs.fExpressionId)
|
||||
{
|
||||
@ -146,7 +142,6 @@ void ReturnedColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
b << (uint64_t)fColSource;
|
||||
b << (int64_t)fColPosition;
|
||||
b << (uint32_t)fInputIndex;
|
||||
b << (uint32_t)fInputOffset;
|
||||
b << (uint32_t)fOutputIndex;
|
||||
b << (int32_t)fSequence;
|
||||
b << (uint8_t)fReturnAll;
|
||||
@ -169,7 +164,6 @@ void ReturnedColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
b >> (uint64_t&)fColSource;
|
||||
b >> (int64_t&)fColPosition;
|
||||
b >> (uint32_t&)fInputIndex;
|
||||
b >> (uint32_t&)fInputOffset;
|
||||
b >> (uint32_t&)fOutputIndex;
|
||||
b >> (int32_t&)fSequence;
|
||||
b >> (uint8_t&)fReturnAll;
|
||||
|
@ -372,7 +372,6 @@ class ReturnedColumn : public TreeNode
|
||||
protected:
|
||||
std::string fErrMsg; /// error occured in evaluation
|
||||
uint32_t fInputIndex; /// index to the input rowgroup
|
||||
uint32_t fInputOffset; /// index to the input rowgroup
|
||||
uint32_t fOutputIndex; /// index to the output rowgroup
|
||||
uint32_t fExpressionId; /// unique id for this expression
|
||||
};
|
||||
|
@ -489,12 +489,6 @@ bool SimpleColumn::singleTable(CalpontSystemCatalog::TableAliasName& tan)
|
||||
// @todo move to inline
|
||||
void SimpleColumn::evaluate(Row& row, bool& isNull)
|
||||
{
|
||||
// TODO Move this block into an appropriate place
|
||||
if (UNLIKELY((int)(fInputOffset == (uint32_t)-1)))
|
||||
{
|
||||
fInputOffset = row.getOffset(fInputIndex);
|
||||
}
|
||||
|
||||
bool isNull2 = row.isNullValue(fInputIndex);
|
||||
|
||||
if (isNull2)
|
||||
@ -632,8 +626,7 @@ void SimpleColumn::evaluate(Row& row, bool& isNull)
|
||||
{
|
||||
case 16:
|
||||
{
|
||||
datatypes::TSInt128::assignPtrPtr(&fResult.decimalVal.s128Value,
|
||||
row.getBinaryField_offset<int128_t>(fInputOffset));
|
||||
fResult.decimalVal.s128Value = row.getTSInt128Field(fInputIndex).getValue();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "joblisttypes.h"
|
||||
#include "mcs_basic_types.h"
|
||||
#include "resourcemanager.h"
|
||||
#include "groupconcat.h"
|
||||
|
||||
@ -74,9 +75,9 @@ inline bool minMax(T d1, T d2, int type)
|
||||
return d1 > d2;
|
||||
}
|
||||
|
||||
inline bool minMax(int128_t* d1, int128_t* d2, int type)
|
||||
inline bool minMax(int128_t d1, int128_t d2, int type)
|
||||
{
|
||||
return (type == rowgroup::ROWAGG_MIN) ? *d1 < *d2 : *d1 > *d2;
|
||||
return (type == rowgroup::ROWAGG_MIN) ? d1 < d2 : d1 > d2;
|
||||
}
|
||||
|
||||
inline int64_t getIntNullValue(int colType)
|
||||
@ -247,13 +248,12 @@ const static_any::any& RowAggregation::strTypeId(typeStr);
|
||||
|
||||
static const string overflowMsg("Aggregation overflow.");
|
||||
|
||||
inline void RowAggregation::updateIntMinMax(int128_t* val1, int128_t* val2, int64_t col, int func)
|
||||
inline void RowAggregation::updateIntMinMax(int128_t val1, int128_t val2, int64_t col, int func)
|
||||
{
|
||||
int32_t colOutOffset = fRow.getOffset(col);
|
||||
if (isNull(fRowGroupOut, fRow, col))
|
||||
fRow.setBinaryField_offset(val1, sizeof(int128_t), colOutOffset);
|
||||
fRow.setInt128Field(val1, col);
|
||||
else if (minMax(val1, val2, func))
|
||||
fRow.setBinaryField_offset(val1, sizeof(int128_t), colOutOffset);
|
||||
fRow.setInt128Field(val1, col);
|
||||
}
|
||||
|
||||
inline void RowAggregation::updateIntMinMax(int64_t val1, int64_t val2, int64_t col, int func)
|
||||
@ -867,8 +867,8 @@ void RowAggregation::initMapData(const Row& rowIn)
|
||||
{
|
||||
if (LIKELY(rowIn.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
uint32_t colOutOffset = fRow.getOffset(colOut);
|
||||
fRow.setBinaryField_offset(rowIn.getTSInt128Field(colIn).getValPtr(), sizeof(int128_t), colOutOffset);
|
||||
int128_t value = rowIn.getTSInt128Field(colIn).getValue();
|
||||
fRow.setInt128Field(value, colOut);
|
||||
}
|
||||
else if (rowIn.getColumnWidth(colIn) <= datatypes::MAXLEGACYWIDTH)
|
||||
{
|
||||
@ -1128,7 +1128,7 @@ void RowAggregation::doMinMax(const Row& rowIn, int64_t colIn, int64_t colOut, i
|
||||
{
|
||||
if (LIKELY(rowIn.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
updateIntMinMax(rowIn.getTSInt128Field(colIn).getValPtr(), fRow.getTSInt128Field(colOut).getValPtr(), colOut,
|
||||
updateIntMinMax(rowIn.getTSInt128Field(colIn).getValue(), fRow.getTSInt128Field(colOut).getValue(), colOut,
|
||||
funcType);
|
||||
}
|
||||
else if (rowIn.getColumnWidth(colIn) <= datatypes::MAXLEGACYWIDTH)
|
||||
@ -1226,7 +1226,7 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
|
||||
datatypes::SystemCatalog::ColDataType colDataType = rowIn.getColType(colIn);
|
||||
long double valIn = 0;
|
||||
bool isWideDataType = false;
|
||||
void* wideValInPtr = nullptr;
|
||||
int128_t wideValue = 0;
|
||||
|
||||
if (rowIn.isNullValue(colIn))
|
||||
return;
|
||||
@ -1260,8 +1260,7 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
|
||||
isWideDataType = width == datatypes::MAXDECIMALWIDTH;
|
||||
if (LIKELY(isWideDataType))
|
||||
{
|
||||
int128_t* dec = rowIn.getTSInt128Field(colIn).getValPtr();
|
||||
wideValInPtr = reinterpret_cast<void*>(dec);
|
||||
wideValue = rowIn.getTSInt128Field(colIn).getValue();
|
||||
}
|
||||
else if (width <= datatypes::MAXLEGACYWIDTH)
|
||||
{
|
||||
@ -1341,16 +1340,15 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
|
||||
}
|
||||
else if (isWideDataType)
|
||||
{
|
||||
int128_t* dec = reinterpret_cast<int128_t*>(wideValInPtr);
|
||||
if (LIKELY(!isNull(fRowGroupOut, fRow, colOut)))
|
||||
{
|
||||
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
|
||||
int128_t sum = valOut + *dec;
|
||||
fRow.setBinaryField(&sum, colOut);
|
||||
int128_t sum = valOut + wideValue;
|
||||
fRow.setInt128Field(sum, colOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
fRow.setBinaryField(dec, colOut);
|
||||
fRow.setInt128Field(wideValue, colOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1762,7 +1760,7 @@ void RowAggregation::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut, int6
|
||||
datatypes::SystemCatalog::ColDataType colDataType = rowIn.getColType(colIn);
|
||||
long double valIn = 0;
|
||||
bool isWideDataType = false;
|
||||
void* wideValInPtr = nullptr;
|
||||
int128_t wideValue = 0;
|
||||
|
||||
switch (colDataType)
|
||||
{
|
||||
@ -1793,8 +1791,7 @@ void RowAggregation::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut, int6
|
||||
isWideDataType = width == datatypes::MAXDECIMALWIDTH;
|
||||
if (LIKELY(isWideDataType))
|
||||
{
|
||||
int128_t* dec = rowIn.getTSInt128Field(colIn).getValPtr();
|
||||
wideValInPtr = reinterpret_cast<void*>(dec);
|
||||
wideValue = rowIn.getTSInt128Field(colIn).getValue();
|
||||
}
|
||||
else if (width <= datatypes::MAXLEGACYWIDTH)
|
||||
{
|
||||
@ -1871,16 +1868,15 @@ void RowAggregation::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut, int6
|
||||
}
|
||||
else if (isWideDataType)
|
||||
{
|
||||
int128_t* dec = reinterpret_cast<int128_t*>(wideValInPtr);
|
||||
if (LIKELY(notFirstValue))
|
||||
{
|
||||
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
|
||||
int128_t sum = valOut + *dec;
|
||||
fRow.setBinaryField(&sum, colOut);
|
||||
int128_t sum = valOut + wideValue;
|
||||
fRow.setInt128Field(sum, colOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
fRow.setBinaryField(dec, colOut);
|
||||
fRow.setInt128Field(wideValue, colOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2618,21 +2614,20 @@ void RowAggregationUM::calculateAvgColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t offset = fRow.getOffset(colOut);
|
||||
uint32_t scale = fRow.getScale(colOut);
|
||||
// Get multiplied to deliver AVG with the scale closest
|
||||
// to the expected original scale + 4.
|
||||
// There is a counterpart in buildAggregateColumn.
|
||||
datatypes::Decimal::setScalePrecision4Avg(precision, scale);
|
||||
int128_t* sumPnt = fRow.getBinaryField_offset<int128_t>(offset);
|
||||
int128_t sumPnt = fRow.getTSInt128Field(colOut).getValue();
|
||||
uint32_t scaleDiff = scale - fRow.getScale(colOut);
|
||||
// multiplication overflow check
|
||||
datatypes::MultiplicationOverflowCheck multOp;
|
||||
int128_t sum = 0;
|
||||
if (scaleDiff > 0)
|
||||
multOp(*sumPnt, datatypes::mcs_pow_10[scaleDiff], sum);
|
||||
multOp(sumPnt, datatypes::mcs_pow_10[scaleDiff], sum);
|
||||
else
|
||||
sum = *sumPnt;
|
||||
sum = sumPnt;
|
||||
datatypes::lldiv_t_128 avgAndRem = datatypes::lldiv128(sum, cnt);
|
||||
// Round the last digit
|
||||
if (datatypes::abs(avgAndRem.rem) * 2 >= (int128_t)cnt)
|
||||
@ -2646,7 +2641,7 @@ void RowAggregationUM::calculateAvgColumns()
|
||||
avgAndRem.quot++;
|
||||
}
|
||||
}
|
||||
fRow.setBinaryField_offset(&avgAndRem.quot, sizeof(avgAndRem.quot), offset);
|
||||
fRow.setInt128Field(avgAndRem.quot, colOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4151,7 +4146,7 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
|
||||
datatypes::SystemCatalog::ColDataType colDataType = rowIn.getColType(colIn);
|
||||
long double valIn = 0;
|
||||
bool isWideDataType = false;
|
||||
void* wideValInPtr = nullptr;
|
||||
int128_t wideValue = 0;
|
||||
|
||||
switch (colDataType)
|
||||
{
|
||||
@ -4182,8 +4177,7 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
|
||||
isWideDataType = width == datatypes::MAXDECIMALWIDTH;
|
||||
if (LIKELY(isWideDataType))
|
||||
{
|
||||
int128_t* dec = rowIn.getTSInt128Field(colIn).getValPtr();
|
||||
wideValInPtr = reinterpret_cast<void*>(dec);
|
||||
wideValue = rowIn.getTSInt128Field(colIn).getValue();
|
||||
}
|
||||
else if (width <= datatypes::MAXLEGACYWIDTH)
|
||||
{
|
||||
@ -4250,17 +4244,16 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
|
||||
}
|
||||
else if (isWideDataType)
|
||||
{
|
||||
int128_t* dec = reinterpret_cast<int128_t*>(wideValInPtr);
|
||||
if (LIKELY(cnt > 0))
|
||||
{
|
||||
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();;
|
||||
int128_t sum = valOut + *dec;
|
||||
fRow.setBinaryField(&sum, colOut);
|
||||
int128_t sum = valOut + wideValue;
|
||||
fRow.setInt128Field(sum, colOut);
|
||||
fRow.setUintField(rowIn.getUintField(colAuxIn) + cnt, colAux);
|
||||
}
|
||||
else
|
||||
{
|
||||
fRow.setBinaryField(dec, colOut);
|
||||
fRow.setInt128Field(wideValue, colOut);
|
||||
fRow.setUintField(rowIn.getUintField(colAuxIn), colAux);
|
||||
}
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ class RowAggregation : public messageqcpp::Serializeable
|
||||
copyRow(fNullRow, &row);
|
||||
}
|
||||
|
||||
inline void updateIntMinMax(int128_t* val1, int128_t* val2, int64_t col, int func);
|
||||
inline void updateIntMinMax(int128_t val1, int128_t val2, int64_t col, int func);
|
||||
inline void updateIntMinMax(int64_t val1, int64_t val2, int64_t col, int func);
|
||||
inline void updateUintMinMax(uint64_t val1, uint64_t val2, int64_t col, int func);
|
||||
inline void updateCharMinMax(uint64_t val1, uint64_t val2, int64_t col, int func);
|
||||
|
@ -589,7 +589,7 @@ string Row::toString(uint32_t rownum) const
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
if (colWidths[i] == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
datatypes::Decimal dec(0, scale[i], precision[i], getTSInt128Field(i).getValPtr());
|
||||
datatypes::Decimal dec(getTSInt128Field(i), scale[i], precision[i]);
|
||||
os << dec << " ";
|
||||
break;
|
||||
}
|
||||
@ -1456,7 +1456,7 @@ void applyMapping(const int* mapping, const Row& in, Row* out)
|
||||
// Migrate to offset based methods here
|
||||
// code precision 2 width convertor
|
||||
else if (UNLIKELY(datatypes::isWideDecimalType(in.getColTypes()[i], in.getColumnWidth(i))))
|
||||
out->setBinaryField_offset(in.getTSInt128Field(i).getValPtr(), 16, out->getOffset(mapping[i]));
|
||||
out->setInt128Field(in.getTSInt128Field(i).getValue(), mapping[i]);
|
||||
else if (in.isUnsigned(i))
|
||||
out->setUintField(in.getUintField(i), mapping[i]);
|
||||
else
|
||||
|
@ -442,8 +442,7 @@ class Row
|
||||
inline datatypes::Decimal getDecimalField(uint32_t colIndex) const
|
||||
{
|
||||
if (LIKELY(getColumnWidth(colIndex) == datatypes::MAXDECIMALWIDTH))
|
||||
return datatypes::Decimal(0, (int)getScale(colIndex), getPrecision(colIndex),
|
||||
getTSInt128Field(colIndex).getValPtr());
|
||||
return datatypes::Decimal(getTSInt128Field(colIndex), (int)getScale(colIndex), getPrecision(colIndex));
|
||||
return datatypes::Decimal(datatypes::TSInt64(getIntField(colIndex)), (int)getScale(colIndex),
|
||||
getPrecision(colIndex));
|
||||
}
|
||||
@ -515,11 +514,6 @@ class Row
|
||||
inline const uint8_t* getVarBinaryField(uint32_t colIndex) const;
|
||||
inline const uint8_t* getVarBinaryField(uint32_t& len, uint32_t colIndex) const;
|
||||
inline void setVarBinaryField(const uint8_t* val, uint32_t len, uint32_t colIndex);
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline T* getBinaryField_offset(uint32_t offset) const;
|
||||
|
||||
inline boost::shared_ptr<mcsv1sdk::UserData> getUserData(uint32_t colIndex) const;
|
||||
inline void setUserData(mcsv1sdk::mcsv1Context& context, boost::shared_ptr<mcsv1sdk::UserData> userData,
|
||||
uint32_t len, uint32_t colIndex);
|
||||
@ -1014,13 +1008,6 @@ inline void Row::setStringField(const utils::ConstString& str, uint32_t colIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline T* Row::getBinaryField_offset(uint32_t offset) const
|
||||
{
|
||||
return reinterpret_cast<T*>(&data[offset]);
|
||||
}
|
||||
|
||||
inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const
|
||||
{
|
||||
if (inStringTable(colIndex))
|
||||
@ -1346,7 +1333,7 @@ inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) cons
|
||||
|
||||
inline void Row::copyBinaryField(Row& out, uint32_t destIndex, uint32_t srcIndex) const
|
||||
{
|
||||
out.setBinaryField(getTSInt128Field(srcIndex).getValPtr(), destIndex);
|
||||
out.setInt128Field(getTSInt128Field(srcIndex).getValue(), destIndex);
|
||||
}
|
||||
|
||||
inline void Row::setRid(uint64_t rid)
|
||||
|
@ -526,7 +526,7 @@ void WindowFunctionType::implicit2T(uint64_t i, T& t, int s)
|
||||
}
|
||||
else if (width == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
datatypes::TSInt128::assignPtrPtr(&t, fRow.getTSInt128Field(i).getValPtr());
|
||||
t = fRow.getTSInt128Field(i).getValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3111,9 +3111,8 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, std::strin
|
||||
{
|
||||
if (fetchColColwidths[fetchColPos] == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
datatypes::Decimal dec(0, fetchColScales[fetchColPos],
|
||||
rowGroups[txnId]->getPrecision()[fetchColPos],
|
||||
row.getTSInt128Field(fetchColPos).getValPtr());
|
||||
datatypes::Decimal dec(row.getTSInt128Field(fetchColPos), fetchColScales[fetchColPos],
|
||||
rowGroups[txnId]->getPrecision()[fetchColPos]);
|
||||
value = dec.toString(true);
|
||||
break;
|
||||
}
|
||||
@ -3466,9 +3465,8 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs, std::strin
|
||||
{
|
||||
if (fetchColColwidths[fetchColPos] == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
datatypes::Decimal dec(0, fetchColScales[fetchColPos],
|
||||
rowGroups[txnId]->getPrecision()[fetchColPos],
|
||||
row.getTSInt128Field(fetchColPos).getValPtr());
|
||||
datatypes::Decimal dec(row.getTSInt128Field(fetchColPos), fetchColScales[fetchColPos],
|
||||
rowGroups[txnId]->getPrecision()[fetchColPos]);
|
||||
value = dec.toString(true);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user