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
replace boost::shared_array<T> to std::shared_ptr<T[]>
This commit is contained in:
@ -31,13 +31,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#define FIXEDALLOCATOR_DLLEXPORT
|
||||
#include "fixedallocator.h"
|
||||
#undef FIXEDALLOCATOR_DLLEXPORT
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
namespace utils
|
||||
{
|
||||
@ -75,7 +75,7 @@ void FixedAllocator::setAllocSize(uint allocSize)
|
||||
|
||||
void FixedAllocator::newBlock()
|
||||
{
|
||||
shared_array<uint8_t> next;
|
||||
std::shared_ptr<uint8_t[]> next;
|
||||
|
||||
capacityRemaining = elementCount * elementSize;
|
||||
|
||||
|
@ -93,7 +93,7 @@ class FixedAllocator
|
||||
private:
|
||||
void newBlock();
|
||||
|
||||
std::vector<boost::shared_array<uint8_t> > mem;
|
||||
std::vector<std::shared_ptr<uint8_t[]>> mem;
|
||||
unsigned long capacityRemaining;
|
||||
uint64_t elementCount;
|
||||
unsigned long elementSize;
|
||||
|
@ -24,10 +24,11 @@
|
||||
//#define NDEBUG
|
||||
#include <cassert>
|
||||
|
||||
|
||||
#include "poolallocator.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
|
||||
namespace utils
|
||||
{
|
||||
@ -51,7 +52,7 @@ void PoolAllocator::deallocateAll()
|
||||
|
||||
void PoolAllocator::newBlock()
|
||||
{
|
||||
shared_array<uint8_t> next;
|
||||
std::shared_ptr<uint8_t[]> next;
|
||||
|
||||
capacityRemaining = allocSize;
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@ -89,7 +90,7 @@ class PoolAllocator
|
||||
void* allocOOB(uint64_t size);
|
||||
|
||||
unsigned allocSize;
|
||||
std::vector<boost::shared_array<uint8_t> > mem;
|
||||
std::vector<std::shared_ptr<uint8_t[]>> mem;
|
||||
bool tmpSpace;
|
||||
unsigned capacityRemaining;
|
||||
uint64_t memUsage;
|
||||
@ -99,7 +100,7 @@ class PoolAllocator
|
||||
|
||||
struct OOBMemInfo
|
||||
{
|
||||
boost::shared_array<uint8_t> mem;
|
||||
std::shared_ptr<uint8_t[]> mem;
|
||||
uint64_t size;
|
||||
};
|
||||
typedef std::map<void*, OOBMemInfo> OutOfBandMap;
|
||||
|
@ -913,14 +913,14 @@ void TupleJoiner::setInUM(vector<RGData>& rgs)
|
||||
}
|
||||
}
|
||||
|
||||
void TupleJoiner::setPMJoinResults(boost::shared_array<vector<uint32_t>> jr, uint32_t threadID)
|
||||
void TupleJoiner::setPMJoinResults(std::shared_ptr<vector<uint32_t>[]> jr, uint32_t threadID)
|
||||
{
|
||||
pmJoinResults[threadID] = jr;
|
||||
}
|
||||
|
||||
void TupleJoiner::markMatches(uint32_t threadID, uint32_t rowCount)
|
||||
{
|
||||
boost::shared_array<vector<uint32_t>> matches = pmJoinResults[threadID];
|
||||
std::shared_ptr<vector<uint32_t>[]> matches = pmJoinResults[threadID];
|
||||
uint32_t i, j;
|
||||
|
||||
for (i = 0; i < rowCount; i++)
|
||||
@ -946,7 +946,7 @@ void TupleJoiner::markMatches(uint32_t threadID, const vector<Row::Pointer>& mat
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_array<std::vector<uint32_t>> TupleJoiner::getPMJoinArrays(uint32_t threadID)
|
||||
std::shared_ptr<std::vector<uint32_t>[]> TupleJoiner::getPMJoinArrays(uint32_t threadID)
|
||||
{
|
||||
return pmJoinResults[threadID];
|
||||
}
|
||||
@ -954,7 +954,7 @@ boost::shared_array<std::vector<uint32_t>> TupleJoiner::getPMJoinArrays(uint32_t
|
||||
void TupleJoiner::setThreadCount(uint32_t cnt)
|
||||
{
|
||||
threadCount = cnt;
|
||||
pmJoinResults.reset(new boost::shared_array<vector<uint32_t>>[cnt]);
|
||||
pmJoinResults.reset(new std::shared_ptr<vector<uint32_t>[]>[cnt]);
|
||||
smallRow.reset(new Row[cnt]);
|
||||
|
||||
for (uint32_t i = 0; i < cnt; i++)
|
||||
|
@ -321,8 +321,8 @@ class TupleJoiner
|
||||
void umJoinConvert(size_t begin, size_t end);
|
||||
|
||||
void setThreadCount(uint32_t cnt);
|
||||
void setPMJoinResults(boost::shared_array<std::vector<uint32_t> >, uint32_t threadID);
|
||||
boost::shared_array<std::vector<uint32_t> > getPMJoinArrays(uint32_t threadID);
|
||||
void setPMJoinResults(std::shared_ptr<std::vector<uint32_t>[]>, uint32_t threadID);
|
||||
std::shared_ptr<std::vector<uint32_t>[]> getPMJoinArrays(uint32_t threadID);
|
||||
std::vector<rowgroup::Row::Pointer>* getSmallSide()
|
||||
{
|
||||
return &rows;
|
||||
@ -502,10 +502,10 @@ class TupleJoiner
|
||||
the logical block being processed. There are X threads at once, so
|
||||
up to X logical blocks being processed. For each of those there's a vector
|
||||
of matches. Each match is an index into 'rows'. */
|
||||
boost::shared_array<boost::shared_array<std::vector<uint32_t> > > pmJoinResults;
|
||||
std::shared_ptr<std::shared_ptr<std::vector<uint32_t>[]>[]> pmJoinResults;
|
||||
rowgroup::RowGroup smallRG, largeRG;
|
||||
boost::scoped_array<rowgroup::Row> smallRow;
|
||||
// boost::shared_array<uint8_t> smallNullMemory;
|
||||
|
||||
rowgroup::Row smallNullRow;
|
||||
|
||||
enum JoinAlg
|
||||
@ -517,7 +517,7 @@ class TupleJoiner
|
||||
};
|
||||
JoinAlg joinAlg;
|
||||
joblist::JoinType joinType;
|
||||
boost::shared_array<boost::shared_ptr<utils::PoolAllocator> > _pool; // pools for the table and nodes
|
||||
std::shared_ptr<boost::shared_ptr<utils::PoolAllocator>[]> _pool; // pools for the table and nodes
|
||||
uint32_t threadCount;
|
||||
std::string tableName;
|
||||
|
||||
|
@ -152,17 +152,17 @@ void ByteStream::growBuf(uint32_t toSize)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<boost::shared_array<uint8_t>>& ByteStream::getLongStrings()
|
||||
std::vector<std::shared_ptr<uint8_t[]>>& ByteStream::getLongStrings()
|
||||
{
|
||||
return longStrings;
|
||||
}
|
||||
|
||||
const std::vector<boost::shared_array<uint8_t>>& ByteStream::getLongStrings() const
|
||||
const std::vector<std::shared_ptr<uint8_t[]>>& ByteStream::getLongStrings() const
|
||||
{
|
||||
return longStrings;
|
||||
}
|
||||
|
||||
void ByteStream::setLongStrings(const std::vector<boost::shared_array<uint8_t>>& other)
|
||||
void ByteStream::setLongStrings(const std::vector<std::shared_ptr<uint8_t[]>>& other)
|
||||
{
|
||||
longStrings = other;
|
||||
}
|
||||
|
@ -444,9 +444,9 @@ class ByteStream : public Serializeable
|
||||
3 * sizeof(uint32_t); // space for the BS magic & length & number of long strings.
|
||||
|
||||
// Methods to get and set `long strings`.
|
||||
EXPORT std::vector<boost::shared_array<uint8_t>>& getLongStrings();
|
||||
EXPORT const std::vector<boost::shared_array<uint8_t>>& getLongStrings() const;
|
||||
EXPORT void setLongStrings(const std::vector<boost::shared_array<uint8_t>>& other);
|
||||
EXPORT std::vector<std::shared_ptr<uint8_t[]>>& getLongStrings();
|
||||
EXPORT const std::vector<std::shared_ptr<uint8_t[]>>& getLongStrings() const;
|
||||
EXPORT void setLongStrings(const std::vector<std::shared_ptr<uint8_t[]>>& other);
|
||||
|
||||
friend class ::ByteStreamTestSuite;
|
||||
|
||||
@ -478,7 +478,7 @@ class ByteStream : public Serializeable
|
||||
uint8_t* fCurOutPtr; // the point in fBuf where data is extracted from next
|
||||
uint32_t fMaxLen; // how big fBuf is currently
|
||||
// Stores `long strings`.
|
||||
std::vector<boost::shared_array<uint8_t>> longStrings;
|
||||
std::vector<std::shared_ptr<uint8_t[]>> longStrings;
|
||||
};
|
||||
|
||||
template <int W, typename T = void>
|
||||
|
@ -515,7 +515,7 @@ const SBS InetStreamSocket::read(const struct ::timespec* timeout, bool* isTimeO
|
||||
return SBS(new ByteStream(0));
|
||||
res->advanceInputPtr(msglen);
|
||||
|
||||
std::vector<boost::shared_array<uint8_t>> longStrings;
|
||||
std::vector<std::shared_ptr<uint8_t[]>> longStrings;
|
||||
try
|
||||
{
|
||||
for (uint32_t i = 0; i < longStringSize; ++i)
|
||||
@ -527,7 +527,7 @@ const SBS InetStreamSocket::read(const struct ::timespec* timeout, bool* isTimeO
|
||||
return SBS(new ByteStream(0));
|
||||
|
||||
// Allocate new memory for the `long string`.
|
||||
boost::shared_array<uint8_t> longString(
|
||||
std::shared_ptr<uint8_t[]> longString(
|
||||
new uint8_t[sizeof(rowgroup::StringStore::MemChunk) + memChunk.currentSize]);
|
||||
|
||||
uint8_t* longStringData = longString.get();
|
||||
|
@ -607,7 +607,7 @@ void RowAggregation::setJoinRowGroups(vector<RowGroup>* pSmallSideRG, RowGroup*
|
||||
fSmallSideRGs = pSmallSideRG;
|
||||
fLargeSideRG = pLargeSideRG;
|
||||
fSmallSideCount = fSmallSideRGs->size();
|
||||
fSmallMappings.reset(new shared_array<int>[fSmallSideCount]);
|
||||
fSmallMappings.reset(new std::shared_ptr<int[]>[fSmallSideCount]);
|
||||
|
||||
for (uint32_t i = 0; i < fSmallSideCount; i++)
|
||||
fSmallMappings[i] = makeMapping((*fSmallSideRGs)[i], fRowGroupIn);
|
||||
|
@ -335,7 +335,7 @@ struct GroupConcat
|
||||
uint64_t fSize;
|
||||
|
||||
RowGroup fRowGroup;
|
||||
boost::shared_array<int> fMapping;
|
||||
std::shared_ptr<int[]> fMapping;
|
||||
std::vector<std::pair<int, bool>> fOrderCond; // position to order by [asc/desc]
|
||||
joblist::ResourceManager* fRm; // resource manager
|
||||
boost::shared_ptr<int64_t> fSessionMemLimit;
|
||||
@ -586,8 +586,8 @@ class RowAggregation : public messageqcpp::Serializeable
|
||||
// for support PM aggregation after PM hashjoin
|
||||
std::vector<RowGroup>* fSmallSideRGs;
|
||||
RowGroup* fLargeSideRG;
|
||||
boost::shared_array<boost::shared_array<int>> fSmallMappings;
|
||||
boost::shared_array<int> fLargeMapping;
|
||||
std::shared_ptr<std::shared_ptr<int[]>[]> fSmallMappings;
|
||||
std::shared_ptr<int[]> fLargeMapping;
|
||||
uint32_t fSmallSideCount;
|
||||
boost::scoped_array<Row> rowSmalls;
|
||||
|
||||
|
@ -33,7 +33,6 @@ using namespace std;
|
||||
|
||||
|
||||
#include <numeric>
|
||||
using namespace boost;
|
||||
|
||||
#include "bytestream.h"
|
||||
using namespace messageqcpp;
|
||||
@ -97,7 +96,7 @@ uint64_t StringStore::storeString(const uint8_t* data, uint32_t len)
|
||||
|
||||
if ((len + 4) >= CHUNK_SIZE)
|
||||
{
|
||||
shared_array<uint8_t> newOne(new uint8_t[len + sizeof(MemChunk) + 4]);
|
||||
std::shared_ptr<uint8_t[]> newOne(new uint8_t[len + sizeof(MemChunk) + 4]);
|
||||
longStrings.push_back(newOne);
|
||||
lastMC = (MemChunk*)longStrings.back().get();
|
||||
lastMC->capacity = lastMC->currentSize = len + 4;
|
||||
@ -114,7 +113,7 @@ uint64_t StringStore::storeString(const uint8_t* data, uint32_t len)
|
||||
// mem usage debugging
|
||||
// if (lastMC)
|
||||
// cout << "Memchunk efficiency = " << lastMC->currentSize << "/" << lastMC->capacity << endl;
|
||||
shared_array<uint8_t> newOne(new uint8_t[CHUNK_SIZE + sizeof(MemChunk)]);
|
||||
std::shared_ptr<uint8_t[]> newOne(new uint8_t[CHUNK_SIZE + sizeof(MemChunk)]);
|
||||
mem.push_back(newOne);
|
||||
lastMC = (MemChunk*)mem.back().get();
|
||||
lastMC->currentSize = 0;
|
||||
@ -196,8 +195,8 @@ void StringStore::deserialize(ByteStream& bs)
|
||||
|
||||
void StringStore::clear()
|
||||
{
|
||||
vector<shared_array<uint8_t> > emptyv;
|
||||
vector<shared_array<uint8_t> > emptyv2;
|
||||
vector<std::shared_ptr<uint8_t[]> > emptyv;
|
||||
vector<std::shared_ptr<uint8_t[]> > emptyv2;
|
||||
mem.swap(emptyv);
|
||||
longStrings.swap(emptyv2);
|
||||
empty = true;
|
||||
@ -1325,9 +1324,9 @@ string RowGroup::toString(const std::vector<uint64_t>& used) const
|
||||
return os.str();
|
||||
}
|
||||
|
||||
boost::shared_array<int> makeMapping(const RowGroup& r1, const RowGroup& r2)
|
||||
std::shared_ptr<int[]> makeMapping(const RowGroup& r1, const RowGroup& r2)
|
||||
{
|
||||
shared_array<int> ret(new int[r1.getColumnCount()]);
|
||||
std::shared_ptr<int[]> ret(new int[r1.getColumnCount()]);
|
||||
// bool reserved[r2.getColumnCount()];
|
||||
bool* reserved = (bool*)alloca(r2.getColumnCount() * sizeof(bool));
|
||||
uint32_t i, j;
|
||||
@ -1352,7 +1351,7 @@ boost::shared_array<int> makeMapping(const RowGroup& r1, const RowGroup& r2)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void applyMapping(const boost::shared_array<int>& mapping, const Row& in, Row* out)
|
||||
void applyMapping(const std::shared_ptr<int[]>& mapping, const Row& in, Row* out)
|
||||
{
|
||||
applyMapping(mapping.get(), in, out);
|
||||
}
|
||||
@ -1397,7 +1396,7 @@ void applyMapping(const int* mapping, const Row& in, Row* out)
|
||||
|
||||
RowGroup& RowGroup::operator+=(const RowGroup& rhs)
|
||||
{
|
||||
boost::shared_array<bool> tmp;
|
||||
std::shared_ptr<bool[]> tmp;
|
||||
uint32_t i, j;
|
||||
// not appendable if data is set
|
||||
assert(!data);
|
||||
|
@ -183,10 +183,10 @@ class StringStore
|
||||
std::string empty_str;
|
||||
static constexpr const uint32_t CHUNK_SIZE = 64 * 1024; // allocators like powers of 2
|
||||
|
||||
std::vector<boost::shared_array<uint8_t>> mem;
|
||||
std::vector<std::shared_ptr<uint8_t[]>> mem;
|
||||
|
||||
// To store strings > 64KB (BLOB/TEXT)
|
||||
std::vector<boost::shared_array<uint8_t>> longStrings;
|
||||
std::vector<std::shared_ptr<uint8_t[]>> longStrings;
|
||||
bool empty = true;
|
||||
bool fUseStoreStringMutex = false; //@bug6065, make StringStore::storeString() thread safe
|
||||
boost::mutex fMutex;
|
||||
@ -628,7 +628,7 @@ private:
|
||||
bool hasCollation = false;
|
||||
bool hasLongStringField = false;
|
||||
uint32_t sTableThreshold = 20;
|
||||
boost::shared_array<bool> forceInline;
|
||||
std::shared_ptr<bool[]> forceInline;
|
||||
UserDataStore* userDataStore = nullptr; // For UDAF
|
||||
|
||||
friend class RowGroup;
|
||||
@ -1521,7 +1521,7 @@ class RowGroup : public messageqcpp::Serializeable
|
||||
inline std::vector<execplan::CalpontSystemCatalog::ColDataType>& getColTypes();
|
||||
inline const std::vector<uint32_t>& getCharsetNumbers() const;
|
||||
inline uint32_t getCharsetNumber(uint32_t colIndex) const;
|
||||
inline boost::shared_array<bool>& getForceInline();
|
||||
inline std::shared_ptr<bool[]>& getForceInline();
|
||||
static inline uint32_t getHeaderSize()
|
||||
{
|
||||
return headerSize;
|
||||
@ -1613,7 +1613,7 @@ class RowGroup : public messageqcpp::Serializeable
|
||||
bool hasCollation = false;
|
||||
bool hasLongStringField = false;
|
||||
uint32_t sTableThreshold = 20;
|
||||
boost::shared_array<bool> forceInline;
|
||||
std::shared_ptr<bool[]> forceInline;
|
||||
|
||||
static const uint32_t headerSize = 18;
|
||||
static const uint32_t rowCountOffset = 0;
|
||||
@ -1639,8 +1639,8 @@ inline uint64_t getFileRelativeRid(uint64_t baseRid);
|
||||
*/
|
||||
RowGroup operator+(const RowGroup& lhs, const RowGroup& rhs);
|
||||
|
||||
boost::shared_array<int> makeMapping(const RowGroup& r1, const RowGroup& r2);
|
||||
void applyMapping(const boost::shared_array<int>& mapping, const Row& in, Row* out);
|
||||
std::shared_ptr<int[]> makeMapping(const RowGroup& r1, const RowGroup& r2);
|
||||
void applyMapping(const std::shared_ptr<int[]>& mapping, const Row& in, Row* out);
|
||||
void applyMapping(const std::vector<int>& mapping, const Row& in, Row* out);
|
||||
void applyMapping(const int* mapping, const Row& in, Row* out);
|
||||
|
||||
@ -1863,7 +1863,7 @@ inline const std::vector<uint32_t>& RowGroup::getColWidths() const
|
||||
return colWidths;
|
||||
}
|
||||
|
||||
inline boost::shared_array<bool>& RowGroup::getForceInline()
|
||||
inline std::shared_ptr<bool[]>& RowGroup::getForceInline()
|
||||
{
|
||||
return forceInline;
|
||||
}
|
||||
|
Reference in New Issue
Block a user