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

MCOL-641 Simple aggregates works with GROUP BY column keys.

Fixed constant colump copy for binary columns in TNS.
This commit is contained in:
Roman Nozdrin
2020-05-08 15:57:23 +00:00
parent e88cbe9bc1
commit 21a41738e1
4 changed files with 45 additions and 22 deletions

View File

@ -25,6 +25,7 @@
using int128_t = __int128; using int128_t = __int128;
using ColTypeAlias = execplan::CalpontSystemCatalog::ColType; using ColTypeAlias = execplan::CalpontSystemCatalog::ColType;
using ColDataTypeAlias = execplan::CalpontSystemCatalog::ColDataType;
namespace execplan namespace execplan
{ {
@ -166,7 +167,7 @@ class Decimal
/** /**
@brief The method detects whether decimal type is wide @brief The method detects whether decimal type is wide
using csc data type. using csc colType.
*/ */
static constexpr inline bool isWideDecimalType(const ColTypeAlias& ct) static constexpr inline bool isWideDecimalType(const ColTypeAlias& ct)
{ {
@ -185,6 +186,18 @@ class Decimal
&& precision <= INT128MAXPRECISION; && precision <= INT128MAXPRECISION;
} }
/**
@brief The method detects whether decimal type is wide
using datatype and width.
*/
static constexpr inline bool isWideDecimalType(const ColDataTypeAlias dt,
const int32_t width)
{
return (width == MAXDECIMALWIDTH &&
(dt == execplan::CalpontSystemCatalog::DECIMAL ||
dt == execplan::CalpontSystemCatalog::UDECIMAL));
}
/** /**
@brief The method sets the legacy scale and precision of a wide decimal @brief The method sets the legacy scale and precision of a wide decimal
column which is the result of an arithmetic operation. column which is the result of an arithmetic operation.

View File

@ -512,31 +512,18 @@ void TupleConstantStep::fillInConstants(const rowgroup::Row& rowIn, rowgroup::Ro
if (fIndexConst.size() > 1 || fIndexConst[0] != 0) if (fIndexConst.size() > 1 || fIndexConst[0] != 0)
{ {
copyRow(fRowConst, &rowOut); copyRow(fRowConst, &rowOut);
//memcpy(rowOut.getData(), fRowConst.getData(), fRowConst.getSize());
rowOut.setRid(rowIn.getRelRid()); rowOut.setRid(rowIn.getRelRid());
for (uint64_t j = 0; j < fIndexMapping.size(); ++j) for (uint64_t j = 0; j < fIndexMapping.size(); ++j)
rowIn.copyField(rowOut, fIndexMapping[j], j); rowIn.copyField(rowOut, fIndexMapping[j], j);
//rowIn.copyField(rowOut.getData() + rowOut.getOffset(fIndexMapping[j]), j);
} }
else // only first column is constant else // only first column is constant
{ {
//size_t n = rowOut.getOffset(rowOut.getColumnCount()) - rowOut.getOffset(1);
rowOut.setRid(rowIn.getRelRid()); rowOut.setRid(rowIn.getRelRid());
fRowConst.copyField(rowOut, 0, 0); fRowConst.copyField(rowOut, 0, 0);
//fRowConst.copyField(rowOut.getData()+2, 0); // hardcoded 2 for rid length
for (uint32_t i = 1; i < rowOut.getColumnCount(); i++) for (uint32_t i = 1; i < rowOut.getColumnCount(); i++)
// WIP MCOL-641 implement copyBinaryField inside copyField rowIn.copyField(rowOut, i, i - 1);
if (UNLIKELY(utils::isWide(rowIn.getColumnWidth(i - 1)) &&
(rowIn.getColType(i - 1) == CalpontSystemCatalog::DECIMAL ||
rowIn.getColType(i - 1) == CalpontSystemCatalog::UDECIMAL)))
rowIn.copyBinaryField(rowOut, i, i - 1);
else
rowIn.copyField(rowOut, i, i - 1);
//memcpy(rowOut.getData()+rowOut.getOffset(1), rowIn.getData()+2, n);
} }
} }

View File

@ -1298,7 +1298,7 @@ void RowAggregation::doMinMax(const Row& rowIn, int64_t colIn, int64_t colOut, i
case execplan::CalpontSystemCatalog::DECIMAL: case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL: case execplan::CalpontSystemCatalog::UDECIMAL:
{ {
if (LIKELY(fRow.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH)) if (LIKELY(rowIn.getColumnWidth(colIn) == datatypes::MAXDECIMALWIDTH))
{ {
updateIntMinMax(rowIn.getBinaryField<int128_t>(colIn), updateIntMinMax(rowIn.getBinaryField<int128_t>(colIn),
fRow.getBinaryField<int128_t>(colOut), fRow.getBinaryField<int128_t>(colOut),

View File

@ -1203,19 +1203,32 @@ inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) cons
if (UNLIKELY(types[srcIndex] == execplan::CalpontSystemCatalog::VARBINARY || if (UNLIKELY(types[srcIndex] == execplan::CalpontSystemCatalog::VARBINARY ||
types[srcIndex] == execplan::CalpontSystemCatalog::BLOB || types[srcIndex] == execplan::CalpontSystemCatalog::BLOB ||
types[srcIndex] == execplan::CalpontSystemCatalog::TEXT)) types[srcIndex] == execplan::CalpontSystemCatalog::TEXT))
{
out.setVarBinaryField(getVarBinaryStringField(srcIndex), destIndex); out.setVarBinaryField(getVarBinaryStringField(srcIndex), destIndex);
}
else if (UNLIKELY(isLongString(srcIndex))) else if (UNLIKELY(isLongString(srcIndex)))
{
out.setStringField(getStringPointer(srcIndex), getStringLength(srcIndex), destIndex); out.setStringField(getStringPointer(srcIndex), getStringLength(srcIndex), destIndex);
//out.setStringField(getStringField(srcIndex), destIndex); }
else if (UNLIKELY(isShortString(srcIndex))) else if (UNLIKELY(isShortString(srcIndex)))
{
out.setUintField(getUintField(srcIndex), destIndex); out.setUintField(getUintField(srcIndex), destIndex);
}
else if (UNLIKELY(types[srcIndex] == execplan::CalpontSystemCatalog::LONGDOUBLE)) else if (UNLIKELY(types[srcIndex] == execplan::CalpontSystemCatalog::LONGDOUBLE))
{
out.setLongDoubleField(getLongDoubleField(srcIndex), destIndex); out.setLongDoubleField(getLongDoubleField(srcIndex), destIndex);
}
else if (UNLIKELY(datatypes::Decimal::isWideDecimalType(
types[srcIndex], colWidths[srcIndex])))
{
copyBinaryField(out, destIndex, srcIndex);
}
else else
{
out.setIntField(getIntField(srcIndex), destIndex); out.setIntField(getIntField(srcIndex), destIndex);
}
} }
// WIP MCOL-641
inline void Row::copyBinaryField(Row& out, uint32_t destIndex, uint32_t srcIndex) const inline void Row::copyBinaryField(Row& out, uint32_t destIndex, uint32_t srcIndex) const
{ {
out.setBinaryField(getBinaryField<int128_t>(srcIndex), 16, destIndex); out.setBinaryField(getBinaryField<int128_t>(srcIndex), 16, destIndex);
@ -1922,20 +1935,30 @@ inline void copyRow(const Row& in, Row* out, uint32_t colCount)
in.getColTypes()[i] == execplan::CalpontSystemCatalog::BLOB || in.getColTypes()[i] == execplan::CalpontSystemCatalog::BLOB ||
in.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT || in.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT ||
in.getColTypes()[i] == execplan::CalpontSystemCatalog::CLOB)) in.getColTypes()[i] == execplan::CalpontSystemCatalog::CLOB))
{
out->setVarBinaryField(in.getVarBinaryStringField(i), i); out->setVarBinaryField(in.getVarBinaryStringField(i), i);
}
else if (UNLIKELY(in.isLongString(i))) else if (UNLIKELY(in.isLongString(i)))
//out->setStringField(in.getStringField(i), i); {
out->setStringField(in.getStringPointer(i), in.getStringLength(i), i); out->setStringField(in.getStringPointer(i), in.getStringLength(i), i);
}
else if (UNLIKELY(in.isShortString(i))) else if (UNLIKELY(in.isShortString(i)))
{
out->setUintField(in.getUintField(i), i); out->setUintField(in.getUintField(i), i);
}
else if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::LONGDOUBLE)) else if (UNLIKELY(in.getColTypes()[i] == execplan::CalpontSystemCatalog::LONGDOUBLE))
{
out->setLongDoubleField(in.getLongDoubleField(i), i); out->setLongDoubleField(in.getLongDoubleField(i), i);
else if (UNLIKELY((in.getColType(i) == execplan::CalpontSystemCatalog::DECIMAL || }
in.getColType(i) == execplan::CalpontSystemCatalog::UDECIMAL) && else if (UNLIKELY(datatypes::Decimal::isWideDecimalType(
in.getColumnWidth(i) == datatypes::MAXDECIMALWIDTH)) in.getColType(i), in.getColumnWidth(i))))
{
in.copyBinaryField(*out, i, i); in.copyBinaryField(*out, i, i);
}
else else
{
out->setIntField(in.getIntField(i), i); out->setIntField(in.getIntField(i), i);
}
} }
} }