Skip to content

Commit c3f019a

Browse files
committed
DPL CCDB: move helper class to shared header
So that I can reuse it for the analysis code.
1 parent 0364324 commit c3f019a

File tree

2 files changed

+52
-47
lines changed

2 files changed

+52
-47
lines changed

Framework/CCDBSupport/src/CCDBHelpers.cxx

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -28,55 +28,22 @@ O2_DECLARE_DYNAMIC_LOG(ccdb);
2828
namespace o2::framework
2929
{
3030

31-
struct CCDBFetcherHelper {
32-
struct CCDBCacheInfo {
33-
std::string etag;
34-
size_t cacheValidUntil = 0;
35-
size_t cachePopulatedAt = 0;
36-
size_t cacheMiss = 0;
37-
size_t cacheHit = 0;
38-
size_t minSize = -1ULL;
39-
size_t maxSize = 0;
40-
int lastCheckedTF = 0;
41-
};
42-
43-
struct RemapMatcher {
44-
std::string path;
45-
};
46-
47-
struct RemapTarget {
48-
std::string url;
49-
};
50-
51-
std::unordered_map<std::string, CCDBCacheInfo> mapURL2UUID;
52-
std::unordered_map<std::string, DataAllocator::CacheId> mapURL2DPLCache;
53-
std::string createdNotBefore = "0";
54-
std::string createdNotAfter = "3385078236000";
55-
std::unordered_map<std::string, o2::ccdb::CcdbApi> apis;
56-
std::vector<OutputRoute> routes;
57-
std::unordered_map<std::string, std::string> remappings;
58-
uint32_t lastCheckedTFCounterOrbReset = 0; // last checkecked TFcounter for bulk check
59-
int queryPeriodGlo = 1;
60-
int queryPeriodFactor = 1;
61-
int64_t timeToleranceMS = 5000;
62-
63-
o2::ccdb::CcdbApi& getAPI(const std::string& path)
64-
{
65-
// find the first = sign in the string. If present drop everything after it
66-
// and between it and the previous /.
67-
auto pos = path.find('=');
68-
if (pos == std::string::npos) {
69-
auto entry = remappings.find(path);
70-
return apis[entry == remappings.end() ? "" : entry->second];
71-
}
72-
auto pos2 = path.rfind('/', pos);
73-
if (pos2 == std::string::npos || pos2 == pos - 1 || pos2 == 0) {
74-
throw runtime_error_f("Malformed path %s", path.c_str());
75-
}
76-
auto entry = remappings.find(path.substr(0, pos2));
31+
o2::ccdb::CcdbApi& CCDBFetcherHelper::getAPI(const std::string& path)
32+
{
33+
// find the first = sign in the string. If present drop everything after it
34+
// and between it and the previous /.
35+
auto pos = path.find('=');
36+
if (pos == std::string::npos) {
37+
auto entry = remappings.find(path);
7738
return apis[entry == remappings.end() ? "" : entry->second];
7839
}
79-
};
40+
auto pos2 = path.rfind('/', pos);
41+
if (pos2 == std::string::npos || pos2 == pos - 1 || pos2 == 0) {
42+
throw runtime_error_f("Malformed path %s", path.c_str());
43+
}
44+
auto entry = remappings.find(path.substr(0, pos2));
45+
return apis[entry == remappings.end() ? "" : entry->second];
46+
}
8047

8148
bool isPrefix(std::string_view prefix, std::string_view full)
8249
{

Framework/CCDBSupport/src/CCDBHelpers.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,50 @@
1212
#define O2_FRAMEWORK_CCDBHELPERS_H_
1313

1414
#include "Framework/AlgorithmSpec.h"
15+
#include "Framework/OutputRoute.h"
16+
#include "Framework/DataAllocator.h"
17+
#include "CCDB/CcdbApi.h"
1518
#include <unordered_map>
1619
#include <string>
1720

1821
namespace o2::framework
1922
{
2023

24+
struct CCDBFetcherHelper {
25+
struct CCDBCacheInfo {
26+
std::string etag;
27+
size_t cacheValidUntil = 0;
28+
size_t cachePopulatedAt = 0;
29+
size_t cacheMiss = 0;
30+
size_t cacheHit = 0;
31+
size_t minSize = -1ULL;
32+
size_t maxSize = 0;
33+
int lastCheckedTF = 0;
34+
};
35+
36+
struct RemapMatcher {
37+
std::string path;
38+
};
39+
40+
struct RemapTarget {
41+
std::string url;
42+
};
43+
44+
std::unordered_map<std::string, CCDBCacheInfo> mapURL2UUID;
45+
std::unordered_map<std::string, DataAllocator::CacheId> mapURL2DPLCache;
46+
std::string createdNotBefore = "0";
47+
std::string createdNotAfter = "3385078236000";
48+
std::unordered_map<std::string, o2::ccdb::CcdbApi> apis;
49+
std::vector<OutputRoute> routes;
50+
std::unordered_map<std::string, std::string> remappings;
51+
uint32_t lastCheckedTFCounterOrbReset = 0; // last checkecked TFcounter for bulk check
52+
int queryPeriodGlo = 1;
53+
int queryPeriodFactor = 1;
54+
int64_t timeToleranceMS = 5000;
55+
56+
o2::ccdb::CcdbApi& getAPI(const std::string& path);
57+
};
58+
2159
struct CCDBHelpers {
2260
struct ParserResult {
2361
std::unordered_map<std::string, std::string> remappings;

0 commit comments

Comments
 (0)