1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Replace getBinaryField

This commit is contained in:
mariadb-AndreyPiskunov
2022-08-25 18:21:43 +03:00
parent 3d10d0707b
commit 0863ecd279
9 changed files with 43 additions and 54 deletions

View File

@ -868,7 +868,7 @@ void RowAggregation::initMapData(const Row& rowIn)
if (LIKELY(rowIn.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH))
{
uint32_t colOutOffset = fRow.getOffset(colOut);
fRow.setBinaryField_offset(rowIn.getBinaryField<int128_t>(colIn), sizeof(int128_t), colOutOffset);
fRow.setBinaryField_offset(rowIn.getTSInt128Field(colIn).getValPtr(), sizeof(int128_t), colOutOffset);
}
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.getBinaryField<int128_t>(colIn), fRow.getBinaryField<int128_t>(colOut), colOut,
updateIntMinMax(rowIn.getTSInt128Field(colIn).getValPtr(), fRow.getTSInt128Field(colOut).getValPtr(), colOut,
funcType);
}
else if (rowIn.getColumnWidth(colIn) <= datatypes::MAXLEGACYWIDTH)
@ -1260,7 +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.getBinaryField<int128_t>(colIn);
int128_t* dec = rowIn.getTSInt128Field(colIn).getValPtr();
wideValInPtr = reinterpret_cast<void*>(dec);
}
else if (width <= datatypes::MAXLEGACYWIDTH)
@ -1329,8 +1329,8 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
{
if (LIKELY(!isNull(fRowGroupOut, fRow, colOut)))
{
int128_t* valOutPtr = fRow.getBinaryField<int128_t>(colOut);
int128_t sum = *valOutPtr + valIn;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
int128_t sum = valOut + valIn;
fRow.setBinaryField(&sum, colOut);
}
else
@ -1344,8 +1344,8 @@ void RowAggregation::doSum(const Row& rowIn, int64_t colIn, int64_t colOut, int
int128_t* dec = reinterpret_cast<int128_t*>(wideValInPtr);
if (LIKELY(!isNull(fRowGroupOut, fRow, colOut)))
{
int128_t* valOutPtr = fRow.getBinaryField<int128_t>(colOut);
int128_t sum = *valOutPtr + *dec;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
int128_t sum = valOut + *dec;
fRow.setBinaryField(&sum, colOut);
}
else
@ -1793,7 +1793,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.getBinaryField<int128_t>(colIn);
int128_t* dec = rowIn.getTSInt128Field(colIn).getValPtr();
wideValInPtr = reinterpret_cast<void*>(dec);
}
else if (width <= datatypes::MAXLEGACYWIDTH)
@ -1859,8 +1859,8 @@ void RowAggregation::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut, int6
{
if (LIKELY(notFirstValue))
{
int128_t* valOutPtr = fRow.getBinaryField<int128_t>(colOut);
int128_t sum = *valOutPtr + valIn;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
int128_t sum = valOut + valIn;
fRow.setBinaryField(&sum, colOut);
}
else
@ -1874,8 +1874,8 @@ void RowAggregation::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut, int6
int128_t* dec = reinterpret_cast<int128_t*>(wideValInPtr);
if (LIKELY(notFirstValue))
{
int128_t* valOutPtr = fRow.getBinaryField<int128_t>(colOut);
int128_t sum = *valOutPtr + *dec;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
int128_t sum = valOut + *dec;
fRow.setBinaryField(&sum, colOut);
}
else
@ -1925,7 +1925,7 @@ void RowAggregation::doStatistics(const Row& rowIn, int64_t colIn, int64_t colOu
if (LIKELY(fRowGroupIn.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH))
{
// To save from unaligned memory
datatypes::TSInt128 val128In(rowIn.getBinaryField<int128_t>(colIn));
datatypes::TSInt128 val128In = rowIn.getTSInt128Field(colIn);
valIn = static_cast<long double>(val128In.toTFloat128());
}
else if (fRowGroupIn.getColumnWidth(colIn) <= datatypes::MAXLEGACYWIDTH)
@ -4182,7 +4182,7 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
isWideDataType = width == datatypes::MAXDECIMALWIDTH;
if (LIKELY(isWideDataType))
{
int128_t* dec = rowIn.getBinaryField<int128_t>(colIn);
int128_t* dec = rowIn.getTSInt128Field(colIn).getValPtr();
wideValInPtr = reinterpret_cast<void*>(dec);
}
else if (width <= datatypes::MAXLEGACYWIDTH)
@ -4236,8 +4236,8 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
{
if (LIKELY(cnt > 0))
{
int128_t* valOutPtr = fRow.getBinaryField<int128_t>(colOut);
int128_t sum = valIn + *valOutPtr;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();
int128_t sum = valIn + valOut;
fRow.setBinaryField(&sum, colOut);
fRow.setUintField(rowIn.getUintField(colAuxIn) + cnt, colAux);
}
@ -4253,8 +4253,8 @@ void RowAggregationUMP2::doAvg(const Row& rowIn, int64_t colIn, int64_t colOut,
int128_t* dec = reinterpret_cast<int128_t*>(wideValInPtr);
if (LIKELY(cnt > 0))
{
int128_t* valOutPtr = fRow.getBinaryField<int128_t>(colOut);
int128_t sum = *valOutPtr + *dec;
int128_t valOut = fRow.getTSInt128Field(colOut).getValue();;
int128_t sum = valOut + *dec;
fRow.setBinaryField(&sum, colOut);
fRow.setUintField(rowIn.getUintField(colAuxIn) + cnt, colAux);
}

View File

@ -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], getBinaryField<int128_t>(i));
datatypes::Decimal dec(0, scale[i], precision[i], getTSInt128Field(i).getValPtr());
os << dec << " ";
break;
}
@ -1023,7 +1023,7 @@ bool Row::equals(const Row& r2, uint32_t lastCol) const
}
else if (UNLIKELY(datatypes::isWideDecimalType(columnType, colWidths[col])))
{
if (*getBinaryField<int128_t>(col) != *r2.getBinaryField<int128_t>(col))
if (getTSInt128Field(col).getValue() != r2.getTSInt128Field(col).getValue())
return false;
}
else if (getUintField(col) != r2.getUintField(col))
@ -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.getBinaryField<int128_t>(i), 16, out->getOffset(mapping[i]));
out->setBinaryField_offset(in.getTSInt128Field(i).getValPtr(), 16, out->getOffset(mapping[i]));
else if (in.isUnsigned(i))
out->setUintField(in.getUintField(i), mapping[i]);
else

View File

@ -443,7 +443,7 @@ class Row
{
if (LIKELY(getColumnWidth(colIndex) == datatypes::MAXDECIMALWIDTH))
return datatypes::Decimal(0, (int)getScale(colIndex), getPrecision(colIndex),
getBinaryField<int128_t>(colIndex));
getTSInt128Field(colIndex).getValPtr());
return datatypes::Decimal(datatypes::TSInt64(getIntField(colIndex)), (int)getScale(colIndex),
getPrecision(colIndex));
}
@ -516,12 +516,7 @@ class Row
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);
// inline std::string getBinaryField(uint32_t colIndex) const;
template <typename T>
inline T* getBinaryField(uint32_t colIndex) const;
// To simplify parameter type deduction.
template <typename T>
inline T* getBinaryField(T* argtype, uint32_t colIndex) const;
template <typename T>
inline T* getBinaryField_offset(uint32_t offset) const;
@ -549,7 +544,7 @@ class Row
// that's not string-table safe, this one is
inline void copyField(Row& dest, uint32_t destIndex, uint32_t srcIndex) const;
template <typename T>
inline void copyBinaryField(Row& dest, uint32_t destIndex, uint32_t srcIndex) const;
std::string toString(uint32_t rownum = 0) const;
@ -1019,17 +1014,6 @@ inline void Row::setStringField(const utils::ConstString& str, uint32_t colIndex
}
}
template <typename T>
inline T* Row::getBinaryField(uint32_t colIndex) const
{
return getBinaryField_offset<T>(offsets[colIndex]);
}
template <typename T>
inline T* Row::getBinaryField(T* argtype, uint32_t colIndex) const
{
return getBinaryField_offset<T>(offsets[colIndex]);
}
template <typename T>
inline T* Row::getBinaryField_offset(uint32_t offset) const
@ -1113,7 +1097,7 @@ inline void Row::getInt128Field(uint32_t colIndex, int128_t& x) const
inline datatypes::TSInt128 Row::getTSInt128Field(uint32_t colIndex) const
{
const int128_t* ptr = getBinaryField<int128_t>(colIndex);
const int128_t* ptr = reinterpret_cast<int128_t*>(&data[offsets[colIndex]]);;
return datatypes::TSInt128(ptr);
}
@ -1351,7 +1335,7 @@ inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) cons
}
else if (UNLIKELY(datatypes::isWideDecimalType(types[srcIndex], colWidths[srcIndex])))
{
copyBinaryField<int128_t>(out, destIndex, srcIndex);
copyBinaryField(out, destIndex, srcIndex);
}
else
{
@ -1359,10 +1343,10 @@ inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) cons
}
}
template <typename T>
inline void Row::copyBinaryField(Row& out, uint32_t destIndex, uint32_t srcIndex) const
{
out.setBinaryField(getBinaryField<T>(srcIndex), destIndex);
out.setBinaryField(getTSInt128Field(srcIndex).getValPtr(), destIndex);
}
inline void Row::setRid(uint64_t rid)
@ -1981,7 +1965,7 @@ inline void copyRow(const Row& in, Row* out, uint32_t colCount)
}
else if (UNLIKELY(datatypes::isWideDecimalType(in.getColType(i), in.getColumnWidth(i))))
{
in.copyBinaryField<int128_t>(*out, i, i);
in.copyBinaryField(*out, i, i);
}
else
{

View File

@ -526,7 +526,7 @@ void WindowFunctionType::implicit2T(uint64_t i, T& t, int s)
}
else if (width == datatypes::MAXDECIMALWIDTH)
{
datatypes::TSInt128::assignPtrPtr(&t, fRow.getBinaryField<int128_t>(i));
datatypes::TSInt128::assignPtrPtr(&t, fRow.getTSInt128Field(i).getValPtr());
}
break;
}