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

Remove boost shared array [develop 23.02] (#2812)

* remove boost/shared_array include

* replace boost::shared_array<T> to std::shared_ptr<T[]>
This commit is contained in:
Leonid Fedorov
2023-04-17 20:56:09 +03:00
committed by GitHub
parent f1697c261e
commit 030144127e
65 changed files with 222 additions and 232 deletions

View File

@ -18,7 +18,7 @@
#pragma once
#include <string>
#include <boost/shared_array.hpp>
#include "SMLogging.h"
namespace storagemanager
@ -29,10 +29,10 @@ class CloudStorage
virtual ~CloudStorage(){};
/* These behave like syscalls. return code -1 means an error, and errno is set */
virtual int getObject(const std::string& sourceKey, const std::string& destFile, size_t* size = NULL) = 0;
virtual int getObject(const std::string& sourceKey, boost::shared_array<uint8_t>* data,
virtual int getObject(const std::string& sourceKey, std::shared_ptr<uint8_t[]>* data,
size_t* size = NULL) = 0;
virtual int putObject(const std::string& sourceFile, const std::string& destKey) = 0;
virtual int putObject(const boost::shared_array<uint8_t> data, size_t len, const std::string& destKey) = 0;
virtual int putObject(const std::shared_ptr<uint8_t[]> data, size_t len, const std::string& destKey) = 0;
virtual int deleteObject(const std::string& key) = 0;
virtual int copyObject(const std::string& sourceKey, const std::string& destKey) = 0;
virtual int exists(const std::string& key, bool* out) = 0;

View File

@ -148,7 +148,7 @@ int IOCoordinator::loadObject(int fd, uint8_t* data, off_t offset, size_t length
int IOCoordinator::loadObjectAndJournal(const char* objFilename, const char* journalFilename, uint8_t* data,
off_t offset, size_t length)
{
boost::shared_array<uint8_t> argh;
std::shared_ptr<uint8_t[]> argh;
size_t tmp = 0;
argh = mergeJournal(objFilename, journalFilename, offset, length, &tmp);
@ -259,7 +259,7 @@ ssize_t IOCoordinator::read(const char* _filename, uint8_t* data, off_t offset,
// copy data from each object + journal into the returned data
size_t count = 0;
int err;
boost::shared_array<uint8_t> mergedData;
std::shared_ptr<uint8_t[]> mergedData;
for (auto& object : relevants)
{
const auto& jit = journalFDs.find(object.key);
@ -1168,10 +1168,10 @@ const bf::path& IOCoordinator::getMetadataPath() const
// first byte after the header.
// update: had to make it also return the header; the boost json parser does not stop at either
// a null char or the end of an object.
boost::shared_array<char> seekToEndOfHeader1(int fd, size_t* _bytesRead)
std::shared_ptr<char[]> seekToEndOfHeader1(int fd, size_t* _bytesRead)
{
//::lseek(fd, 0, SEEK_SET);
boost::shared_array<char> ret(new char[100]);
std::shared_ptr<char[]> ret(new char[100]);
int err;
err = ::read(fd, ret.get(), 100);
@ -1197,12 +1197,12 @@ int IOCoordinator::mergeJournal(int objFD, int journalFD, uint8_t* buf, off_t of
throw runtime_error("IOCoordinator::mergeJournal(int, int, etc) is not implemented yet.");
}
boost::shared_array<uint8_t> IOCoordinator::mergeJournal(const char* object, const char* journal,
std::shared_ptr<uint8_t[]> IOCoordinator::mergeJournal(const char* object, const char* journal,
off_t offset, size_t len,
size_t* _bytesReadOut) const
{
int objFD, journalFD;
boost::shared_array<uint8_t> ret;
std::shared_ptr<uint8_t[]> ret;
size_t l_bytesRead = 0;
objFD = ::open(object, O_RDONLY);
@ -1263,7 +1263,7 @@ boost::shared_array<uint8_t> IOCoordinator::mergeJournal(const char* object, con
}
ScopedCloser s2(journalFD);
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
std::shared_ptr<char[]> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
stringstream ss;
ss << headertxt.get();
boost::property_tree::ptree header;
@ -1335,7 +1335,7 @@ out:
// MergeJournalInMem is a specialized version of mergeJournal(). This is currently only used by Synchronizer
// and mergeJournal(), and only for merging the whole object with the whole journal.
int IOCoordinator::mergeJournalInMem(boost::shared_array<uint8_t>& objData, size_t len,
int IOCoordinator::mergeJournalInMem(std::shared_ptr<uint8_t[]>& objData, size_t len,
const char* journalPath, size_t* _bytesReadOut) const
{
// if the journal is over some size threshold (100MB for now why not),
@ -1350,7 +1350,7 @@ int IOCoordinator::mergeJournalInMem(boost::shared_array<uint8_t>& objData, size
ScopedCloser s(journalFD);
// grab the journal header and make sure the version is 1
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
std::shared_ptr<char[]> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
stringstream ss;
ss << headertxt.get();
boost::property_tree::ptree header;
@ -1420,7 +1420,7 @@ int IOCoordinator::mergeJournalInMem(boost::shared_array<uint8_t>& objData, size
return 0;
}
int IOCoordinator::mergeJournalInMem_bigJ(boost::shared_array<uint8_t>& objData, size_t len,
int IOCoordinator::mergeJournalInMem_bigJ(std::shared_ptr<uint8_t[]>& objData, size_t len,
const char* journalPath, size_t* _bytesReadOut) const
{
size_t l_bytesRead = 0;
@ -1430,7 +1430,7 @@ int IOCoordinator::mergeJournalInMem_bigJ(boost::shared_array<uint8_t>& objData,
ScopedCloser s(journalFD);
// grab the journal header and make sure the version is 1
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
std::shared_ptr<char[]> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
stringstream ss;
ss << headertxt.get();
boost::property_tree::ptree header;

View File

@ -24,7 +24,7 @@
#include <string>
#include <boost/utility.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/shared_array.hpp>
#include <boost/filesystem.hpp>
#include "Config.h"
@ -37,7 +37,7 @@
namespace storagemanager
{
boost::shared_array<char> seekToEndOfHeader1(int fd, size_t* bytesRead);
std::shared_ptr<char[]> seekToEndOfHeader1(int fd, size_t* bytesRead);
class IOCoordinator : public boost::noncopyable
{
@ -57,16 +57,16 @@ class IOCoordinator : public boost::noncopyable
// The shared logic for merging a journal file with its base file.
// len should be set to the length of the data requested
boost::shared_array<uint8_t> mergeJournal(const char* objectPath, const char* journalPath, off_t offset,
std::shared_ptr<uint8_t[]> mergeJournal(const char* objectPath, const char* journalPath, off_t offset,
size_t len, size_t* sizeRead) const;
// this version modifies object data in memory, given the journal filename. Processes the whole object
// and whole journal file.
int mergeJournalInMem(boost::shared_array<uint8_t>& objData, size_t len, const char* journalPath,
int mergeJournalInMem(std::shared_ptr<uint8_t[]>& objData, size_t len, const char* journalPath,
size_t* sizeRead) const;
// this version of MJIM has a higher IOPS requirement and lower mem usage.
int mergeJournalInMem_bigJ(boost::shared_array<uint8_t>& objData, size_t len, const char* journalPath,
int mergeJournalInMem_bigJ(std::shared_ptr<uint8_t[]>& objData, size_t len, const char* journalPath,
size_t* sizeRead) const;
// this version takes already-open file descriptors, and an already-allocated buffer as input.

View File

@ -127,7 +127,7 @@ int LocalStorage::getObject(const string& source, const string& dest, size_t* si
return ret;
}
int LocalStorage::getObject(const std::string& sourceKey, boost::shared_array<uint8_t>* data, size_t* size)
int LocalStorage::getObject(const std::string& sourceKey, std::shared_ptr<uint8_t[]>* data, size_t* size)
{
addLatency();
@ -188,7 +188,7 @@ int LocalStorage::putObject(const string& source, const string& dest)
return ret;
}
int LocalStorage::putObject(boost::shared_array<uint8_t> data, size_t len, const string& dest)
int LocalStorage::putObject(std::shared_ptr<uint8_t[]> data, size_t len, const string& dest)
{
addLatency();

View File

@ -21,6 +21,7 @@
#include "CloudStorage.h"
#include "SMLogging.h"
#include <boost/filesystem/path.hpp>
#include <memory>
namespace storagemanager
{
@ -31,9 +32,9 @@ class LocalStorage : public CloudStorage
virtual ~LocalStorage();
int getObject(const std::string& sourceKey, const std::string& destFile, size_t* size = NULL);
int getObject(const std::string& sourceKey, boost::shared_array<uint8_t>* data, size_t* size = NULL);
int getObject(const std::string& sourceKey, std::shared_ptr<uint8_t[]>* data, size_t* size = NULL);
int putObject(const std::string& sourceFile, const std::string& destKey);
int putObject(const boost::shared_array<uint8_t> data, size_t len, const std::string& destKey);
int putObject(const std::shared_ptr<uint8_t[]> data, size_t len, const std::string& destKey);
int deleteObject(const std::string& key);
int copyObject(const std::string& sourceKey, const std::string& destKey);
int exists(const std::string& key, bool* out);

View File

@ -29,7 +29,7 @@
#include <boost/filesystem.hpp>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/json_parser.hpp>
#include <boost/shared_array.hpp>
#include <boost/format.hpp>
#include <iostream>
@ -259,7 +259,7 @@ int Replicator::addJournalEntry(const boost::filesystem::path& filename, const u
{
// read the existing header and check if max_offset needs to be updated
size_t tmp;
boost::shared_array<char> headertxt;
std::shared_ptr<char[]> headertxt;
try
{
headertxt = seekToEndOfHeader1(fd, &tmp);

View File

@ -283,7 +283,7 @@ bool S3Storage::getCredentialsFromMetadataEC2()
void S3Storage::testConnectivityAndPerms()
{
boost::shared_array<uint8_t> testObj(new uint8_t[1]);
std::shared_ptr<uint8_t[]> testObj(new uint8_t[1]);
testObj[0] = 0;
boost::uuids::uuid u = boost::uuids::random_generator()();
ostringstream oss;
@ -317,7 +317,7 @@ void S3Storage::testConnectivityAndPerms()
int S3Storage::getObject(const string& sourceKey, const string& destFile, size_t* size)
{
int fd, err;
boost::shared_array<uint8_t> data;
std::shared_ptr<uint8_t[]> data;
size_t len, count = 0;
char buf[80];
@ -353,7 +353,7 @@ int S3Storage::getObject(const string& sourceKey, const string& destFile, size_t
return 0;
}
int S3Storage::getObject(const string& _sourceKey, boost::shared_array<uint8_t>* data, size_t* size)
int S3Storage::getObject(const string& _sourceKey, std::shared_ptr<uint8_t[]>* data, size_t* size)
{
uint8_t err;
size_t len = 0;
@ -418,7 +418,7 @@ int S3Storage::getObject(const string& _sourceKey, boost::shared_array<uint8_t>*
int S3Storage::putObject(const string& sourceFile, const string& destKey)
{
boost::shared_array<uint8_t> data;
std::shared_ptr<uint8_t[]> data;
int err, fd;
size_t len, count = 0;
char buf[80];
@ -466,7 +466,7 @@ int S3Storage::putObject(const string& sourceFile, const string& destKey)
return putObject(data, len, destKey);
}
int S3Storage::putObject(const boost::shared_array<uint8_t> data, size_t len, const string& _destKey)
int S3Storage::putObject(const std::shared_ptr<uint8_t[]> data, size_t len, const string& _destKey)
{
string destKey = prefix + _destKey;
uint8_t s3err;
@ -648,7 +648,7 @@ int S3Storage::copyObject(const string& _sourceKey, const string& _destKey)
// no s3-s3 copy yet. get & put for now.
int err;
boost::shared_array<uint8_t> data;
std::shared_ptr<uint8_t[]> data;
size_t len;
err = getObject(sourceKey, &data, &len);
if (err)

View File

@ -20,6 +20,7 @@
#include <deque>
#include <string>
#include <map>
#include <memory>
#include "CloudStorage.h"
#include "libmarias3/marias3.h"
#include "Config.h"
@ -35,9 +36,9 @@ class S3Storage : public CloudStorage
virtual ~S3Storage();
int getObject(const std::string& sourceKey, const std::string& destFile, size_t* size = NULL);
int getObject(const std::string& sourceKey, boost::shared_array<uint8_t>* data, size_t* size = NULL);
int getObject(const std::string& sourceKey, std::shared_ptr<uint8_t[]>* data, size_t* size = NULL);
int putObject(const std::string& sourceFile, const std::string& destKey);
int putObject(const boost::shared_array<uint8_t> data, size_t len, const std::string& destKey);
int putObject(const std::shared_ptr<uint8_t[]> data, size_t len, const std::string& destKey);
int deleteObject(const std::string& key);
int copyObject(const std::string& sourceKey, const std::string& destKey);
int exists(const std::string& key, bool* out);

View File

@ -645,7 +645,7 @@ void Synchronizer::synchronizeWithJournal(const string& sourceFile, list<string>
}
int err;
boost::shared_array<uint8_t> data;
std::shared_ptr<uint8_t[]> data;
size_t count = 0, size = mdEntry.length, originalSize = 0;
bool oldObjIsCached = cache->exists(prefix, cloudKey);
@ -673,7 +673,7 @@ void Synchronizer::synchronizeWithJournal(const string& sourceFile, list<string>
// do any add'l alloc'ing or copying
if (size < mdEntry.length)
{
boost::shared_array<uint8_t> tmp(new uint8_t[mdEntry.length]());
std::shared_ptr<uint8_t[]> tmp(new uint8_t[mdEntry.length]());
memcpy(tmp.get(), data.get(), size);
memset(&tmp[size], 0, mdEntry.length - size);
data.swap(tmp);

View File

@ -1200,7 +1200,7 @@ bool mergeJournalTest()
int i;
IOCoordinator* ioc = IOCoordinator::get();
size_t len = 8192, tmp;
boost::shared_array<uint8_t> data = ioc->mergeJournal("test-object", "test-journal", 0, len, &tmp);
std::shared_ptr<uint8_t[]> data = ioc->mergeJournal("test-object", "test-journal", 0, len, &tmp);
assert(data);
int* idata = (int*)data.get();
for (i = 0; i < 5; i++)
@ -1767,7 +1767,7 @@ void bigMergeJournal1()
return;
}
IOCoordinator* ioc = IOCoordinator::get();
boost::shared_array<uint8_t> buf;
std::shared_ptr<uint8_t[]> buf;
size_t tmp;
buf = ioc->mergeJournal(fNamePath.string().c_str(), jNamePath.string().c_str(), 0, 68332, &tmp);
assert(buf);