You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-4042 cleanup after MODA
This commit is contained in:
@ -480,3 +480,83 @@ void ModaData::unserialize(messageqcpp::ByteStream& bs)
|
||||
}
|
||||
}
|
||||
|
||||
void ModaData::cleanup()
|
||||
{
|
||||
if (!fMap)
|
||||
return;
|
||||
switch ((execplan::CalpontSystemCatalog::ColDataType)fReturnType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
clear<int8_t>();
|
||||
deleteMap<int8_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
clear<int16_t>();
|
||||
deleteMap<int16_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
clear<int32_t>();
|
||||
deleteMap<int32_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
clear<int64_t>();
|
||||
deleteMap<int64_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
switch (fColWidth)
|
||||
{
|
||||
case 1:
|
||||
clear<int8_t>();
|
||||
deleteMap<int8_t>();
|
||||
break;
|
||||
case 2:
|
||||
clear<int16_t>();
|
||||
deleteMap<int16_t>();
|
||||
break;
|
||||
case 4:
|
||||
clear<int32_t>();
|
||||
deleteMap<int32_t>();
|
||||
break;
|
||||
default:
|
||||
clear<int64_t>();
|
||||
deleteMap<int64_t>();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
clear<uint8_t>();
|
||||
deleteMap<uint8_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
clear<uint16_t>();
|
||||
deleteMap<uint16_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
clear<uint32_t>();
|
||||
deleteMap<uint32_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
clear<uint64_t>();
|
||||
deleteMap<uint64_t>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
clear<float>();
|
||||
deleteMap<float>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
clear<double>();
|
||||
deleteMap<double>();
|
||||
break;
|
||||
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||
clear<long double>();
|
||||
deleteMap<long double>();
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("ModaData::unserialize with bad data type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ struct ModaData : public UserData
|
||||
modaImpl(NULL)
|
||||
{};
|
||||
|
||||
virtual ~ModaData() {}
|
||||
virtual ~ModaData() {cleanup();}
|
||||
|
||||
virtual void serialize(messageqcpp::ByteStream& bs) const;
|
||||
virtual void unserialize(messageqcpp::ByteStream& bs);
|
||||
@ -84,19 +84,26 @@ struct ModaData : public UserData
|
||||
template<class T>
|
||||
std::unordered_map<T, uint32_t>* getMap() const
|
||||
{
|
||||
if (!fMap)
|
||||
{
|
||||
throw std::runtime_error("ModaData::serialize with no map");
|
||||
}
|
||||
return (std::unordered_map<T, uint32_t>*) fMap;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void deleteMap()
|
||||
{
|
||||
if (fMap)
|
||||
{
|
||||
delete (std::unordered_map<T, uint32_t>*) fMap;
|
||||
fMap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void clear()
|
||||
{
|
||||
fSum = 0.0;
|
||||
fCount = 0;
|
||||
getMap<T>()->clear();
|
||||
if (fMap)
|
||||
getMap<T>()->clear();
|
||||
}
|
||||
|
||||
long double fSum;
|
||||
@ -110,17 +117,26 @@ private:
|
||||
// For now, copy construction is unwanted
|
||||
ModaData(UserData&);
|
||||
|
||||
void cleanup();
|
||||
|
||||
// Templated map streamers
|
||||
template<class T>
|
||||
void serializeMap(messageqcpp::ByteStream& bs) const
|
||||
{
|
||||
std::unordered_map<T, uint32_t>* map = getMap<T>();
|
||||
typename std::unordered_map<T, uint32_t>::const_iterator iter;
|
||||
bs << (uint64_t)map->size();
|
||||
for (iter = map->begin(); iter != map->end(); ++iter)
|
||||
if (map)
|
||||
{
|
||||
bs << iter->first;
|
||||
bs << iter->second;
|
||||
typename std::unordered_map<T, uint32_t>::const_iterator iter;
|
||||
bs << (uint64_t)map->size();
|
||||
for (iter = map->begin(); iter != map->end(); ++iter)
|
||||
{
|
||||
bs << iter->first;
|
||||
bs << iter->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bs << (uint64_t)0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user