#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) |
|
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 24 of file CrestFunctions.cxx.
27 const std::string prefix1 =
"http://";
28 const std::string prefix2 =
"https://";
29 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 174 of file CrestFunctions.cxx.
175 std::vector<cool::ChannelId>
list;
176 std::vector<std::string>
names;
180 for (
int i = 0;
i <=
n;
i++) {
182 for (
auto& [
key,
val] : j_object.items()){
183 list.push_back(std::stoll(
key));
189 auto isEmpty=[](
const std::string &
s){
return s.empty();};
191 return std::make_pair(std::move(
list), std::move(
names));
◆ extractDescriptionFromJson()
std::string IOVDbNamespace::CrestFunctions::extractDescriptionFromJson |
( |
const std::string & |
jsonReply | ) |
|
Definition at line 103 of file CrestFunctions.cxx.
106 const std::string_view signature=
"node_description\\\":\\\"";
107 const auto signaturePosition = jsonReply.find(signature);
108 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
109 const auto startOfDescription= signaturePosition + signature.size();
110 const std::string_view endSignature =
"\\\",\\\"payload_spec";
111 const auto endOfDescription=jsonReply.find(endSignature);
112 if (endOfDescription == std::string::npos)
throw std::runtime_error(
"end signature "+std::string(endSignature)+
" not found");
113 const auto len=endOfDescription-startOfDescription;
114 description=jsonReply.substr(startOfDescription, len);
116 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 49 of file CrestFunctions.cxx.
52 std::string_view signature=
"payloadHash\":\"";
53 auto signaturePosition=jsonReply.rfind(signature);
54 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
55 auto startOfHash=signaturePosition + signature.size();
56 auto endOfHash=jsonReply.find(
'\"',startOfHash);
57 auto len=endOfHash-startOfHash;
58 if (startOfHash > jsonReply.size())
throw std::runtime_error(
"Hash start is beyond end of string");
59 hash=jsonReply.substr(startOfHash, len);
61 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 | ) |
|
Definition at line 124 of file CrestFunctions.cxx.
126 std::string jsonReply =
"";
129 TagInfoDto tag_info_dto = dto.getTagInfoDto();
130 jsonReply = tag_info_dto.getFolderDescription();
◆ getIovGroups()
std::vector< uint64_t > IOVDbNamespace::CrestFunctions::getIovGroups |
( |
const std::string & |
tag | ) |
|
Definition at line 202 of file CrestFunctions.cxx.
203 std::vector<uint64_t>
v;
205 IovSetDto dto =
m_crestCl->selectGroups(
tag, 0, 10000, 0,
"id.since:ASC");
206 const std::vector<IovDto> &
res = dto.getResources();
207 for (
const IovDto & item_iov:
res){
208 v.emplace_back(item_iov.getSince());
211 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 268 of file CrestFunctions.cxx.
269 std::vector<IovHashPair> iovHashPairs;
273 if (iovNumber <=1000) {
274 dto =
m_crestCl->selectIovs(
tag, 0, -1, 0, 10000, 0,
"id.since:ASC");
277 if (s_time == 0 && u_time == 0){
280 dto =
m_crestCl->selectIovs(
tag, s_time, u_time, 0, 10000, 0,
"id.since:ASC");
283 std::vector<IovDto>
res = dto.getResources();
284 std::map<uint64_t, std::string> hashmap;
285 for (
const IovDto &
item:
res) {
286 hashmap[
item.getSince()] =
item.getPayloadHash();
288 for (
auto&
t : hashmap){
292 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 68 of file CrestFunctions.cxx.
71 std::string reply =
"";
74 IovSetDto dto =
m_crestCl->selectIovs(
tag, 0, -1, 0, 10000, 0,
"id.since:ASC");
78 reply = iov_list.dump();
80 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 88 of file CrestFunctions.cxx.
89 std::string reply =
"";
94 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 219 of file CrestFunctions.cxx.
222 std::pair<uint64_t,uint64_t> answer = std::make_pair(0,0);
225 std::cerr <<
"Wrong since/until." << std::endl;
230 for (
int i = 0;
i <
N;
i++) {
237 for (
int i = 0;
i <
N;
i++) {
244 answer = std::make_pair(new_since,new_until);
◆ getTagInfo()
Definition at line 134 of file CrestFunctions.cxx.
137 TagInfoDto tag_info_dto = dto.getTagInfoDto();
141 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 158 of file CrestFunctions.cxx.
159 if (tag_info.contains(
key)){
160 if (
key ==
"channel_list"){
161 return tag_info[
key].dump();
162 }
else if (
key==
"node_description"){
164 tag_info[
key].get_to(
v);
◆ getTagProperties()
Definition at line 147 of file CrestFunctions.cxx.
152 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 249 of file CrestFunctions.cxx.
254 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
std::unique_ptr<Crest::CrestApiBase> IOVDbNamespace::CrestFunctions::m_crestCl |
|
private |
The documentation for this class was generated from the following files: