Skip to content

Commit 0c957a9

Browse files
committed
Remove the header filtering & add more tests
1 parent a57e2d3 commit 0c957a9

File tree

3 files changed

+264
-149
lines changed

3 files changed

+264
-149
lines changed

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <unordered_map>
2828
#include <memory>
2929
#include <cstdlib>
30-
#include <vector>
3130

3231
class TGeoManager; // we need to forward-declare those classes which should not be cleaned up
3332

@@ -102,9 +101,9 @@ class CCDBManagerInstance
102101
/// query timestamp
103102
long getTimestamp() const { return mTimestamp; }
104103

105-
/// retrieve an object of type T from CCDB as stored under path and timestamp. Optional to get the headers. Can give a filter of headers to be saved in cache and returned (if present)
104+
/// retrieve an object of type T from CCDB as stored under path and timestamp. Optional to get the headers.
106105
template <typename T>
107-
T* getForTimeStamp(std::string const& path, long timestamp, std::map<std::string, std::string>* headers = nullptr, std::vector<std::string_view> headerFilter = {});
106+
T* getForTimeStamp(std::string const& path, long timestamp, std::map<std::string, std::string>* headers = nullptr);
108107

109108
/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run
110109
template <typename T>
@@ -236,7 +235,7 @@ class CCDBManagerInstance
236235
};
237236

238237
template <typename T>
239-
T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp, std::map<std::string, std::string>* headers, std::vector<std::string_view> headerFilter)
238+
T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp, std::map<std::string, std::string>* headers)
240239
{
241240
mHeaders.clear(); // we clear at the beginning; to allow to retrieve the header information in a subsequent call
242241
T* ptr = nullptr;
@@ -259,9 +258,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
259258
mFetchedSize += s;
260259
}
261260
}
262-
if (!headerFilter.empty()) {
263-
LOGP(warn, "Header filter ignored when caching is disabled, giving back all headers");
264-
}
261+
265262
if (headers) {
266263
*headers = mHeaders;
267264
}
@@ -278,22 +275,11 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
278275
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
279276
mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "",
280277
mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : "");
281-
282-
// Cache the headers
283-
if (headerFilter.empty()) {
284-
// No filter, cache all headers
285-
for (auto const& h : mHeaders) {
286-
cached.cacheOfHeaders[h.first] = h.second;
287-
}
288-
} else {
289-
// Cache only the asked for headers
290-
for (auto const& k : headerFilter) {
291-
auto it = mHeaders.find(std::string(k));
292-
if (it != mHeaders.end()) {
293-
cached.cacheOfHeaders.insert_or_assign(it->first, it->second); // Only want to overwrite if the header exists in the source
294-
}
295-
}
278+
// update the cached headers
279+
for (auto const& h : mHeaders) {
280+
cached.cacheOfHeaders[h.first] = h.second;
296281
}
282+
// return the cached headers
297283
if (headers) {
298284
*headers = cached.cacheOfHeaders;
299285
}
@@ -331,7 +317,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
331317
size_t s = atol(sh->second.c_str());
332318
mFetchedSize += s;
333319
cached.minSize = std::min(s, cached.minSize);
334-
cached.maxSize = std::max(s, cached.minSize); // I think this should be maxSize, not minSize
320+
cached.maxSize = std::max(s, cached.minSize);
335321
}
336322
} else if (mHeaders.count("Error")) { // in case of errors the pointer is 0 and headers["Error"] should be set
337323
cached.failures++;

CCDB/src/CcdbApi.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ bool CcdbApi::retrieveBlob(std::string const& path, std::string const& targetdir
880880

881881
updateMetaInformationInLocalFile(targetpath.c_str(), &headers, &querysummary);
882882
if (outHeaders) {
883-
*outHeaders = std::move(headers); // Re-use the same headers to give back to the callee
883+
*outHeaders = std::move(headers);
884884
}
885885
return true;
886886
}

0 commit comments

Comments
 (0)