1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-641 1. Add support for int128_t in ParsedColumnFilter.

2. Set Decimal precision in SimpleColumn::evaluate().
3. Add support for int128_t in ConstantColumn.
4. Set IDB_Decimal::s128Value in buildDecimalColumn().
5. Use width 16 as first if predicate for branching based on decimal width.
This commit is contained in:
Gagan Goel
2020-03-13 15:42:25 -04:00
committed by Roman Nozdrin
parent 0bd172cd6e
commit 74b64eb4f1
21 changed files with 348 additions and 238 deletions

View File

@ -23,7 +23,6 @@
namespace utils
{
const uint8_t MAXLEGACYWIDTH = 8ULL;
const uint8_t MAXCOLUMNWIDTH = 16ULL;
inline bool isWide(uint8_t width)
{

View File

@ -391,29 +391,21 @@ void number_int_value(const string& data,
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
if (ct.colWidth == 1)
if (LIKELY(ct.colWidth == 16))
{
if (intVal < MIN_TINYINT)
int128_t tmp;
utils::int128Min(tmp);
if (intVal < tmp + 2) // + 2 for NULL and EMPTY values
{
intVal = MIN_TINYINT;
pushwarning = true;
}
else if (intVal > MAX_TINYINT)
{
intVal = MAX_TINYINT;
intVal = tmp + 2;
pushwarning = true;
}
}
else if (ct.colWidth == 2)
else if (ct.colWidth == 8)
{
if (intVal < MIN_SMALLINT)
if (intVal < MIN_BIGINT)
{
intVal = MIN_SMALLINT;
pushwarning = true;
}
else if (intVal > MAX_SMALLINT)
{
intVal = MAX_SMALLINT;
intVal = MIN_BIGINT;
pushwarning = true;
}
}
@ -430,21 +422,29 @@ void number_int_value(const string& data,
pushwarning = true;
}
}
else if (ct.colWidth == 8)
else if (ct.colWidth == 2)
{
if (intVal < MIN_BIGINT)
if (intVal < MIN_SMALLINT)
{
intVal = MIN_BIGINT;
intVal = MIN_SMALLINT;
pushwarning = true;
}
else if (intVal > MAX_SMALLINT)
{
intVal = MAX_SMALLINT;
pushwarning = true;
}
}
else if (ct.colWidth == 16)
else if (ct.colWidth == 1)
{
int128_t tmp;
utils::int128Min(tmp);
if (intVal < tmp + 2) // + 2 for NULL and EMPTY values
if (intVal < MIN_TINYINT)
{
intVal = tmp + 2;
intVal = MIN_TINYINT;
pushwarning = true;
}
else if (intVal > MAX_TINYINT)
{
intVal = MAX_TINYINT;
pushwarning = true;
}
}
@ -1469,31 +1469,31 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
break;
case CalpontSystemCatalog::DECIMAL:
if (colType.colWidth == 1)
if (LIKELY(colType.colWidth == 16))
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (char) val64;
}
else if (colType.colWidth == 2)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (short) val64;
}
else if (colType.colWidth == 4)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (int) val64;
int128_t val128;
number_int_value(data, colType, pushWarning, noRoundup, val128);
value = (int128_t) val128;
}
else if (colType.colWidth == 8)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (long long) val64;
}
else if (colType.colWidth == 16)
else if (colType.colWidth == 4)
{
int128_t val128;
number_int_value(data, colType, pushWarning, noRoundup, val128);
value = (int128_t) val128;
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (int) val64;
}
else if (colType.colWidth == 2)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (short) val64;
}
else if (colType.colWidth == 1)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
value = (char) val64;
}
//else if (colType.colWidth == 32)
// value = data;
@ -1503,29 +1503,29 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
case CalpontSystemCatalog::UDECIMAL:
// UDECIMAL numbers may not be negative
if (colType.colWidth == 1)
if (LIKELY(colType.colWidth == 16))
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
char ival = (char) val64;
int128_t val128;
number_int_value(data, colType, pushWarning, noRoundup, val128);
if (ival < 0 &&
ival != static_cast<int8_t>(joblist::TINYINTEMPTYROW) &&
ival != static_cast<int8_t>(joblist::TINYINTNULL))
if (val128 < 0 &&
!utils::isWideDecimalNullValue(val128) &&
!utils::isWideDecimalEmptyValue(val128))
{
ival = 0;
val128 = 0;
pushWarning = true;
}
value = ival;
value = val128;
}
else if (colType.colWidth == 2)
else if (colType.colWidth == 8)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
short ival = (short) val64;
long long ival = static_cast<long long>(val64);
if (ival < 0 &&
ival != static_cast<int16_t>(joblist::SMALLINTEMPTYROW) &&
ival != static_cast<int16_t>(joblist::SMALLINTNULL))
ival != static_cast<long long>(joblist::BIGINTEMPTYROW) &&
ival != static_cast<long long>(joblist::BIGINTNULL))
{
ival = 0;
pushWarning = true;
@ -1548,14 +1548,14 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
value = ival;
}
else if (colType.colWidth == 8)
else if (colType.colWidth == 2)
{
number_int_value(data, colType, pushWarning, noRoundup, val64);
long long ival = static_cast<long long>(val64);
short ival = (short) val64;
if (ival < 0 &&
ival != static_cast<long long>(joblist::BIGINTEMPTYROW) &&
ival != static_cast<long long>(joblist::BIGINTNULL))
ival != static_cast<int16_t>(joblist::SMALLINTEMPTYROW) &&
ival != static_cast<int16_t>(joblist::SMALLINTNULL))
{
ival = 0;
pushWarning = true;
@ -1563,20 +1563,20 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
value = ival;
}
else if (colType.colWidth == 16)
else if (colType.colWidth == 1)
{
int128_t val128;
number_int_value(data, colType, pushWarning, noRoundup, val128);
number_int_value(data, colType, pushWarning, noRoundup, val64);
char ival = (char) val64;
if (val128 < 0 &&
!utils::isWideDecimalNullValue(val128) &&
!utils::isWideDecimalEmptyValue(val128))
if (ival < 0 &&
ival != static_cast<int8_t>(joblist::TINYINTEMPTYROW) &&
ival != static_cast<int8_t>(joblist::TINYINTNULL))
{
val128 = 0;
ival = 0;
pushWarning = true;
}
value = val128;
value = ival;
}
break;
@ -1865,31 +1865,31 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
if (colType.colWidth == CalpontSystemCatalog::ONE_BYTE)
if (LIKELY(colType.colWidth == 16))
{
char tinyintvalue = joblist::TINYINTNULL;
value = tinyintvalue;
}
else if (colType.colWidth == CalpontSystemCatalog::TWO_BYTE)
{
short smallintvalue = joblist::SMALLINTNULL;
value = smallintvalue;
}
else if (colType.colWidth == CalpontSystemCatalog::FOUR_BYTE)
{
int intvalue = joblist::INTNULL;
value = intvalue;
int128_t val;
utils::setWideDecimalNullValue(val);
value = val;
}
else if (colType.colWidth == CalpontSystemCatalog::EIGHT_BYTE)
{
long long eightbyte = joblist::BIGINTNULL;
value = eightbyte;
}
else if (colType.colWidth == 16)
else if (colType.colWidth == CalpontSystemCatalog::FOUR_BYTE)
{
int128_t val;
utils::setWideDecimalNullValue(val);
value = val;
int intvalue = joblist::INTNULL;
value = intvalue;
}
else if (colType.colWidth == CalpontSystemCatalog::TWO_BYTE)
{
short smallintvalue = joblist::SMALLINTNULL;
value = smallintvalue;
}
else if (colType.colWidth == CalpontSystemCatalog::ONE_BYTE)
{
char tinyintvalue = joblist::TINYINTNULL;
value = tinyintvalue;
}
else
{

View File

@ -1147,7 +1147,7 @@ void TupleJoiner::updateCPData(const Row& r)
}
}
}
else if (r.getColumnWidth(colIdx) == utils::MAXCOLUMNWIDTH
else if (r.getColumnWidth(colIdx) == datatypes::MAXDECIMALWIDTH
&& (r.getColType(colIdx) == CalpontSystemCatalog::DECIMAL
|| r.getColType(colIdx) == CalpontSystemCatalog::UDECIMAL))
{

View File

@ -639,9 +639,9 @@ string Row::toString() const
break;
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
if (colWidths[i] == utils::MAXCOLUMNWIDTH)
if (colWidths[i] == datatypes::MAXDECIMALWIDTH)
{
unsigned int buflen = precision[i] + 3;
unsigned int buflen = utils::MAXLENGTH16BYTES;
char *buf = (char*)alloca(buflen);
// empty the buffer
dataconvert::DataConvert::decimalToString(getBinaryField<int128_t>(i),

View File

@ -1235,7 +1235,7 @@ inline void Row::copyField(Row& out, uint32_t destIndex, uint32_t srcIndex) cons
// WIP MCOL-641
inline void Row::copyBinaryField(Row& out, uint32_t destIndex, uint32_t srcIndex) const
{
out.setBinaryField<int128_t>(getBinaryField<int128_t>(srcIndex), 16, destIndex);
out.setBinaryField(getBinaryField<int128_t>(srcIndex), 16, destIndex);
}
inline void Row::setRid(uint64_t rid)