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

Remove hi_val/lo_val data members from EMCasualPartition_struct

and use the union members instead.
This commit is contained in:
Gagan Goel
2020-07-27 19:22:13 -04:00
committed by Roman Nozdrin
parent 1588ebe439
commit 62c1c1e0e2
10 changed files with 135 additions and 153 deletions

View File

@ -335,8 +335,8 @@ bool LBIDList::GetMinMax(T* min, T* max, int64_t* seq,
}
else
{
*min = entry.partition.cprange.lo_val;
*max = entry.partition.cprange.hi_val;
*min = entry.partition.cprange.loVal;
*max = entry.partition.cprange.hiVal;
}
*seq = entry.partition.cprange.sequenceNum;
@ -364,8 +364,8 @@ int LBIDList::getMinMaxFromEntries(T& min, T& max, int32_t& seq,
}
else
{
min = EMEntries[i].partition.cprange.lo_val;
max = EMEntries[i].partition.cprange.hi_val;
min = EMEntries[i].partition.cprange.loVal;
max = EMEntries[i].partition.cprange.hiVal;
}
seq = EMEntries[i].partition.cprange.sequenceNum;
return EMEntries[i].partition.cprange.isValid;
@ -757,7 +757,6 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
bool scan = true;
int64_t value = 0;
__int128 bigValue = 0;
uint64_t* int128Ptr = reinterpret_cast<uint64_t*>(&bigValue);
bool bIsUnsigned = execplan::isUnsigned(ct.colDataType);
bool bIsChar = execplan::isCharType(ct.colDataType);
@ -806,15 +805,14 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
{
uint64_t val = *(int64_t*)MsgDataPtr;
value = static_cast<int64_t>(val);
break;
}
case 16:
{
unsigned __int128 val;
int128Ptr = reinterpret_cast<uint64_t*>(&val);
int128Ptr[0] = *reinterpret_cast<const uint64_t*>(MsgDataPtr);
int128Ptr[1] = *(reinterpret_cast<const uint64_t*>(MsgDataPtr) + 1);
bigValue = static_cast<__int128>(val);
uint128_t val = *(int128_t*)MsgDataPtr;
bigValue = static_cast<int128_t>(val);
break;
}
}
}
@ -847,12 +845,14 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
{
int64_t val = *(int64_t*)MsgDataPtr;
value = val;
break;
}
case 16:
{
int128Ptr[0] = *reinterpret_cast<const uint64_t*>(MsgDataPtr);
int128Ptr[1] = *(reinterpret_cast<const uint64_t*>(MsgDataPtr) + 1);
int128_t val = *(int128_t*)MsgDataPtr;
bigValue = val;
break;
}
}
}
@ -875,8 +875,8 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
{
// MCOL-1246 Trim trailing whitespace for matching so that we have
// the same as InnoDB behaviour
int64_t tMin = cpRange.lo_val;
int64_t tMax = cpRange.hi_val;
int64_t tMin = cpRange.loVal;
int64_t tMax = cpRange.hiVal;
dataconvert::DataConvert::trimWhitespace(tMin);
dataconvert::DataConvert::trimWhitespace(tMax);
@ -886,22 +886,22 @@ bool LBIDList::CasualPartitionPredicate(const BRM::EMCasualPartition_t& cpRange,
}
else if (bIsUnsigned)
{
if (ct.colWidth <= 8)
if (ct.colWidth != datatypes::MAXDECIMALWIDTH)
{
scan = compareVal(static_cast<uint64_t>(cpRange.lo_val), static_cast<uint64_t>(cpRange.hi_val), static_cast<uint64_t>(value), op, lcf);
scan = compareVal(static_cast<uint64_t>(cpRange.loVal), static_cast<uint64_t>(cpRange.hiVal), static_cast<uint64_t>(value), op, lcf);
}
else if (ct.colWidth == 16)
else
{
scan = compareVal(static_cast<unsigned __int128>(cpRange.bigLoVal), static_cast<unsigned __int128>(cpRange.bigHiVal), static_cast<unsigned __int128>(bigValue), op, lcf);
}
}
else
{
if (ct.colWidth <= 8)
if (ct.colWidth != datatypes::MAXDECIMALWIDTH)
{
scan = compareVal(cpRange.lo_val, cpRange.hi_val, value, op, lcf);
scan = compareVal(cpRange.loVal, cpRange.hiVal, value, op, lcf);
}
else if (ct.colWidth == 16)
else
{
scan = compareVal(cpRange.bigLoVal, cpRange.bigHiVal, bigValue, op, lcf);
}

View File

@ -739,8 +739,8 @@ void pColStep::sendPrimitiveMessages()
// {
//
// bool flag = lbidList->CasualPartitionPredicate(
// extents[idx].partition.cprange.lo_val,
// extents[idx].partition.cprange.hi_val,
// extents[idx].partition.cprange.loVal,
// extents[idx].partition.cprange.hiVal,
// &fFilterString,
// fFilterCount,
// fColType,
@ -749,8 +749,8 @@ void pColStep::sendPrimitiveMessages()
//#ifdef DEBUG
// if (fOid >= 3000 && flushInterval == 0)
// cout << (flag ? " will scan " : " will not scan ")
// << "extent with range " << extents[idx].partition.cprange.lo_val
// << "-" << extents[idx].partition.cprange.hi_val << endl;
// << "extent with range " << extents[idx].partition.cprange.loVal
// << "-" << extents[idx].partition.cprange.hiVal << endl;
//#endif
//
// }

View File

@ -48,8 +48,8 @@ void PseudoCCJL::runCommand(ByteStream& bs) const
{
if (!datatypes::Decimal::isWideDecimalType(colType))
{
int64_t max = extents[currentExtentIndex].partition.cprange.hi_val;
int64_t min = extents[currentExtentIndex].partition.cprange.lo_val;
int64_t max = extents[currentExtentIndex].partition.cprange.hiVal;
int64_t min = extents[currentExtentIndex].partition.cprange.loVal;
if (extents[currentExtentIndex].partition.cprange.isValid == BRM::CP_VALID && max >= min)
bs << max;
@ -75,8 +75,8 @@ void PseudoCCJL::runCommand(ByteStream& bs) const
{
if (!datatypes::Decimal::isWideDecimalType(colType))
{
int64_t max = extents[currentExtentIndex].partition.cprange.hi_val;
int64_t min = extents[currentExtentIndex].partition.cprange.lo_val;
int64_t max = extents[currentExtentIndex].partition.cprange.hiVal;
int64_t min = extents[currentExtentIndex].partition.cprange.loVal;
if (extents[currentExtentIndex].partition.cprange.isValid == BRM::CP_VALID && max >= min)
bs << min;

View File

@ -200,7 +200,7 @@ uint32_t RowEstimator::estimateDistinctValues(const execplan::CalpontSystemCatal
ret = max - min + 1;
}
if (ret > (T) fRowsPerExtent)
if (ret > fRowsPerExtent)
{
ret = fRowsPerExtent;
}
@ -251,7 +251,7 @@ float RowEstimator::estimateOpFactor(const T& min, const T& max, const T& value,
if (!datatypes::Decimal::isWideDecimalType(ct))
factor = (1.0 * max - value) / (1.0 * max - min + 1);
else
factor = (1.0 * max - value) / (1.0 * max - min + 1);
factor = ((__float128) max - value) / (max - min + 1);
}
break;
@ -264,7 +264,7 @@ float RowEstimator::estimateOpFactor(const T& min, const T& max, const T& value,
if (!datatypes::Decimal::isWideDecimalType(ct))
factor = (1.0 * max - value + 1) / (max - min + 1);
else
factor = (1.0 * max - value + 1) / (max - min + 1);
factor = ((__float128) max - value + 1) / (max - min + 1);
}
break;
@ -310,8 +310,8 @@ float RowEstimator::estimateRowReturnFactor(const BRM::EMEntry& emEntry,
// Adjust values based on column type and estimate the
if (!datatypes::Decimal::isWideDecimalType(ct))
{
adjustedMin = adjustValue(ct, emEntry.partition.cprange.lo_val);
adjustedMax = adjustValue(ct, emEntry.partition.cprange.hi_val);
adjustedMin = adjustValue(ct, emEntry.partition.cprange.loVal);
adjustedMax = adjustValue(ct, emEntry.partition.cprange.hiVal);
distinctValuesEstimate = estimateDistinctValues(
ct, adjustedMin, adjustedMax, emEntry.partition.cprange.isValid);
}
@ -452,8 +452,8 @@ float RowEstimator::estimateRowReturnFactor(const BRM::EMEntry& emEntry,
}
#if ROW_EST_DEBUG
cout << " Min-" << emEntry.partition.cprange.lo_val <<
", Max-" << emEntry.partition.cprange.hi_val <<
cout << " Min-" << emEntry.partition.cprange.loVal <<
", Max-" << emEntry.partition.cprange.hiVal <<
", Val-" << value;
#endif
@ -685,16 +685,5 @@ uint64_t RowEstimator::estimateRowsForNonCPColumn(ColumnCommandJL& colCmd)
return estimatedRows;
}
template
uint32_t RowEstimator::estimateDistinctValues<int128_t>(const execplan::CalpontSystemCatalog::ColType& ct,
const int128_t& min,
const int128_t& max,
const char cpStatus);
template
uint32_t RowEstimator::estimateDistinctValues<int64_t>(const execplan::CalpontSystemCatalog::ColType& ct,
const int64_t& min,
const int64_t& max,
const char cpStatus);
} //namespace joblist

View File

@ -1584,7 +1584,7 @@ bool TupleBPS::processSingleFilterString(int8_t BOP, int8_t colWidth, T val, con
throw logic_error("invalid column width");
}
if (colWidth < 16)
if (colWidth < datatypes::MAXDECIMALWIDTH)
thisPredicate = compareSingleValue(COP, (int64_t) val, val2);
else
thisPredicate = compareSingleValue(COP, (int128_t) val, bigVal2);
@ -1694,11 +1694,11 @@ bool TupleBPS::processPseudoColFilters(uint32_t extentIndex, boost::shared_ptr<m
&& (!hasExtentIDFilter || processOneFilterType(8, emEntry.range.start, PSEUDO_EXTENTID))
&& (!hasMaxFilter || (emEntry.partition.cprange.isValid == BRM::CP_VALID ?
(!datatypes::Decimal::isWideDecimalType(fColType) ?
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.hi_val, PSEUDO_EXTENTMAX) :
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.hiVal, PSEUDO_EXTENTMAX) :
processOneFilterType(fColType.colWidth, emEntry.partition.cprange.bigHiVal, PSEUDO_EXTENTMAX)) : true))
&& (!hasMinFilter || (emEntry.partition.cprange.isValid == BRM::CP_VALID ?
(!datatypes::Decimal::isWideDecimalType(fColType) ?
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.lo_val, PSEUDO_EXTENTMIN) :
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.loVal, PSEUDO_EXTENTMIN) :
processOneFilterType(fColType.colWidth, emEntry.partition.cprange.bigLoVal, PSEUDO_EXTENTMIN)) : true))
&& (!hasLBIDFilter || processLBIDFilter(emEntry))
;
@ -1712,11 +1712,11 @@ bool TupleBPS::processPseudoColFilters(uint32_t extentIndex, boost::shared_ptr<m
|| (hasExtentIDFilter && processOneFilterType(8, emEntry.range.start, PSEUDO_EXTENTID))
|| (hasMaxFilter && (emEntry.partition.cprange.isValid == BRM::CP_VALID ?
(!datatypes::Decimal::isWideDecimalType(fColType) ?
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.hi_val, PSEUDO_EXTENTMAX) :
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.hiVal, PSEUDO_EXTENTMAX) :
processOneFilterType(fColType.colWidth, emEntry.partition.cprange.bigHiVal, PSEUDO_EXTENTMAX)) : false))
|| (hasMinFilter && (emEntry.partition.cprange.isValid == BRM::CP_VALID ?
(!datatypes::Decimal::isWideDecimalType(fColType) ?
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.lo_val, PSEUDO_EXTENTMIN) :
processOneFilterType(emEntry.range.size, emEntry.partition.cprange.loVal, PSEUDO_EXTENTMIN) :
processOneFilterType(fColType.colWidth, emEntry.partition.cprange.bigLoVal, PSEUDO_EXTENTMIN)) : false))
|| (hasLBIDFilter && processLBIDFilter(emEntry))
;

View File

@ -1299,8 +1299,8 @@ extern "C"
else
{
output << setw(10) << "Part#"
<< setw(42) << "Min"
<< setw(42) << "Max" << "Status";
<< setw(utils::MAXLENGTH16BYTES) << "Min"
<< setw(utils::MAXLENGTH16BYTES) << "Max" << "Status";
}
int64_t maxLimit = numeric_limits<int64_t>::max();
@ -1334,7 +1334,7 @@ extern "C"
if (!datatypes::Decimal::isWideDecimalType(ct))
output << setw(30) << "N/A" << setw(30) << "N/A";
else
output << setw(42) << "N/A" << setw(42) << "N/A";
output << setw(utils::MAXLENGTH16BYTES) << "N/A" << setw(utils::MAXLENGTH16BYTES) << "N/A";
}
else
{
@ -1352,9 +1352,9 @@ extern "C"
{
if (static_cast<unsigned __int128>(partIt->second.bigMin) == ubigMaxLimit
&& static_cast<uint64_t>(partIt->second.bigMax) == ubigMinLimit)
output << setw(42) << "Empty/Null" << setw(42) << "Empty/Null";
output << setw(utils::MAXLENGTH16BYTES) << "Empty/Null" << setw(utils::MAXLENGTH16BYTES) << "Empty/Null";
else
output << setw(42) << format(partIt->second.bigMin, ct) << setw(42) << format(partIt->second.bigMax, ct);
output << setw(utils::MAXLENGTH16BYTES) << format(partIt->second.bigMin, ct) << setw(utils::MAXLENGTH16BYTES) << format(partIt->second.bigMax, ct);
}
}
else
@ -1369,9 +1369,9 @@ extern "C"
else
{
if (partIt->second.bigMin == bigMaxLimit && partIt->second.bigMax == bigMinLimit)
output << setw(42) << "Empty/Null" << setw(42) << "Empty/Null";
output << setw(utils::MAXLENGTH16BYTES) << "Empty/Null" << setw(utils::MAXLENGTH16BYTES) << "Empty/Null";
else
output << setw(42) << format(partIt->second.bigMin, ct) << setw(42) << format(partIt->second.bigMax, ct);
output << setw(utils::MAXLENGTH16BYTES) << format(partIt->second.bigMin, ct) << setw(utils::MAXLENGTH16BYTES) << format(partIt->second.bigMax, ct);
}
}
}
@ -2308,8 +2308,8 @@ extern "C"
{
output.setf(ios::left, ios::adjustfield);
output << setw(10) << "Part#"
<< setw(42) << "Min"
<< setw(42) << "Max" << "Status";
<< setw(utils::MAXLENGTH16BYTES) << "Min"
<< setw(utils::MAXLENGTH16BYTES) << "Max" << "Status";
}
noPartFound = false;
@ -2321,23 +2321,23 @@ extern "C"
if (mapit->second.status & CPINVALID)
{
output << setw(42) << "N/A" << setw(42) << "N/A";
output << setw(utils::MAXLENGTH16BYTES) << "N/A" << setw(utils::MAXLENGTH16BYTES) << "N/A";
}
else
{
if ((isUnsigned(ct.colDataType)))
{
if (static_cast<uint128_t>(mapit->second.bigMin) > static_cast<uint128_t>(mapit->second.bigMax))
output << setw(42) << "Empty/Null" << setw(42) << "Empty/Null";
output << setw(utils::MAXLENGTH16BYTES) << "Empty/Null" << setw(utils::MAXLENGTH16BYTES) << "Empty/Null";
else
output << setw(42) << format(mapit->second.bigMin, ct) << setw(42) << format(mapit->second.bigMax, ct);
output << setw(utils::MAXLENGTH16BYTES) << format(mapit->second.bigMin, ct) << setw(utils::MAXLENGTH16BYTES) << format(mapit->second.bigMax, ct);
}
else
{
if (mapit->second.bigMin > mapit->second.bigMax)
output << setw(42) << "Empty/Null" << setw(42) << "Empty/Null";
output << setw(utils::MAXLENGTH16BYTES) << "Empty/Null" << setw(utils::MAXLENGTH16BYTES) << "Empty/Null";
else
output << setw(42) << format(mapit->second.bigMin, ct) << setw(42) << format(mapit->second.bigMax, ct);
output << setw(utils::MAXLENGTH16BYTES) << format(mapit->second.bigMin, ct) << setw(utils::MAXLENGTH16BYTES) << format(mapit->second.bigMax, ct);
}
}

View File

@ -82,25 +82,25 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th
if (iter->colWid != datatypes::MAXDECIMALWIDTH)
{
if (iter->partition.cprange.lo_val == std::numeric_limits<int64_t>::max() ||
iter->partition.cprange.lo_val <= (std::numeric_limits<int64_t>::min() + 1))
if (iter->partition.cprange.loVal == std::numeric_limits<int64_t>::max() ||
iter->partition.cprange.loVal <= (std::numeric_limits<int64_t>::min() + 1))
{
table->field[4]->set_null();
}
else
{
table->field[4]->set_notnull();
table->field[4]->store(iter->partition.cprange.lo_val);
table->field[4]->store(iter->partition.cprange.loVal);
}
if (iter->partition.cprange.hi_val <= (std::numeric_limits<int64_t>::min() + 1))
if (iter->partition.cprange.hiVal <= (std::numeric_limits<int64_t>::min() + 1))
{
table->field[5]->set_null();
}
else
{
table->field[5]->set_notnull();
table->field[5]->store(iter->partition.cprange.hi_val);
table->field[5]->store(iter->partition.cprange.hiVal);
}
}
else

View File

@ -349,8 +349,8 @@ int dumpone(OID_t oid, unsigned int sortOrder)
if (iter->colWid != datatypes::MAXDECIMALWIDTH)
{
max = iter->partition.cprange.hi_val;
min = iter->partition.cprange.lo_val;
max = iter->partition.cprange.hiVal;
min = iter->partition.cprange.loVal;
cout << iter->range.start << " - " <<
(iter->range.start + lbidRangeSize - 1) <<

View File

@ -56,6 +56,7 @@ namespace bi = boost::interprocess;
#include "blocksize.h"
#include "dataconvert.h"
#include "widedecimalutils.h"
#include "mcs_decimal.h"
#include "oamcache.h"
#include "IDBDataFile.h"
#include "IDBPolicy.h"
@ -118,8 +119,6 @@ namespace BRM
EMCasualPartition_struct::EMCasualPartition_struct()
{
lo_val = numeric_limits<int64_t>::max();
hi_val = numeric_limits<int64_t>::min();
utils::int128Max(bigLoVal);
utils::int128Min(bigHiVal);
sequenceNum = 0;
@ -128,8 +127,8 @@ EMCasualPartition_struct::EMCasualPartition_struct()
EMCasualPartition_struct::EMCasualPartition_struct(const int64_t lo, const int64_t hi, const int32_t seqNum)
{
lo_val = lo;
hi_val = hi;
loVal = lo;
hiVal = hi;
sequenceNum = seqNum;
isValid = CP_INVALID;
}
@ -144,8 +143,6 @@ EMCasualPartition_struct::EMCasualPartition_struct(const __int128 bigLo, const _
EMCasualPartition_struct::EMCasualPartition_struct(const EMCasualPartition_struct& em)
{
lo_val = em.lo_val;
hi_val = em.hi_val;
bigLoVal = em.bigLoVal;
bigHiVal = em.bigHiVal;
sequenceNum = em.sequenceNum;
@ -154,8 +151,6 @@ EMCasualPartition_struct::EMCasualPartition_struct(const EMCasualPartition_struc
EMCasualPartition_struct& EMCasualPartition_struct::operator= (const EMCasualPartition_struct& em)
{
lo_val = em.lo_val;
hi_val = em.hi_val;
bigLoVal = em.bigLoVal;
bigHiVal = em.bigHiVal;
sequenceNum = em.sequenceNum;
@ -353,17 +348,21 @@ int ExtentMap::_markInvalid(const LBID_t lbid, const execplan::CalpontSystemCata
if (isUnsigned(colDataType))
{
fExtentMap[i].partition.cprange.lo_val = numeric_limits<uint64_t>::max();
fExtentMap[i].partition.cprange.hi_val = 0;
fExtentMap[i].partition.cprange.bigLoVal = -1;
fExtentMap[i].partition.cprange.bigHiVal = 0;
}
else
{
fExtentMap[i].partition.cprange.lo_val = numeric_limits<int64_t>::max();
fExtentMap[i].partition.cprange.hi_val = numeric_limits<int64_t>::min();
utils::int128Max(fExtentMap[i].partition.cprange.bigLoVal);
utils::int128Min(fExtentMap[i].partition.cprange.bigHiVal);
if (fExtentMap[i].colWid != datatypes::MAXDECIMALWIDTH)
{
fExtentMap[i].partition.cprange.loVal = numeric_limits<int64_t>::max();
fExtentMap[i].partition.cprange.hiVal = numeric_limits<int64_t>::min();
}
else
{
utils::int128Max(fExtentMap[i].partition.cprange.bigLoVal);
utils::int128Min(fExtentMap[i].partition.cprange.bigHiVal);
}
}
incSeqNum(fExtentMap[i].partition.cprange.sequenceNum);
@ -372,8 +371,8 @@ int ExtentMap::_markInvalid(const LBID_t lbid, const execplan::CalpontSystemCata
os << "ExtentMap::_markInvalid(): casual partitioning update: firstLBID=" <<
fExtentMap[i].range.start << " lastLBID=" << fExtentMap[i].range.start +
fExtentMap[i].range.size * 1024 - 1 << " OID=" << fExtentMap[i].fileID <<
" min=" << fExtentMap[i].partition.cprange.lo_val <<
" max=" << fExtentMap[i].partition.cprange.hi_val <<
" min=" << fExtentMap[i].partition.cprange.loVal <<
" max=" << fExtentMap[i].partition.cprange.hiVal <<
"seq=" << fExtentMap[i].partition.cprange.sequenceNum;
log(os.str(), logging::LOG_TYPE_DEBUG);
#endif
@ -472,7 +471,7 @@ int ExtentMap::markInvalid(const vector<LBID_t>& lbids,
/**
* @brief set the max/min values for the extent if the seqNum matches the extents sequenceNum
*
* reset the lbid's hi_val to max and lo_val to min
* reset the lbid's hiVal to max and loVal to min
* the seqNum matches the ExtentMap.sequenceNum. Then increments
* the current sequenceNum value by 1. If the sequenceNum does not
* match the seqNum value do not update the lbid's max/min values
@ -543,8 +542,8 @@ int ExtentMap::setMaxMin(const LBID_t lbid,
if (curSequence == seqNum)
{
makeUndoRecord(&fExtentMap[i], sizeof(struct EMEntry));
fExtentMap[i].partition.cprange.hi_val = max;
fExtentMap[i].partition.cprange.lo_val = min;
fExtentMap[i].partition.cprange.hiVal = max;
fExtentMap[i].partition.cprange.loVal = min;
fExtentMap[i].partition.cprange.isValid = CP_VALID;
incSeqNum(fExtentMap[i].partition.cprange.sequenceNum);
return 0;
@ -554,7 +553,7 @@ int ExtentMap::setMaxMin(const LBID_t lbid,
else if (seqNum == -1)
{
makeUndoRecord(&fExtentMap[i], sizeof(struct EMEntry));
// We set hi_val and lo_val to correct values for signed or unsigned
// We set hiVal and loVal to correct values for signed or unsigned
// during the markinvalid step, which sets the invalid variable to CP_UPDATING.
// During this step (seqNum == -1), the min and max passed in are not reliable
// and should not be used.
@ -655,8 +654,8 @@ void ExtentMap::setExtentsMaxMin(const CPMaxMinMap_t& cpMap, bool firstNode, boo
}
else
{
fExtentMap[i].partition.cprange.hi_val = it->second.max;
fExtentMap[i].partition.cprange.lo_val = it->second.min;
fExtentMap[i].partition.cprange.hiVal = it->second.max;
fExtentMap[i].partition.cprange.loVal = it->second.min;
}
fExtentMap[i].partition.cprange.isValid = CP_VALID;
incSeqNum(fExtentMap[i].partition.cprange.sequenceNum);
@ -681,7 +680,7 @@ void ExtentMap::setExtentsMaxMin(const CPMaxMinMap_t& cpMap, bool firstNode, boo
else if (it->second.seqNum == -1)
{
makeUndoRecord(&fExtentMap[i], sizeof(struct EMEntry));
// We set hi_val and lo_val to correct values for signed or unsigned
// We set hiVal and loVal to correct values for signed or unsigned
// during the markinvalid step, which sets the invalid variable to CP_UPDATING.
// During this step (seqNum == -1), the min and max passed in are not reliable
// and should not be used.
@ -700,8 +699,8 @@ void ExtentMap::setExtentsMaxMin(const CPMaxMinMap_t& cpMap, bool firstNode, boo
}
else
{
fExtentMap[i].partition.cprange.hi_val = it->second.max;
fExtentMap[i].partition.cprange.lo_val = it->second.min;
fExtentMap[i].partition.cprange.hiVal = it->second.max;
fExtentMap[i].partition.cprange.loVal = it->second.min;
}
fExtentMap[i].partition.cprange.isValid = CP_INVALID;
incSeqNum(fExtentMap[i].partition.cprange.sequenceNum);
@ -816,8 +815,8 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
os << "ExtentMap::mergeExtentsMaxMin(): casual partitioning update: firstLBID=" <<
fExtentMap[i].range.start << " lastLBID=" << fExtentMap[i].range.start +
fExtentMap[i].range.size * 1024 - 1 << " OID=" << fExtentMap[i].fileID <<
" hi_val=" << fExtentMap[i].partition.cprange.hi_val <<
" lo_val=" << fExtentMap[i].partition.cprange.lo_val <<
" hiVal=" << fExtentMap[i].partition.cprange.hiVal <<
" loVal=" << fExtentMap[i].partition.cprange.loVal <<
" min=" << it->second.min << " max=" << it->second.max <<
" seq=" << it->second.seqNum;
log(os.str(), logging::LOG_TYPE_DEBUG);
@ -845,8 +844,8 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
// min/max needs to be set instead of merged.
if (isValidCPRange(
!isBinaryColumn ? fExtentMap[i].partition.cprange.hi_val : fExtentMap[i].partition.cprange.bigHiVal,
!isBinaryColumn ? fExtentMap[i].partition.cprange.lo_val : fExtentMap[i].partition.cprange.bigLoVal,
!isBinaryColumn ? fExtentMap[i].partition.cprange.hiVal : fExtentMap[i].partition.cprange.bigHiVal,
!isBinaryColumn ? fExtentMap[i].partition.cprange.loVal : fExtentMap[i].partition.cprange.bigLoVal,
it->second.type))
{
// Swap byte order to do binary string comparison
@ -861,18 +860,18 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
int64_t oldMinVal =
static_cast<int64_t>( uint64ToStr(
static_cast<uint64_t>(
fExtentMap[i].partition.cprange.lo_val)) );
fExtentMap[i].partition.cprange.loVal)) );
int64_t oldMaxVal =
static_cast<int64_t>( uint64ToStr(
static_cast<uint64_t>(
fExtentMap[i].partition.cprange.hi_val)) );
fExtentMap[i].partition.cprange.hiVal)) );
if (newMinVal < oldMinVal)
fExtentMap[i].partition.cprange.lo_val =
fExtentMap[i].partition.cprange.loVal =
it->second.min;
if (newMaxVal > oldMaxVal)
fExtentMap[i].partition.cprange.hi_val =
fExtentMap[i].partition.cprange.hiVal =
it->second.max;
}
else if (isUnsigned(it->second.type))
@ -880,16 +879,16 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
if (!isBinaryColumn)
{
if (static_cast<uint64_t>(it->second.min) <
static_cast<uint64_t>(fExtentMap[i].partition.cprange.lo_val))
static_cast<uint64_t>(fExtentMap[i].partition.cprange.loVal))
{
fExtentMap[i].partition.cprange.lo_val =
fExtentMap[i].partition.cprange.loVal =
it->second.min;
}
if (static_cast<uint64_t>(it->second.max) >
static_cast<uint64_t>(fExtentMap[i].partition.cprange.hi_val))
static_cast<uint64_t>(fExtentMap[i].partition.cprange.hiVal))
{
fExtentMap[i].partition.cprange.hi_val =
fExtentMap[i].partition.cprange.hiVal =
it->second.max;
}
}
@ -915,13 +914,13 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
if (!isBinaryColumn)
{
if (it->second.min <
fExtentMap[i].partition.cprange.lo_val)
fExtentMap[i].partition.cprange.lo_val =
fExtentMap[i].partition.cprange.loVal)
fExtentMap[i].partition.cprange.loVal =
it->second.min;
if (it->second.max >
fExtentMap[i].partition.cprange.hi_val)
fExtentMap[i].partition.cprange.hi_val =
fExtentMap[i].partition.cprange.hiVal)
fExtentMap[i].partition.cprange.hiVal =
it->second.max;
}
else
@ -942,9 +941,9 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
{
if (!isBinaryColumn)
{
fExtentMap[i].partition.cprange.lo_val =
fExtentMap[i].partition.cprange.loVal =
it->second.min;
fExtentMap[i].partition.cprange.hi_val =
fExtentMap[i].partition.cprange.hiVal =
it->second.max;
}
else
@ -988,9 +987,9 @@ void ExtentMap::mergeExtentsMaxMin(CPMaxMinMergeMap_t& cpMap, bool useLock)
{
if (!isBinaryColumn)
{
fExtentMap[i].partition.cprange.lo_val =
fExtentMap[i].partition.cprange.loVal =
it->second.min;
fExtentMap[i].partition.cprange.hi_val =
fExtentMap[i].partition.cprange.hiVal =
it->second.max;
}
else
@ -1086,7 +1085,7 @@ bool ExtentMap::isValidCPRange(const T& max, const T& min, execplan::CalpontSyst
}
/**
* @brief retrieve the hi_val and lo_val or sequenceNum of the extent containing the LBID lbid.
* @brief retrieve the hiVal and loVal or sequenceNum of the extent containing the LBID lbid.
*
* For the extent containing the LBID lbid, return the max/min values if the extent range values
* are valid and a -1 in the seqNum parameter. If the range values are flaged as invalid
@ -1156,8 +1155,8 @@ int ExtentMap::getMaxMin(const LBID_t lbid,
}
else
{
max = fExtentMap[i].partition.cprange.hi_val;
min = fExtentMap[i].partition.cprange.lo_val;
max = fExtentMap[i].partition.cprange.hiVal;
min = fExtentMap[i].partition.cprange.loVal;
}
seqNum = fExtentMap[i].partition.cprange.sequenceNum;
isValid = fExtentMap[i].partition.cprange.isValid;
@ -1369,12 +1368,10 @@ void ExtentMap::loadVersion4or5(IDBDataFile* in, bool upgradeV4ToV5)
fExtentMap[i].dbRoot = emEntryV4.dbRoot;
fExtentMap[i].colWid = emEntryV4.colWid;
fExtentMap[i].status = emEntryV4.status;
fExtentMap[i].partition.cprange.hi_val = emEntryV4.partition.cprange.hi_val;
fExtentMap[i].partition.cprange.lo_val = emEntryV4.partition.cprange.lo_val;
fExtentMap[i].partition.cprange.hiVal = emEntryV4.partition.cprange.hi_val;
fExtentMap[i].partition.cprange.loVal = emEntryV4.partition.cprange.lo_val;
fExtentMap[i].partition.cprange.sequenceNum = emEntryV4.partition.cprange.sequenceNum;
fExtentMap[i].partition.cprange.isValid = emEntryV4.partition.cprange.isValid;
utils::int128Max(fExtentMap[i].partition.cprange.bigLoVal);
utils::int128Min(fExtentMap[i].partition.cprange.bigHiVal);
}
std::cout<<emNumElements<<" extents successfully upgraded"<<std::endl;
@ -1408,8 +1405,8 @@ void ExtentMap::loadVersion4or5(IDBDataFile* in, bool upgradeV4ToV5)
<< '\t' << emSrc[i].segmentNum
<< '\t' << emSrc[i].dbRoot
<< '\t' << emSrc[i].status
<< '\t' << emSrc[i].partition.cprange.hi_val
<< '\t' << emSrc[i].partition.cprange.lo_val
<< '\t' << emSrc[i].partition.cprange.hiVal
<< '\t' << emSrc[i].partition.cprange.loVal
<< '\t' << emSrc[i].partition.cprange.sequenceNum
<< '\t' << (int)(emSrc[i].partition.cprange.isValid)
<< endl;
@ -2763,10 +2760,10 @@ LBID_t ExtentMap::_createColumnExtent_DBroot(uint32_t size, int OID,
if (isUnsigned(colDataType))
{
if (colWidth <= 8)
if (colWidth != datatypes::MAXDECIMALWIDTH)
{
e->partition.cprange.lo_val = numeric_limits<uint64_t>::max();
e->partition.cprange.hi_val = 0;
e->partition.cprange.loVal = numeric_limits<uint64_t>::max();
e->partition.cprange.hiVal = 0;
}
else
{
@ -2776,10 +2773,10 @@ LBID_t ExtentMap::_createColumnExtent_DBroot(uint32_t size, int OID,
}
else
{
if (colWidth <= 8)
if (colWidth != datatypes::MAXDECIMALWIDTH)
{
e->partition.cprange.lo_val = numeric_limits<int64_t>::max();
e->partition.cprange.hi_val = numeric_limits<int64_t>::min();
e->partition.cprange.loVal = numeric_limits<int64_t>::max();
e->partition.cprange.hiVal = numeric_limits<int64_t>::min();
}
else
{
@ -2974,10 +2971,10 @@ LBID_t ExtentMap::_createColumnExtentExactFile(uint32_t size, int OID,
if (isUnsigned(colDataType))
{
if (colWidth <= 8)
if (colWidth != datatypes::MAXDECIMALWIDTH)
{
e->partition.cprange.lo_val = numeric_limits<uint64_t>::max();
e->partition.cprange.hi_val = 0;
e->partition.cprange.loVal = numeric_limits<uint64_t>::max();
e->partition.cprange.hiVal = 0;
}
else
{
@ -2987,10 +2984,10 @@ LBID_t ExtentMap::_createColumnExtentExactFile(uint32_t size, int OID,
}
else
{
if (colWidth <= 8)
if (colWidth != datatypes::MAXDECIMALWIDTH)
{
e->partition.cprange.lo_val = numeric_limits<int64_t>::max();
e->partition.cprange.hi_val = numeric_limits<int64_t>::min();
e->partition.cprange.loVal = numeric_limits<int64_t>::max();
e->partition.cprange.hiVal = numeric_limits<int64_t>::min();
}
else
{
@ -3179,8 +3176,6 @@ LBID_t ExtentMap::_createDictStoreExtent(uint32_t size, int OID,
e->range.size = size;
e->fileID = OID;
e->status = EXTENTUNAVAILABLE;// @bug 1911 mark extent as in process
e->partition.cprange.lo_val = numeric_limits<int64_t>::max();
e->partition.cprange.hi_val = numeric_limits<int64_t>::min();
utils::int128Max(e->partition.cprange.bigLoVal);
utils::int128Min(e->partition.cprange.bigHiVal);
e->partition.cprange.sequenceNum = 0;
@ -3271,8 +3266,8 @@ void ExtentMap::printEM(const EMEntry& em) const
<< (long) em.range.size << " OID "
<< (long) em.fileID << " offset "
<< (long) em.blockOffset
<< " LV " << em.partition.cprange.lo_val
<< " HV " << em.partition.cprange.hi_val;
<< " LV " << em.partition.cprange.loVal
<< " HV " << em.partition.cprange.hiVal;
cout << endl;
}
@ -4668,8 +4663,8 @@ void ExtentMap::setLocalHWM(int OID, uint32_t partitionNum,
os << "ExtentMap::setLocalHWM(): firstLBID=" << fExtentMap[lastExtentIndex].range.start <<
" lastLBID=" << fExtentMap[lastExtentIndex].range.start +
fExtentMap[lastExtentIndex].range.size * 1024 - 1 << " newHWM=" << fExtentMap[lastExtentIndex].HWM
<< " min=" << fExtentMap[lastExtentIndex].partition.cprange.lo_val << " max=" <<
fExtentMap[lastExtentIndex].partition.cprange.hi_val << " seq=" <<
<< " min=" << fExtentMap[lastExtentIndex].partition.cprange.loVal << " max=" <<
fExtentMap[lastExtentIndex].partition.cprange.hiVal << " seq=" <<
fExtentMap[lastExtentIndex].partition.cprange.sequenceNum << " status=";
switch (fExtentMap[lastExtentIndex].partition.cprange.isValid)
@ -4830,8 +4825,8 @@ void ExtentMap::getExtents_dbroot(int OID, vector<struct EMEntry>& entries, cons
fakeEntry.dbRoot = 1;
fakeEntry.colWid = 4;
fakeEntry.status = EXTENTAVAILABLE;
fakeEntry.partition.cprange.hi_val = numeric_limits<int64_t>::min() + 2;
fakeEntry.partition.cprange.lo_val = numeric_limits<int64_t>::max();
fakeEntry.partition.cprange.hiVal = numeric_limits<int64_t>::min() + 2;
fakeEntry.partition.cprange.loVal = numeric_limits<int64_t>::max();
fakeEntry.partition.cprange.sequenceNum = 0;
fakeEntry.partition.cprange.isValid = CP_INVALID;
entries.push_back(fakeEntry);
@ -5475,8 +5470,8 @@ void ExtentMap::lookup(OID_t OID, LBIDRange_v& ranges)
fakeEntry.dbRoot = 1;
fakeEntry.colWid = 4;
fakeEntry.status = EXTENTAVAILABLE;
fakeEntry.partition.cprange.hi_val = numeric_limits<int64_t>::min() + 2;
fakeEntry.partition.cprange.lo_val = numeric_limits<int64_t>::max();
fakeEntry.partition.cprange.hiVal = numeric_limits<int64_t>::min() + 2;
fakeEntry.partition.cprange.loVal = numeric_limits<int64_t>::max();
fakeEntry.partition.cprange.sequenceNum = 0;
fakeEntry.partition.cprange.isValid = CP_INVALID;
#endif
@ -6011,8 +6006,8 @@ void ExtentMap::dumpTo(ostream& os)
<< fExtentMap[i].dbRoot << '|'
<< fExtentMap[i].colWid << '|'
<< fExtentMap[i].status << '|'
<< fExtentMap[i].partition.cprange.hi_val << '|'
<< fExtentMap[i].partition.cprange.lo_val << '|'
<< fExtentMap[i].partition.cprange.hiVal << '|'
<< fExtentMap[i].partition.cprange.loVal << '|'
<< fExtentMap[i].partition.cprange.sequenceNum << '|'
<< (int)fExtentMap[i].partition.cprange.isValid << '|'
<< endl;

View File

@ -133,13 +133,11 @@ struct EMEntry_v4
// and max values for casual partitioning.
struct EMCasualPartition_struct
{
RangePartitionData_t hi_val; // This needs to be reinterpreted as unsigned for uint64_t column types.
RangePartitionData_t lo_val;
int32_t sequenceNum;
char isValid; //CP_INVALID - No min/max and no DML in progress. CP_UPDATING - Update in progress. CP_VALID- min/max is valid
union
{
__int128 bigLoVal;
__int128 bigLoVal; // These need to be reinterpreted as unsigned for uint64_t/uint128_t column types.
int64_t loVal;
};
union