Skip to content

Commit 27410da

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents c130e76 + 3e0d913 commit 27410da

File tree

70 files changed

+1768
-965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1768
-965
lines changed

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace o2::ccdb
4141
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
4242
struct HeaderObjectPair_t {
4343
std::multimap<std::string, std::string> header;
44-
o2::pmr::vector<char>* object = nullptr;
44+
std::pmr::vector<char>* object = nullptr;
4545
int counter = 0;
4646
};
4747

CCDB/include/CCDB/CcdbApi.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class CcdbApi //: public DatabaseInterface
355355

356356
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
357357
typedef struct RequestContext {
358-
o2::pmr::vector<char>& dest;
358+
std::pmr::vector<char>& dest;
359359
std::string path;
360360
std::map<std::string, std::string> const& metadata;
361361
long timestamp;
@@ -365,7 +365,7 @@ class CcdbApi //: public DatabaseInterface
365365
std::string createdNotBefore;
366366
bool considerSnapshot;
367367

368-
RequestContext(o2::pmr::vector<char>& d,
368+
RequestContext(std::pmr::vector<char>& d,
369369
std::map<std::string, std::string> const& m,
370370
std::map<std::string, std::string>& h)
371371
: dest(d), metadata(m), headers(h) {}
@@ -379,7 +379,7 @@ class CcdbApi //: public DatabaseInterface
379379

380380
void getFromSnapshot(bool createSnapshot, std::string const& path,
381381
long timestamp, std::map<std::string, std::string>& headers,
382-
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
382+
std::string& snapshotpath, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
383383
void releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, std::string const& path) const;
384384
boost::interprocess::named_semaphore* createNamedSemaphore(std::string const& path) const;
385385
static std::string determineSemaphoreName(std::string const& basedir, std::string const& objectpath);
@@ -388,22 +388,22 @@ class CcdbApi //: public DatabaseInterface
388388
static bool removeSemaphore(std::string const& name, bool remove = false);
389389
static void removeLeakingSemaphores(std::string const& basedir, bool remove = false);
390390

391-
void loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders = nullptr, bool fetchLocalMetaData = true) const;
392-
void loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
391+
void loadFileToMemory(std::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders = nullptr, bool fetchLocalMetaData = true) const;
392+
void loadFileToMemory(std::pmr::vector<char>& dest, std::string const& path,
393393
std::map<std::string, std::string> const& metadata, long timestamp,
394394
std::map<std::string, std::string>* headers, std::string const& etag,
395395
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot = true) const;
396396

397397
// Loads files from alien and cvmfs into given destination.
398-
bool loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const;
398+
bool loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string& url) const;
399399

400400
// add annotated flattened headers in the end of the blob
401-
static void appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers);
401+
static void appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers);
402402

403403
// the failure to load the file to memory is signaled by 0 size and non-0 capacity
404-
static bool isMemoryFileInvalid(const o2::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
404+
static bool isMemoryFileInvalid(const std::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
405405
template <typename T>
406-
static T* extractFromMemoryBlob(o2::pmr::vector<char>& blob)
406+
static T* extractFromMemoryBlob(std::pmr::vector<char>& blob)
407407
{
408408
auto obj = static_cast<T*>(interpretAsTMemFileAndExtract(blob.data(), blob.size(), typeid(T)));
409409
if constexpr (std::is_base_of<o2::conf::ConfigurableParam, T>::value) {
@@ -576,9 +576,6 @@ class CcdbApi //: public DatabaseInterface
576576
// convert type_info to TClass, throw on failure
577577
static TClass* tinfo2TClass(std::type_info const& tinfo);
578578

579-
// split string on delimiters and return tokens as vector
580-
std::vector<std::string> splitString(const std::string& str, const char* delimiters);
581-
582579
typedef size_t (*CurlWriteCallback)(void*, size_t, size_t, void*);
583580

584581
void initCurlOptionsForRetrieve(CURL* curlHandle, void* pointer, CurlWriteCallback writeCallback, bool followRedirect = true) const;

CCDB/src/CcdbApi.cxx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Framework/DataTakingContext.h"
2525
#include <chrono>
2626
#include <memory>
27+
#include <ranges>
2728
#include <sstream>
2829
#include <TFile.h>
2930
#include <TGrid.h>
@@ -843,7 +844,7 @@ bool CcdbApi::retrieveBlob(std::string const& path, std::string const& targetdir
843844
return false;
844845
}
845846

846-
o2::pmr::vector<char> buff;
847+
std::pmr::vector<char> buff;
847848
std::map<std::string, std::string> headers;
848849
// avoid creating snapshot via loadFileToMemory itself
849850
loadFileToMemory(buff, path, metadata, timestamp, &headers, "", createdNotAfter, createdNotBefore, false);
@@ -1665,22 +1666,13 @@ int CcdbApi::updateMetadata(std::string const& path, std::map<std::string, std::
16651666
return ret;
16661667
}
16671668

1668-
std::vector<std::string> CcdbApi::splitString(const std::string& str, const char* delimiters)
1669-
{
1670-
std::vector<std::string> tokens;
1671-
char stringForStrTok[str.length() + 1];
1672-
strcpy(stringForStrTok, str.c_str());
1673-
char* token = strtok(stringForStrTok, delimiters);
1674-
while (token != nullptr) {
1675-
tokens.emplace_back(token);
1676-
token = strtok(nullptr, delimiters);
1677-
}
1678-
return tokens;
1679-
}
1680-
16811669
void CcdbApi::initHostsPool(std::string hosts)
16821670
{
1683-
hostsPool = splitString(hosts, ",;");
1671+
hostsPool.clear();
1672+
auto splitted = hosts | std::views::transform([](char c) { return (c == ';') ? ',' : c; }) | std::views::split(',');
1673+
for (auto&& part : splitted) {
1674+
hostsPool.emplace_back(part.begin(), part.end());
1675+
}
16841676
}
16851677

16861678
std::string CcdbApi::getHostUrl(int hostIndex) const
@@ -1838,7 +1830,7 @@ void CcdbApi::removeLeakingSemaphores(std::string const& snapshotdir, bool remov
18381830

18391831
void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
18401832
long timestamp, std::map<std::string, std::string>& headers,
1841-
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
1833+
std::string& snapshotpath, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
18421834
{
18431835
if (createSnapshot) { // create named semaphore
18441836
std::string logfile = mSnapshotCachePath + "/log";
@@ -1892,7 +1884,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
18921884
std::map<std::string, std::string>* headers, std::string const& etag,
18931885
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
18941886
{
1895-
o2::pmr::vector<char> destP;
1887+
std::pmr::vector<char> destP;
18961888
destP.reserve(dest.size());
18971889
loadFileToMemory(destP, path, metadata, timestamp, headers, etag, createdNotAfter, createdNotBefore, considerSnapshot);
18981890
dest.clear();
@@ -1902,7 +1894,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
19021894
}
19031895
}
19041896

1905-
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
1897+
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, std::string const& path,
19061898
std::map<std::string, std::string> const& metadata, long timestamp,
19071899
std::map<std::string, std::string>* headers, std::string const& etag,
19081900
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
@@ -1920,7 +1912,7 @@ void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& p
19201912
vectoredLoadFileToMemory(contexts);
19211913
}
19221914

1923-
void CcdbApi::appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
1915+
void CcdbApi::appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
19241916
{
19251917
size_t hsize = getFlatHeaderSize(headers), cnt = dest.size();
19261918
dest.resize(cnt + hsize);
@@ -1985,7 +1977,7 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
19851977
}
19861978
}
19871979

1988-
bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const
1980+
bool CcdbApi::loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string& url) const
19891981
{
19901982
if (url.find("alien:/", 0) != std::string::npos) {
19911983
std::map<std::string, std::string> localHeaders;
@@ -2013,7 +2005,7 @@ bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string&
20132005
return false;
20142006
}
20152007

2016-
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
2008+
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
20172009
{
20182010
// Read file to memory as vector. For special case of the locally cached file retriev metadata stored directly in the file
20192011
constexpr size_t MaxCopySize = 0x1L << 25;

CCDB/test/testCcdbApi.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ BOOST_AUTO_TEST_CASE(multi_host_test)
560560
api.init("http://bogus-host.cern.ch,http://ccdb-test.cern.ch:8080");
561561
std::map<std::string, std::string> metadata;
562562
std::map<std::string, std::string> headers;
563-
o2::pmr::vector<char> dst;
563+
std::pmr::vector<char> dst;
564564
std::string url = "Analysis/ALICE3/Centrality";
565565
api.loadFileToMemory(dst, url, metadata, 1645780010602, &headers, "", "", "", true);
566566
BOOST_CHECK(dst.size() != 0);
@@ -572,7 +572,7 @@ BOOST_AUTO_TEST_CASE(vectored)
572572
api.init("http://ccdb-test.cern.ch:8080");
573573

574574
int TEST_SAMPLE_SIZE = 5;
575-
std::vector<o2::pmr::vector<char>> dests(TEST_SAMPLE_SIZE);
575+
std::vector<std::pmr::vector<char>> dests(TEST_SAMPLE_SIZE);
576576
std::vector<std::map<std::string, std::string>> metadatas(TEST_SAMPLE_SIZE);
577577
std::vector<std::map<std::string, std::string>> headers(TEST_SAMPLE_SIZE);
578578

CCDB/test/testCcdbApiDownloader.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ size_t writeCallbackNoLambda(void* contents, size_t size, size_t nmemb, void* ch
116116
return realsize;
117117
}
118118

119-
std::vector<CURL*> prepareAsyncHandles(size_t num, std::vector<o2::pmr::vector<char>*>& dests)
119+
std::vector<CURL*> prepareAsyncHandles(size_t num, std::vector<std::pmr::vector<char>*>& dests)
120120
{
121121
std::vector<CURL*> handles;
122122

123123
for (int i = 0; i < num; i++) {
124-
auto dest = new o2::pmr::vector<char>();
124+
auto dest = new std::pmr::vector<char>();
125125
dests.push_back(dest);
126126
CURL* curl_handle = curl_easy_init();
127127
handles.push_back(curl_handle);
@@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(asynch_schedule_test)
154154
}
155155

156156
CCDBDownloader downloader;
157-
std::vector<o2::pmr::vector<char>*> dests;
157+
std::vector<std::pmr::vector<char>*> dests;
158158
auto handles = prepareAsyncHandles(TRANSFERS, dests);
159159
size_t transfersLeft = 0;
160160

DataFormats/Headers/include/Headers/Stack.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#ifndef O2_HEADERS_STACK_H
1212
#define O2_HEADERS_STACK_H
1313

14-
#include "MemoryResources/MemoryResources.h"
1514
#include "Headers/DataHeader.h"
1615

16+
#include <memory_resource>
17+
1718
namespace o2::header
1819
{
1920
//__________________________________________________________________________________________________
@@ -32,7 +33,7 @@ namespace o2::header
3233
/// - returns a Stack ready to be shipped.
3334
struct Stack {
3435

35-
using memory_resource = o2::pmr::memory_resource;
36+
using memory_resource = std::pmr::memory_resource;
3637

3738
private:
3839
struct freeobj {
@@ -42,7 +43,7 @@ struct Stack {
4243
};
4344

4445
public:
45-
using allocator_type = fair::mq::pmr::polymorphic_allocator<std::byte>;
46+
using allocator_type = std::pmr::polymorphic_allocator<std::byte>;
4647
using value_type = std::byte;
4748
using BufferType = std::unique_ptr<value_type[], freeobj>; // this gives us proper default move semantics for free
4849

@@ -87,9 +88,9 @@ struct Stack {
8788
/// all headers must derive from BaseHeader, in addition also other stacks can be passed to ctor.
8889
template <typename FirstArgType, typename... Headers,
8990
typename std::enable_if_t<
90-
!std::is_convertible<FirstArgType, fair::mq::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
91+
!std::is_convertible<FirstArgType, std::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
9192
Stack(FirstArgType&& firstHeader, Headers&&... headers)
92-
: Stack(fair::mq::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
93+
: Stack(std::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
9394
std::forward<Headers>(headers)...)
9495
{
9596
}
@@ -140,7 +141,7 @@ struct Stack {
140141
constexpr static size_t calculateSize() { return 0; }
141142

142143
private:
143-
allocator_type allocator{fair::mq::pmr::new_delete_resource()};
144+
allocator_type allocator{std::pmr::new_delete_resource()};
144145
size_t bufferSize{0};
145146
BufferType buffer{nullptr, freeobj{allocator.resource()}};
146147

DataFormats/Headers/test/testDataHeader.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ BOOST_AUTO_TEST_CASE(headerStack_test)
314314
BOOST_CHECK(h3->secret == 42);
315315

316316
// test constructing from a buffer and an additional header
317-
using namespace fair::mq::pmr;
318-
Stack s5(new_delete_resource(), s1.data(), Stack{}, meta);
317+
Stack s5(std::pmr::new_delete_resource(), s1.data(), Stack{}, meta);
319318
BOOST_CHECK(s5.size() == s1.size() + sizeof(meta));
320319
// check if we can find the header even though there was an empty stack in the middle
321320
h3 = get<test::MetaHeader*>(s5.data());
@@ -329,7 +328,7 @@ BOOST_AUTO_TEST_CASE(headerStack_test)
329328
BOOST_CHECK(h4 == h3);
330329

331330
// let's assume we have some stack that is missing the required DataHeader at the beginning:
332-
Stack s6{new_delete_resource(), DataHeader{}, s1.data()};
331+
Stack s6{std::pmr::new_delete_resource(), DataHeader{}, s1.data()};
333332
BOOST_CHECK(s6.size() == sizeof(DataHeader) + s1.size());
334333
}
335334

DataFormats/MemoryResources/include/MemoryResources/MemoryResources.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#ifndef ALICEO2_MEMORY_RESOURCES_
2929
#define ALICEO2_MEMORY_RESOURCES_
3030

31-
#include <boost/container/pmr/memory_resource.hpp>
32-
#include <boost/container/pmr/monotonic_buffer_resource.hpp>
33-
#include <boost/container/pmr/polymorphic_allocator.hpp>
3431
#include <cstring>
3532
#include <string>
3633
#include <type_traits>
@@ -45,12 +42,8 @@
4542
namespace o2::pmr
4643
{
4744

48-
using FairMQMemoryResource = fair::mq::MemoryResource;
49-
using ChannelResource = fair::mq::ChannelResource;
50-
using namespace fair::mq::pmr;
51-
5245
template <typename ContainerT>
53-
fair::mq::MessagePtr getMessage(ContainerT&& container, FairMQMemoryResource* targetResource = nullptr)
46+
fair::mq::MessagePtr getMessage(ContainerT&& container, fair::mq::MemoryResource* targetResource = nullptr)
5447
{
5548
return fair::mq::getMessage(std::forward<ContainerT>(container), targetResource);
5649
}
@@ -60,7 +53,7 @@ fair::mq::MessagePtr getMessage(ContainerT&& container, FairMQMemoryResource* ta
6053
/// Ownership of hte message is taken. Meant to be used for transparent data adoption in containers.
6154
/// In combination with the SpectatorAllocator this is an alternative to using span, as raw memory
6255
/// (e.g. an existing buffer message) will be accessible with appropriate container.
63-
class MessageResource : public FairMQMemoryResource
56+
class MessageResource : public fair::mq::MemoryResource
6457
{
6558

6659
public:
@@ -82,7 +75,7 @@ class MessageResource : public FairMQMemoryResource
8275
size_t getNumberOfMessages() const noexcept override { return mMessageData ? 1 : 0; }
8376

8477
protected:
85-
FairMQMemoryResource* mUpstream{nullptr};
78+
fair::mq::MemoryResource* mUpstream{nullptr};
8679
size_t mMessageSize{0};
8780
void* mMessageData{nullptr};
8881
bool initialImport{true};
@@ -113,14 +106,14 @@ class MessageResource : public FairMQMemoryResource
113106

114107
// The NoConstructAllocator behaves like the normal pmr vector but does not call constructors / destructors
115108
template <typename T>
116-
class NoConstructAllocator : public fair::mq::pmr::polymorphic_allocator<T>
109+
class NoConstructAllocator : public std::pmr::polymorphic_allocator<T>
117110
{
118111
public:
119-
using fair::mq::pmr::polymorphic_allocator<T>::polymorphic_allocator;
112+
using std::pmr::polymorphic_allocator<T>::polymorphic_allocator;
120113
using propagate_on_container_move_assignment = std::true_type;
121114

122115
template <typename... Args>
123-
NoConstructAllocator(Args&&... args) : fair::mq::pmr::polymorphic_allocator<T>(std::forward<Args>(args)...)
116+
NoConstructAllocator(Args&&... args) : std::pmr::polymorphic_allocator<T>(std::forward<Args>(args)...)
124117
{
125118
}
126119

@@ -145,13 +138,13 @@ class NoConstructAllocator : public fair::mq::pmr::polymorphic_allocator<T>
145138
//__________________________________________________________________________________________________
146139
//__________________________________________________________________________________________________
147140

148-
using BytePmrAllocator = fair::mq::pmr::polymorphic_allocator<std::byte>;
141+
using BytePmrAllocator = std::pmr::polymorphic_allocator<std::byte>;
149142
template <class T>
150-
using vector = std::vector<T, fair::mq::pmr::polymorphic_allocator<T>>;
143+
using vector = std::vector<T, std::pmr::polymorphic_allocator<T>>;
151144

152145
//__________________________________________________________________________________________________
153146
/// Get the allocator associated to a transport factory
154-
inline static FairMQMemoryResource* getTransportAllocator(fair::mq::TransportFactory* factory)
147+
inline static fair::mq::MemoryResource* getTransportAllocator(fair::mq::TransportFactory* factory)
155148
{
156149
return *factory;
157150
}

0 commit comments

Comments
 (0)