Skip to content

Commit 618de86

Browse files
committed
Remove BLOB operations in CCDBManager
They are interferring with fetching vector<char> as object and anyway are not needed anymore since the DPL CCDB fetcher uses loadFileToMemory.
1 parent 3b8ec3f commit 618de86

2 files changed

Lines changed: 6 additions & 60 deletions

File tree

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,17 @@ class CCDBManagerInstance
4646
std::string uuid;
4747
long startvalidity = 0;
4848
long endvalidity = -1;
49-
bool isBlob = false; // is this raw blob or parsed object?
5049
bool isValid(long ts) { return ts < endvalidity && ts > startvalidity; }
5150
void clear()
5251
{
5352
objPtr.reset();
5453
uuid = "";
5554
startvalidity = 0;
5655
endvalidity = -1;
57-
isBlob = false;
5856
}
5957
};
6058

6159
public:
62-
using BLOB = std::vector<char>;
6360
using MD = std::map<std::string, std::string>;
6461

6562
CCDBManagerInstance(std::string const& path) : mCCDBAccessor{}
@@ -103,11 +100,6 @@ class CCDBManagerInstance
103100
return getForTimeStamp<T>(path, mTimestamp);
104101
}
105102

106-
/// aliases for BLOB retrieval
107-
BLOB* getBlobForTimeStamp(std::string const& path, long timestamp) { return getForTimeStamp<BLOB>(path, timestamp); }
108-
BLOB* getSpecificBlob(std::string const& path, long timestamp = -1, MD metaData = MD()) { return getSpecific<BLOB>(path, timestamp, metaData); }
109-
BLOB* getBlob(std::string const& path) { return get<BLOB>(path); }
110-
111103
bool isHostReachable() const { return mCCDBAccessor.isHostReachable(); }
112104

113105
/// clear all entries in the cache
@@ -164,10 +156,6 @@ class CCDBManagerInstance
164156
private:
165157
// method to print (fatal) error
166158
void reportFatal(std::string_view s);
167-
BLOB* createBlob(std::string const& path,
168-
MD const& metadata, long timestamp,
169-
MD* headers, std::string const& etag,
170-
const std::string& createdNotAfter, const std::string& createdNotBefore);
171159
// we access the CCDB via the CURL based C++ API
172160
o2::ccdb::CcdbApi mCCDBAccessor;
173161
std::unordered_map<std::string, CachedObject> mCache; //! map for {path, CachedObject} associations
@@ -189,53 +177,27 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
189177
{
190178
T* ptr = nullptr;
191179
if (!isCachingEnabled()) {
192-
if constexpr (std::is_same<T, BLOB>::value) {
193-
ptr = createBlob(path, mMetaData, timestamp, nullptr, "",
194-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
195-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
196-
} else {
197-
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, nullptr, "",
198-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
199-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
200-
}
180+
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, nullptr, "",
181+
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
182+
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
201183
if (!ptr && mFatalWhenNull) {
202184
reportFatal(std::string("Got nullptr from CCDB for path ") + path + std::string(" and timestamp ") + std::to_string(timestamp));
203185
}
204186
return ptr;
205187
}
206188
auto& cached = mCache[path];
207-
if constexpr (std::is_same<T, BLOB>::value) { // check if cached object type is consistent with requested one
208-
if (!cached.isBlob) {
209-
cached.clear();
210-
}
211-
} else {
212-
if (cached.isBlob) {
213-
cached.clear();
214-
}
215-
}
216189
if (mCheckObjValidityEnabled && cached.isValid(timestamp)) {
217190
return reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
218191
}
219-
if constexpr (std::is_same<T, BLOB>::value) {
220-
ptr = createBlob(path, mMetaData, timestamp, &mHeaders, cached.uuid,
221-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
222-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
223-
} else {
224-
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
225-
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
226-
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
227-
}
192+
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
193+
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
194+
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
228195
if (ptr) { // new object was shipped, old one (if any) is not valid anymore
229196
if constexpr (std::is_same<TGeoManager, T>::value) { // some special objects cannot be cached to shared_ptr since root may delete their raw global pointer
230197
cached.noCleanupPtr = ptr;
231198
} else {
232199
cached.objPtr.reset(ptr);
233200
}
234-
if constexpr (std::is_same<T, BLOB>::value) {
235-
cached.isBlob = true;
236-
} else {
237-
cached.isBlob = false;
238-
}
239201
cached.uuid = mHeaders["ETag"];
240202
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
241203
cached.endvalidity = std::stol(mHeaders["Valid-Until"]);

CCDB/src/BasicCCDBManager.cxx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@ namespace o2
2222
namespace ccdb
2323
{
2424

25-
// Create blob pointer from the vector<char> containing the CCDB file
26-
CCDBManagerInstance::BLOB* CCDBManagerInstance::createBlob(std::string const& path, MD const& metadata, long timestamp, MD* headers, std::string const& etag,
27-
const std::string& createdNotAfter, const std::string& createdNotBefore)
28-
{
29-
o2::pmr::vector<char> v;
30-
mCCDBAccessor.loadFileToMemory(v, path, metadata, timestamp, headers, etag, createdNotAfter, createdNotBefore);
31-
if ((headers && headers->count("Error")) || !v.size()) {
32-
return nullptr;
33-
}
34-
// Do a copy to avoid changing the API of createBlob, at least for now.
35-
BLOB* b = new BLOB();
36-
b->reserve(v.size());
37-
std::copy(v.begin(), v.end(), b->end());
38-
return b;
39-
}
40-
4125
void CCDBManagerInstance::setURL(std::string const& url)
4226
{
4327
mCCDBAccessor.init(url);

0 commit comments

Comments
 (0)