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
Fixes of bugs from ASAN warnings, part one (#2796)
This commit is contained in:
@ -129,7 +129,11 @@ inline T derefFromTwoVectorPtrs(const std::vector<T>* outer, const std::vector<T
|
||||
class StringStore
|
||||
{
|
||||
public:
|
||||
StringStore();
|
||||
StringStore() = default;
|
||||
StringStore(const StringStore&) = delete;
|
||||
StringStore(StringStore&&) = delete;
|
||||
StringStore& operator=(const StringStore&) = delete;
|
||||
StringStore& operator=(StringStore&&) = delete;
|
||||
virtual ~StringStore();
|
||||
|
||||
inline std::string getString(uint64_t offset) const;
|
||||
@ -171,17 +175,14 @@ class StringStore
|
||||
|
||||
private:
|
||||
std::string empty_str;
|
||||
|
||||
StringStore(const StringStore&);
|
||||
StringStore& operator=(const StringStore&);
|
||||
static constexpr const uint32_t CHUNK_SIZE = 64 * 1024; // allocators like powers of 2
|
||||
|
||||
std::vector<boost::shared_array<uint8_t>> mem;
|
||||
|
||||
// To store strings > 64KB (BLOB/TEXT)
|
||||
std::vector<boost::shared_array<uint8_t>> longStrings;
|
||||
bool empty;
|
||||
bool fUseStoreStringMutex; //@bug6065, make StringStore::storeString() thread safe
|
||||
bool empty = true;
|
||||
bool fUseStoreStringMutex = false; //@bug6065, make StringStore::storeString() thread safe
|
||||
boost::mutex fMutex;
|
||||
};
|
||||
|
||||
@ -208,8 +209,13 @@ class UserDataStore
|
||||
};
|
||||
|
||||
public:
|
||||
UserDataStore();
|
||||
virtual ~UserDataStore();
|
||||
UserDataStore() = default;
|
||||
virtual ~UserDataStore() = default;
|
||||
UserDataStore(const UserDataStore&) = delete;
|
||||
UserDataStore(UserDataStore&&) = delete;
|
||||
UserDataStore& operator=(const UserDataStore&) = delete;
|
||||
UserDataStore& operator=(UserDataStore&&) = delete;
|
||||
|
||||
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void deserialize(messageqcpp::ByteStream&);
|
||||
@ -231,12 +237,10 @@ class UserDataStore
|
||||
boost::shared_ptr<mcsv1sdk::UserData> getUserData(uint32_t offset) const;
|
||||
|
||||
private:
|
||||
UserDataStore(const UserDataStore&);
|
||||
UserDataStore& operator=(const UserDataStore&);
|
||||
|
||||
std::vector<StoreData> vStoreData;
|
||||
|
||||
bool fUseUserDataMutex;
|
||||
bool fUseUserDataMutex = false;
|
||||
boost::mutex fMutex;
|
||||
};
|
||||
|
||||
@ -248,13 +252,16 @@ class Row;
|
||||
class RGData
|
||||
{
|
||||
public:
|
||||
RGData(); // useless unless followed by an = or a deserialize operation
|
||||
RGData() = default; // useless unless followed by an = or a deserialize operation
|
||||
RGData(const RowGroup& rg, uint32_t rowCount); // allocates memory for rowData
|
||||
explicit RGData(const RowGroup& rg);
|
||||
RGData(const RGData&);
|
||||
virtual ~RGData();
|
||||
RGData& operator=(const RGData&) = default;
|
||||
RGData& operator=(RGData&&) = default;
|
||||
RGData(const RGData&) = default;
|
||||
RGData(RGData&&) = default;
|
||||
virtual ~RGData() = default;
|
||||
|
||||
|
||||
inline RGData& operator=(const RGData&);
|
||||
|
||||
// amount should be the # returned by RowGroup::getDataSize()
|
||||
void serialize(messageqcpp::ByteStream&, uint32_t amount) const;
|
||||
@ -268,7 +275,7 @@ class RGData
|
||||
void clear();
|
||||
void reinit(const RowGroup& rg);
|
||||
void reinit(const RowGroup& rg, uint32_t rowCount);
|
||||
inline void setStringStore(boost::shared_ptr<StringStore>& ss)
|
||||
inline void setStringStore(std::shared_ptr<StringStore>& ss)
|
||||
{
|
||||
strings = ss;
|
||||
}
|
||||
@ -301,18 +308,21 @@ class RGData
|
||||
return (userDataStore ? (userDataStore->useUserDataMutex()) : false);
|
||||
}
|
||||
|
||||
boost::shared_array<uint8_t> rowData;
|
||||
boost::shared_ptr<StringStore> strings;
|
||||
boost::shared_ptr<UserDataStore> userDataStore;
|
||||
bool hasRowData() const
|
||||
{
|
||||
return !!rowData;
|
||||
}
|
||||
|
||||
private:
|
||||
// boost::shared_array<uint8_t> rowData;
|
||||
// boost::shared_ptr<StringStore> strings;
|
||||
std::shared_ptr<uint8_t[]> rowData;
|
||||
std::shared_ptr<StringStore> strings;
|
||||
std::shared_ptr<UserDataStore> userDataStore;
|
||||
|
||||
// Need sig to support backward compat. RGData can deserialize both forms.
|
||||
static const uint32_t RGDATA_SIG = 0xffffffff; // won't happen for 'old' Rowgroup data
|
||||
|
||||
friend class RowGroup;
|
||||
friend class RowGroupStorage;
|
||||
};
|
||||
|
||||
class Row
|
||||
@ -320,28 +330,26 @@ class Row
|
||||
public:
|
||||
struct Pointer
|
||||
{
|
||||
inline Pointer() : data(NULL), strings(NULL), userDataStore(NULL)
|
||||
{
|
||||
}
|
||||
inline Pointer() = default;
|
||||
|
||||
// Pointer(uint8_t*) implicitly makes old code compatible with the string table impl;
|
||||
inline Pointer(uint8_t* d) : data(d), strings(NULL), userDataStore(NULL)
|
||||
inline Pointer(uint8_t* d) : data(d)
|
||||
{
|
||||
}
|
||||
inline Pointer(uint8_t* d, StringStore* s) : data(d), strings(s), userDataStore(NULL)
|
||||
inline Pointer(uint8_t* d, StringStore* s) : data(d), strings(s)
|
||||
{
|
||||
}
|
||||
inline Pointer(uint8_t* d, StringStore* s, UserDataStore* u) : data(d), strings(s), userDataStore(u)
|
||||
{
|
||||
}
|
||||
uint8_t* data;
|
||||
StringStore* strings;
|
||||
UserDataStore* userDataStore;
|
||||
uint8_t* data = nullptr;
|
||||
StringStore* strings = nullptr;
|
||||
UserDataStore* userDataStore = nullptr;
|
||||
};
|
||||
|
||||
Row();
|
||||
Row() = default;
|
||||
Row(const Row&);
|
||||
~Row();
|
||||
~Row() = default;
|
||||
|
||||
Row& operator=(const Row&);
|
||||
bool operator==(const Row&) const;
|
||||
@ -491,7 +499,7 @@ class Row
|
||||
template <typename T>
|
||||
inline void setBinaryField_offset(const T* value, uint32_t width, uint32_t colIndex);
|
||||
// support VARBINARY
|
||||
// Add 2-byte length at the CHARSET_INFO*beginning of the field. NULL and zero length field are
|
||||
// Add 2-byte length at the CHARSET_INFO*beginning of the field. nullptr and zero length field are
|
||||
// treated the same, could use one of the length bit to distinguish these two cases.
|
||||
inline std::string getVarBinaryStringField(uint32_t colIndex) const;
|
||||
inline void setVarBinaryField(const std::string& val, uint32_t colIndex);
|
||||
@ -579,31 +587,32 @@ class Row
|
||||
|
||||
const CHARSET_INFO* getCharset(uint32_t col) const;
|
||||
|
||||
private:
|
||||
uint32_t columnCount;
|
||||
uint64_t baseRid;
|
||||
private:
|
||||
inline bool inStringTable(uint32_t col) const;
|
||||
|
||||
private:
|
||||
uint32_t columnCount = 0;
|
||||
uint64_t baseRid = 0;
|
||||
|
||||
// Note, the mem behind these pointer fields is owned by RowGroup not Row
|
||||
uint32_t* oldOffsets;
|
||||
uint32_t* stOffsets;
|
||||
uint32_t* offsets;
|
||||
uint32_t* colWidths;
|
||||
execplan::CalpontSystemCatalog::ColDataType* types;
|
||||
uint32_t* charsetNumbers;
|
||||
CHARSET_INFO** charsets;
|
||||
uint8_t* data;
|
||||
uint32_t* scale;
|
||||
uint32_t* precision;
|
||||
uint32_t* oldOffsets = nullptr;
|
||||
uint32_t* stOffsets = nullptr;
|
||||
uint32_t* offsets = nullptr;
|
||||
uint32_t* colWidths = nullptr;
|
||||
execplan::CalpontSystemCatalog::ColDataType* types = nullptr;
|
||||
uint32_t* charsetNumbers = nullptr;
|
||||
CHARSET_INFO** charsets = nullptr;
|
||||
uint8_t* data = nullptr;
|
||||
uint32_t* scale = nullptr;
|
||||
uint32_t* precision = nullptr;
|
||||
|
||||
StringStore* strings;
|
||||
bool useStringTable;
|
||||
bool hasCollation;
|
||||
bool hasLongStringField;
|
||||
uint32_t sTableThreshold;
|
||||
StringStore* strings = nullptr;
|
||||
bool useStringTable = true;
|
||||
bool hasCollation = false;
|
||||
bool hasLongStringField = false;
|
||||
uint32_t sTableThreshold = 20;
|
||||
boost::shared_array<bool> forceInline;
|
||||
inline bool inStringTable(uint32_t col) const;
|
||||
|
||||
UserDataStore* userDataStore; // For UDAF
|
||||
UserDataStore* userDataStore = nullptr; // For UDAF
|
||||
|
||||
friend class RowGroup;
|
||||
};
|
||||
@ -1478,9 +1487,6 @@ class RowGroup : public messageqcpp::Serializeable
|
||||
inline bool usesStringTable() const;
|
||||
inline void setUseStringTable(bool);
|
||||
|
||||
// RGData *convertToInlineData(uint64_t *size = NULL) const; // caller manages the memory returned by
|
||||
// this void convertToInlineDataInPlace(); RGData *convertToStringTable(uint64_t *size = NULL)
|
||||
// const; void convertToStringTableInPlace();
|
||||
void serializeRGData(messageqcpp::ByteStream&) const;
|
||||
inline uint32_t getStringTableThreshold() const;
|
||||
|
||||
@ -1516,17 +1522,17 @@ class RowGroup : public messageqcpp::Serializeable
|
||||
const uint16_t& blockNum);
|
||||
inline void getLocation(uint32_t* partNum, uint16_t* segNum, uint8_t* extentNum, uint16_t* blockNum);
|
||||
|
||||
inline void setStringStore(boost::shared_ptr<StringStore>);
|
||||
inline void setStringStore(std::shared_ptr<StringStore>);
|
||||
|
||||
const CHARSET_INFO* getCharset(uint32_t col);
|
||||
|
||||
private:
|
||||
uint32_t columnCount;
|
||||
uint8_t* data;
|
||||
uint32_t columnCount = 0;
|
||||
uint8_t* data = nullptr;
|
||||
|
||||
std::vector<uint32_t> oldOffsets; // inline data offsets
|
||||
std::vector<uint32_t> stOffsets; // string table offsets
|
||||
uint32_t* offsets; // offsets either points to oldOffsets or stOffsets
|
||||
uint32_t* offsets = nullptr; // offsets either points to oldOffsets or stOffsets
|
||||
std::vector<uint32_t> colWidths;
|
||||
// oids: the real oid of the column, may have duplicates with alias.
|
||||
// This oid is necessary for front-end to decide the real column width.
|
||||
@ -1544,12 +1550,12 @@ class RowGroup : public messageqcpp::Serializeable
|
||||
std::vector<uint32_t> precision;
|
||||
|
||||
// string table impl
|
||||
RGData* rgData;
|
||||
StringStore* strings; // note, strings and data belong to rgData
|
||||
bool useStringTable;
|
||||
bool hasCollation;
|
||||
bool hasLongStringField;
|
||||
uint32_t sTableThreshold;
|
||||
RGData* rgData = nullptr;
|
||||
StringStore* strings = nullptr; // note, strings and data belong to rgData
|
||||
bool useStringTable = true;
|
||||
bool hasCollation = false;
|
||||
bool hasLongStringField = false;
|
||||
uint32_t sTableThreshold = 20;
|
||||
boost::shared_array<bool> forceInline;
|
||||
|
||||
static const uint32_t headerSize = 18;
|
||||
@ -1586,7 +1592,7 @@ every row, they're a measurable performance penalty */
|
||||
inline uint32_t RowGroup::getRowCount() const
|
||||
{
|
||||
// idbassert(data);
|
||||
// if (!data) throw std::logic_error("RowGroup::getRowCount(): data is NULL!");
|
||||
// if (!data) throw std::logic_error("RowGroup::getRowCount(): data is nullptr!");
|
||||
return *((uint32_t*)&data[rowCountOffset]);
|
||||
}
|
||||
|
||||
@ -1617,8 +1623,8 @@ inline void RowGroup::getRow(uint32_t rowNum, Row* r) const
|
||||
inline void RowGroup::setData(uint8_t* d)
|
||||
{
|
||||
data = d;
|
||||
strings = NULL;
|
||||
rgData = NULL;
|
||||
strings = nullptr;
|
||||
rgData = nullptr;
|
||||
setUseStringTable(false);
|
||||
}
|
||||
|
||||
@ -1652,7 +1658,7 @@ inline void RowGroup::setUseStringTable(bool b)
|
||||
offsets = &oldOffsets[0];
|
||||
|
||||
if (!useStringTable)
|
||||
strings = NULL;
|
||||
strings = nullptr;
|
||||
}
|
||||
|
||||
inline uint64_t RowGroup::getBaseRid() const
|
||||
@ -1712,7 +1718,7 @@ inline uint32_t RowGroup::getRowSizeWithStrings() const
|
||||
|
||||
inline uint64_t RowGroup::getSizeWithStrings(uint64_t n) const
|
||||
{
|
||||
if (strings == NULL)
|
||||
if (strings == nullptr)
|
||||
return getDataSize(n);
|
||||
else
|
||||
return getDataSize(n) + strings->getSize();
|
||||
@ -1836,7 +1842,7 @@ inline uint32_t RowGroup::getStringTableThreshold() const
|
||||
return sTableThreshold;
|
||||
}
|
||||
|
||||
inline void RowGroup::setStringStore(boost::shared_ptr<StringStore> ss)
|
||||
inline void RowGroup::setStringStore(std::shared_ptr<StringStore> ss)
|
||||
{
|
||||
if (useStringTable)
|
||||
{
|
||||
@ -2031,7 +2037,7 @@ inline bool StringStore::isNullValue(uint64_t off) const
|
||||
if (off == std::numeric_limits<uint64_t>::max())
|
||||
return true;
|
||||
|
||||
// Long strings won't be NULL
|
||||
// Long strings won't be nullptr
|
||||
if (off & 0x8000000000000000)
|
||||
return false;
|
||||
|
||||
@ -2054,7 +2060,7 @@ inline bool StringStore::isNullValue(uint64_t off) const
|
||||
if ((offset + length) > mc->currentSize)
|
||||
return true;
|
||||
|
||||
if (mc->data[offset + 4] == 0) // "" = NULL string for some reason...
|
||||
if (mc->data[offset + 4] == 0) // "" = nullptr string for some reason...
|
||||
return true;
|
||||
return (memcmp(&mc->data[offset + 4], joblist::CPNULLSTRMARK.c_str(), 8) == 0);
|
||||
}
|
||||
@ -2121,14 +2127,6 @@ inline uint64_t StringStore::getSize() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline RGData& RGData::operator=(const RGData& r)
|
||||
{
|
||||
rowData = r.rowData;
|
||||
strings = r.strings;
|
||||
userDataStore = r.userDataStore;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void RGData::getRow(uint32_t num, Row* row)
|
||||
{
|
||||
uint32_t size = row->getSize();
|
||||
|
Reference in New Issue
Block a user