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
MCOL-641 Changed the hint to search for GTest headers.
This commit introduces DataConvert UTs. DataConvert::decimalToString now can negative values. Next version for Row::toString(), applyMapping UT checks. Row:equals() is now wide-DECIMAL aware.
This commit is contained in:
@ -375,6 +375,8 @@ public:
|
||||
inline uint64_t getUintField(uint32_t colIndex) const;
|
||||
template<int len> inline int64_t getIntField(uint32_t colIndex) const;
|
||||
inline int64_t getIntField(uint32_t colIndex) const;
|
||||
template<typename T>
|
||||
inline bool equals(T* value, uint32_t colIndex) const;
|
||||
template<int len> inline bool equals(uint64_t val, uint32_t colIndex) const;
|
||||
inline bool equals(long double val, uint32_t colIndex) const;
|
||||
bool equals(const std::string& val, uint32_t colIndex) const;
|
||||
@ -664,6 +666,12 @@ inline bool Row::inStringTable(uint32_t col) const
|
||||
return strings && getColumnWidth(col) >= sTableThreshold && !forceInline[col];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool Row::equals(T* value, uint32_t colIndex) const
|
||||
{
|
||||
return reinterpret_cast<T*>(&data[offsets[colIndex]]) == value;
|
||||
}
|
||||
|
||||
template<int len>
|
||||
inline bool Row::equals(uint64_t val, uint32_t colIndex) const
|
||||
{
|
||||
@ -681,8 +689,6 @@ inline bool Row::equals(uint64_t val, uint32_t colIndex) const
|
||||
|
||||
case 8:
|
||||
return *((uint64_t*) &data[offsets[colIndex]]) == val;
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::equals(): bad length.");
|
||||
@ -710,8 +716,6 @@ inline uint64_t Row::getUintField(uint32_t colIndex) const
|
||||
|
||||
case 8:
|
||||
return *((uint64_t*) &data[offsets[colIndex]]);
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
default:
|
||||
idbassert(0);
|
||||
throw std::logic_error("Row::getUintField(): bad length.");
|
||||
@ -730,8 +734,6 @@ inline uint64_t Row::getUintField(uint32_t colIndex) const
|
||||
|
||||
case 4:
|
||||
return *((uint32_t*) &data[offsets[colIndex]]);
|
||||
case 16:
|
||||
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
|
||||
case 8:
|
||||
return *((uint64_t*) &data[offsets[colIndex]]);
|
||||
|
||||
@ -1281,6 +1283,85 @@ inline uint64_t Row::hash(uint32_t lastCol) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline bool Row::equals(const Row& r2, const std::vector<uint32_t>& keyCols) const
|
||||
{
|
||||
for (uint32_t i = 0; i < keyCols.size(); i++)
|
||||
{
|
||||
const uint32_t& col = keyCols[i];
|
||||
|
||||
cscDataType columnType = getColType(i);
|
||||
|
||||
if (!isLongString(col))
|
||||
{
|
||||
if (UNLIKELY(columnType == execplan::CalpontSystemCatalog::LONGDOUBLE))
|
||||
{
|
||||
if (getLongDoubleField(i) != r2.getLongDoubleField(i))
|
||||
return false;
|
||||
}
|
||||
else if (UNLIKELY(execplan::isDecimal(columnType)))
|
||||
{
|
||||
if (getBinaryField<int128_t>(i) != r2.getBinaryField<int128_t>(i))
|
||||
return false;
|
||||
}
|
||||
else if (getUintField(col) != r2.getUintField(col))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getStringLength(col) != r2.getStringLength(col))
|
||||
return false;
|
||||
|
||||
if (memcmp(getStringPointer(col), r2.getStringPointer(col), getStringLength(col)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Row::equals(const Row& r2, uint32_t lastCol) const
|
||||
{
|
||||
// This check fires with empty r2 only.
|
||||
if (lastCol >= columnCount)
|
||||
return true;
|
||||
|
||||
if (!useStringTable && !r2.useStringTable)
|
||||
return !(memcmp(&data[offsets[0]], &r2.data[offsets[0]], offsets[lastCol + 1] - offsets[0]));
|
||||
|
||||
for (uint32_t i = 0; i <= lastCol; i++)
|
||||
{
|
||||
cscDataType columnType = getColType(i);
|
||||
if (!isLongString(i))
|
||||
{
|
||||
if (UNLIKELY(getColType(i) == execplan::CalpontSystemCatalog::LONGDOUBLE))
|
||||
{
|
||||
if (getLongDoubleField(i) != r2.getLongDoubleField(i))
|
||||
return false;
|
||||
}
|
||||
else if (UNLIKELY(execplan::isDecimal(columnType)))
|
||||
{
|
||||
if (getBinaryField<int128_t>(i) != r2.getBinaryField<int128_t>(i))
|
||||
return false;
|
||||
}
|
||||
|
||||
else if (getUintField(i) != r2.getUintField(i))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t len = getStringLength(i);
|
||||
|
||||
if (len != r2.getStringLength(i))
|
||||
return false;
|
||||
|
||||
if (memcmp(getStringPointer(i), r2.getStringPointer(i), len))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Row::equals(const Row& r2) const
|
||||
{
|
||||
return equals(r2, columnCount - 1);
|
||||
|
Reference in New Issue
Block a user