#include <CrestFunctions.h>
|
| CrestFunctions (const std::string &crest_path) |
|
const std::string & | getURLBase () |
|
void | setURLBase (const std::string &crest_path) |
|
std::string | extractHashFromJson (const std::string &jsonReply) |
|
std::vector< IovHashPair > | getIovsForTag (const std::string &tag, uint64_t since, uint64_t until) |
|
std::string | getLastHashForTag (const std::string &tag) |
|
std::string | getPayloadForHash (const std::string &hash) |
|
std::string | folderDescriptionForTag (const std::string &tag) |
|
std::string | extractDescriptionFromJson (const std::string &jsonReply) |
|
std::map< std::string, std::string > | getGlobalTagMap (const std::string &globaltag) |
|
nlohmann::json | getTagInfo (const std::string &tag) |
|
nlohmann::json | getTagProperties (const std::string &tag) |
|
std::string | getTagInfoElement (nlohmann::json tag_info, const std::string &key) |
|
std::pair< std::vector< cool::ChannelId >, std::vector< std::string > > | extractChannelListFromString (const std::string &chanString) |
|
std::vector< uint64_t > | getIovGroups (const std::string &tag) |
|
std::pair< uint64_t, uint64_t > | getSinceUntilPair (const std::vector< uint64_t > &v, const uint64_t since, const uint64_t until) |
|
int | getTagSize (const std::string &tagname) |
|
std::pair< uint64_t, uint64_t > | getIovInterval (const std::string &tag, const uint64_t since, const uint64_t until) |
|
Definition at line 30 of file CrestFunctions.h.
◆ CrestFunctions()
IOVDbNamespace::CrestFunctions::CrestFunctions |
( |
const std::string & |
crest_path | ) |
|
Definition at line 22 of file CrestFunctions.cxx.
25 const std::string prefix1 =
"http://";
26 const std::string prefix2 =
"https://";
27 if (crest_path.starts_with(prefix1) || crest_path.starts_with(prefix2)){
◆ extractChannelListFromString()
std::pair< std::vector< cool::ChannelId >, std::vector< std::string > > IOVDbNamespace::CrestFunctions::extractChannelListFromString |
( |
const std::string & |
chanString | ) |
|
Definition at line 199 of file CrestFunctions.cxx.
200 std::vector<cool::ChannelId>
list;
201 std::vector<std::string>
names;
205 for (
int i = 0;
i <=
n;
i++) {
207 for (
auto& [
key,
val] : j_object.items()){
208 list.push_back(std::stoll(
key));
214 auto isEmpty=[](
const std::string &
s){
return s.empty();};
216 return std::make_pair(std::move(
list), std::move(
names));
◆ extractDescriptionFromJson()
std::string IOVDbNamespace::CrestFunctions::extractDescriptionFromJson |
( |
const std::string & |
jsonReply | ) |
|
Definition at line 101 of file CrestFunctions.cxx.
104 const std::string_view signature=
"node_description\\\":\\\"";
105 const auto signaturePosition = jsonReply.find(signature);
106 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
107 const auto startOfDescription= signaturePosition + signature.size();
108 const std::string_view endSignature =
"\\\",\\\"payload_spec";
109 const auto endOfDescription=jsonReply.find(endSignature);
110 if (endOfDescription == std::string::npos)
throw std::runtime_error(
"end signature "+std::string(endSignature)+
" not found");
111 const auto len=endOfDescription-startOfDescription;
112 description=jsonReply.substr(startOfDescription, len);
114 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the description in "<<jsonReply<<std::endl;
◆ extractHashFromJson()
std::string IOVDbNamespace::CrestFunctions::extractHashFromJson |
( |
const std::string & |
jsonReply | ) |
|
Definition at line 47 of file CrestFunctions.cxx.
50 std::string_view signature=
"payloadHash\":\"";
51 auto signaturePosition=jsonReply.rfind(signature);
52 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
53 auto startOfHash=signaturePosition + signature.size();
54 auto endOfHash=jsonReply.find(
'\"',startOfHash);
55 auto len=endOfHash-startOfHash;
56 if (startOfHash > jsonReply.size())
throw std::runtime_error(
"Hash start is beyond end of string");
57 hash=jsonReply.substr(startOfHash, len);
59 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the hash in "<<jsonReply<<std::endl;
◆ folderDescriptionForTag()
std::string IOVDbNamespace::CrestFunctions::folderDescriptionForTag |
( |
const std::string & |
tag | ) |
|
◆ getGlobalTagMap()
std::map< std::string, std::string > IOVDbNamespace::CrestFunctions::getGlobalTagMap |
( |
const std::string & |
globaltag | ) |
|
Definition at line 133 of file CrestFunctions.cxx.
134 std::map<std::string, std::string> tagmap;
140 for (
int i = 0;
i <
n;
i++ ){
142 if (j_item.contains(
"label") && j_item.contains(
"tagName") ){
143 tagmap[j_item[
"label"]] = j_item[
"tagName"];
147 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a global tag map for " <<
globaltag << std::endl;
◆ getIovGroups()
std::vector< uint64_t > IOVDbNamespace::CrestFunctions::getIovGroups |
( |
const std::string & |
tag | ) |
|
Definition at line 227 of file CrestFunctions.cxx.
228 std::vector<uint64_t>
v;
233 v.emplace_back(item_iov.since);
236 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
◆ getIovInterval()
std::pair< uint64_t, uint64_t > IOVDbNamespace::CrestFunctions::getIovInterval |
( |
const std::string & |
tag, |
|
|
const uint64_t |
since, |
|
|
const uint64_t |
until |
|
) |
| |
◆ getIovsForTag()
std::vector< IovHashPair > IOVDbNamespace::CrestFunctions::getIovsForTag |
( |
const std::string & |
tag, |
|
|
uint64_t |
since, |
|
|
uint64_t |
until |
|
) |
| |
Definition at line 293 of file CrestFunctions.cxx.
294 std::vector<IovHashPair> iovHashPairs;
298 if (iovNumber <=1000) {
299 dto =
m_crestCl->selectIovs(
tag, 0, -1, 0, 10000, 0,
"id.since:ASC");
302 if (s_time == 0 && u_time == 0){
305 dto =
m_crestCl->selectIovs(
tag, s_time, u_time, 0, 10000, 0,
"id.since:ASC");
309 std::map<uint64_t, std::string> hashmap;
311 hashmap[
item.since] =
item.payloadHash;
313 for (
auto&
t : hashmap){
317 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
◆ getLastHashForTag()
std::string IOVDbNamespace::CrestFunctions::getLastHashForTag |
( |
const std::string & |
tag | ) |
|
Definition at line 66 of file CrestFunctions.cxx.
69 std::string reply =
"";
76 reply = iov_list.dump();
78 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
◆ getPayloadForHash()
std::string IOVDbNamespace::CrestFunctions::getPayloadForHash |
( |
const std::string & |
hash | ) |
|
Definition at line 86 of file CrestFunctions.cxx.
87 std::string reply =
"";
92 std::cerr<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the payload"<<std::endl;
◆ getResources()
◆ getSinceUntilPair()
std::pair< uint64_t, uint64_t > IOVDbNamespace::CrestFunctions::getSinceUntilPair |
( |
const std::vector< uint64_t > & |
v, |
|
|
const uint64_t |
since, |
|
|
const uint64_t |
until |
|
) |
| |
Definition at line 244 of file CrestFunctions.cxx.
247 std::pair<uint64_t,uint64_t> answer = std::make_pair(0,0);
250 std::cerr <<
"Wrong since/until." << std::endl;
255 for (
int i = 0;
i <
N;
i++) {
262 for (
int i = 0;
i <
N;
i++) {
269 answer = std::make_pair(new_since,new_until);
◆ getTagInfo()
Definition at line 154 of file CrestFunctions.cxx.
159 if (meta_info.contains(
"tagInfo")){
160 std::string metainf = meta_info[
"tagInfo"];
166 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a tag meta info " <<
tag << std::endl;
◆ getTagInfoElement()
std::string IOVDbNamespace::CrestFunctions::getTagInfoElement |
( |
nlohmann::json |
tag_info, |
|
|
const std::string & |
key |
|
) |
| |
Definition at line 183 of file CrestFunctions.cxx.
184 if (tag_info.contains(
key)){
185 if (
key ==
"channel_list"){
186 return tag_info[
key].dump();
187 }
else if (
key==
"node_description"){
189 tag_info[
key].get_to(
v);
◆ getTagProperties()
Definition at line 172 of file CrestFunctions.cxx.
177 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a tag Properties of " <<
tag << std::endl;
◆ getTagSize()
int IOVDbNamespace::CrestFunctions::getTagSize |
( |
const std::string & |
tagname | ) |
|
Definition at line 274 of file CrestFunctions.cxx.
279 std::cerr<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get the tag size for " <<
tagname << std::endl;
◆ getURLBase()
const std::string & IOVDbNamespace::CrestFunctions::getURLBase |
( |
| ) |
|
◆ setURLBase()
void IOVDbNamespace::CrestFunctions::setURLBase |
( |
const std::string & |
crest_path | ) |
|
◆ m_CREST_PATH
std::string IOVDbNamespace::CrestFunctions::m_CREST_PATH = "" |
|
private |
◆ m_crestCl
The documentation for this class was generated from the following files: