ATLAS Offline Software
CrestContainer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3  */
4 
13 #ifndef CREST_COND_CONTAINER_H
14 #define CREST_COND_CONTAINER_H
15 #include <vector>
16 #include <string>
17 #include <utility>
18 #include <map>
19 #include "nlohmann/json.hpp"
20 
21 namespace Crest {
22  enum class TypeId {
27  };
28  const static std::map<TypeId, std::string> s_typeToString = {
29  { TypeId::Bool, "Bool" },
30  { TypeId::UChar, "UChar" },
31  { TypeId::Int16, "Int16" },
32  { TypeId::UInt16, "UInt16" },
33  { TypeId::Int32, "Int32" },
34  { TypeId::UInt32, "UInt32" },
35  { TypeId::UInt63, "UInt63" },
36  { TypeId::Int64, "Int64" },
37  { TypeId::Float, "Float" },
38  { TypeId::Double, "Double" },
39  { TypeId::String255, "String255" },
40  { TypeId::String4k, "String4k" },
41  { TypeId::String64k, "String64k" },
42  { TypeId::String16M, "String16M" },
43  { TypeId::String128M,"String128M"},
44  { TypeId::Blob64k, "Blob64k" },
45  { TypeId::Blob16M, "Blob16M" },
46  { TypeId::Blob128M, "Blob128M" }
47  };
48 
49  enum class ModeId{
51  };
52 
56  //static bool compareStrTimestamp(std::string& as, std::string& bs);
57 
59  public:
77  void addColumn(const std::string& name, TypeId type);
86  void addColumn(const std::string& name, const std::string& type);
90  bool isVectorPayload();
101  void putRow2Vector();
108  void addNullRecord(const std::string& name);
117  void addRecord(const std::string& name,int number, ...);
124  void addData(const std::string& channel_id);
133  void addExternalData(const std::string& channel_id, const nlohmann::json& data);
140  void addIov(const uint64_t since);
144  const std::vector<std::pair<std::string,TypeId>>& getMPayloadSpec();
148  const nlohmann::json& getPayload();
152  const nlohmann::json& getIovData();
157  const nlohmann::json getPayloadChannel(const std::string& channel_id);
158 
168  int getColumnIndex(const std::string& name);
172  void flush();
176  void clear();
181  void selectIov(const uint64_t since);
185  std::vector<std::string> channelIds();
189  std::string getJsonPayload();
193  std::string getJsonIovData();
197  void dumpJsonToFile(const nlohmann::json& j, const std::string& filename);
201  nlohmann::json readJsonFromFile(const std::string& filename, const std::string& spec_filename);
205  std::vector<uint64_t> fromJson(uint64_t since,const nlohmann::json& j);
219  void parseData(const nlohmann::json & values);
220 
221  private:
222  std::vector<std::pair<std::string,TypeId>> m_payload_spec;
227  std::map<uint64_t,nlohmann::json> m_full_data;
229  bool m_isVectorPayload=false;
230 
231  nlohmann::json createRowArray(const nlohmann::json& data_row) const;
232  const nlohmann::json& getRow();
233  void parseOldFormat(const std::string& colName, const TypeId& typespec, const nlohmann::json & j);
234  void readCommonType(uint64_t since, const nlohmann::json &j_in);
235  std::vector<uint64_t> readDcsFullType(const nlohmann::json &j_in);
236  void setIovData(const nlohmann::json& j);
237  void setPayload(const nlohmann::json& j);
238  void setPayloadSpec(const nlohmann::json& j);
239 
240  };
241 }
242 #endif
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:224
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Crest::CrestContainer::setPayloadSpec
void setPayloadSpec(const nlohmann::json &j)
Definition: CrestContainer.cxx:309
Crest::CrestContainer::getFirstTime
uint64_t getFirstTime()
It return minimal timestamp in concainer.
Definition: CrestContainer.cxx:175
Crest::CrestContainer::addNullRecord
void addNullRecord(const std::string &name)
It adds a null value to the payload.
Definition: CrestContainer.cxx:51
Crest::CrestContainer::addColumn
void addColumn(const std::string &name, TypeId type)
It adds a column to the payload specification.
Definition: CrestContainer.cxx:34
Crest::TypeId::UInt16
@ UInt16
json
nlohmann::json json
Definition: HistogramDef.cxx:9
Crest::CrestContainer::addRecord
void addRecord(const std::string &name, int number,...)
It adds a record to the payload.
Definition: CrestContainer.cxx:63
Crest::CrestContainer::fromJson
std::vector< uint64_t > fromJson(uint64_t since, const nlohmann::json &j)
It reads a json object to fill the container.
Definition: CrestContainer.cxx:565
Crest::TypeId::Blob128M
@ Blob128M
Crest::CrestContainer::readJsonFromFile
nlohmann::json readJsonFromFile(const std::string &filename, const std::string &spec_filename)
It reads a json file and returns the json object.
Definition: CrestContainer.cxx:363
Crest::CrestContainer::m_payload
nlohmann::json m_payload
Definition: CrestContainer.h:223
Crest::CrestContainer::getIovData
const nlohmann::json & getIovData()
Return selected IOV in json format.
Definition: CrestContainer.cxx:262
Crest::CrestContainer::setVectorPayload
void setVectorPayload(bool isVectorPayload)
Set the Vectore mode of the container.
Definition: CrestContainer.cxx:23
Crest::CrestContainer::getRow
const nlohmann::json & getRow()
Definition: CrestContainer.cxx:241
Crest::TypeId::UInt63
@ UInt63
Crest::CrestContainer::getPayload
const nlohmann::json & getPayload()
Return current payload in json format.
Definition: CrestContainer.cxx:248
Crest::CrestContainer::isVectorPayload
bool isVectorPayload()
It sets the Vector mode of the container.
Definition: CrestContainer.cxx:19
Crest::ModeId::DCS_FULL
@ DCS_FULL
Crest::CrestContainer::getJsonPayload
std::string getJsonPayload()
It returns the json representation of the container.
Definition: CrestContainer.cxx:282
Crest::CrestContainer::flush
void flush()
It reinitializes the containers.
Definition: CrestContainer.cxx:330
Crest
Definition: CrestContainer.h:21
Crest::CrestContainer::setIovData
void setIovData(const nlohmann::json &j)
Definition: CrestContainer.cxx:272
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
Crest::TypeId::String16M
@ String16M
Crest::CrestContainer::getColumnIndex
int getColumnIndex(const std::string &name)
It returns the index of the column with the given name.
Definition: CrestContainer.cxx:211
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:808
Crest::CrestContainer::m_vector_data
nlohmann::json m_vector_data
Definition: CrestContainer.h:226
Crest::CrestContainer::m_iov_data
nlohmann::json m_iov_data
Definition: CrestContainer.h:225
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
Crest::CrestContainer::channelIds
std::vector< std::string > channelIds()
Return list of channel id in string format.
Definition: CrestContainer.cxx:183
Crest::TypeId::String255
@ String255
Crest::CrestContainer::getMPayloadSpec
const std::vector< std::pair< std::string, TypeId > > & getMPayloadSpec()
Return tag specification in vector format.
Definition: CrestContainer.cxx:191
Crest::CrestContainer::m_full_data
std::map< uint64_t, nlohmann::json > m_full_data
Definition: CrestContainer.h:227
Crest::CrestContainer::addExternalData
void addExternalData(const std::string &channel_id, const nlohmann::json &data)
It associate the payload row to a channel_id.
Definition: CrestContainer.cxx:123
Crest::TypeId::Blob64k
@ Blob64k
Crest::TypeId::Float
@ Float
Crest::CrestContainer::parseOldFormat
void parseOldFormat(const std::string &colName, const TypeId &typespec, const nlohmann::json &j)
Definition: CrestContainer.cxx:396
Crest::ModeId
ModeId
Definition: CrestContainer.h:49
Crest::CrestContainer::~CrestContainer
~CrestContainer()
Destructor of CrestContainer.
Definition: CrestContainer.cxx:14
Crest::CrestContainer::dumpJsonToFile
void dumpJsonToFile(const nlohmann::json &j, const std::string &filename)
It creates a file with the json representation of the container.
Definition: CrestContainer.cxx:347
Crest::TypeId::Bool
@ Bool
Crest::CrestContainer::clear
void clear()
It clear data the container.
Definition: CrestContainer.cxx:338
Crest::TypeId::Blob16M
@ Blob16M
Crest::CrestContainer::getStoreSetDto
nlohmann::json getStoreSetDto(uint64_t period=-1)
It return StoreSetDto in json format.
Definition: CrestContainer.cxx:657
Crest::CrestContainer::m_modeId
ModeId m_modeId
Definition: CrestContainer.h:228
Crest::CrestContainer::addData
void addData(const std::string &channel_id)
It associate the payload row to a channel_id.
Definition: CrestContainer.cxx:118
Crest::TypeId::UChar
@ UChar
Crest::TypeId::UInt32
@ UInt32
createCoolChannelIdFile.channel_id
channel_id
Definition: createCoolChannelIdFile.py:51
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
Crest::CrestContainer::parseData
void parseData(const nlohmann::json &values)
It reads a json object, parse it and fill the container.
Definition: CrestContainer.cxx:494
Preparation.mode
mode
Definition: Preparation.py:107
Crest::TypeId::Int32
@ Int32
Crest::CrestContainer::readDcsFullType
std::vector< uint64_t > readDcsFullType(const nlohmann::json &j_in)
Definition: CrestContainer.cxx:602
Crest::CrestContainer::getPayloadSpec
nlohmann::json getPayloadSpec()
Return payload specification in json format.
Definition: CrestContainer.cxx:292
Crest::TypeId::String128M
@ String128M
lumiFormat.array
array
Definition: lumiFormat.py:91
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Crest::CrestContainer
It compares timestamp in string format.
Definition: CrestContainer.h:58
Crest::CrestContainer::CrestContainer
CrestContainer(ModeId mode=ModeId::Standard)
Constructor of CrestContainer.
Definition: CrestContainer.cxx:13
Crest::ModeId::Standard
@ Standard
Crest::CrestContainer::getPayloadChannel
const nlohmann::json getPayloadChannel(const std::string &channel_id)
Return payload in json format for selected channel id.
Definition: CrestContainer.cxx:196
Crest::TypeId::Int64
@ Int64
Crest::CrestContainer::selectIov
void selectIov(const uint64_t since)
It select timestamp as active.
Definition: CrestContainer.cxx:163
Crest::TypeId::String64k
@ String64k
Crest::CrestContainer::setPayload
void setPayload(const nlohmann::json &j)
Definition: CrestContainer.cxx:277
Crest::CrestContainer::readCommonType
void readCommonType(uint64_t since, const nlohmann::json &j_in)
Definition: CrestContainer.cxx:629
Crest::TypeId::TypeIdCount
@ TypeIdCount
Crest::CrestContainer::getJsonIovData
std::string getJsonIovData()
It returns the json representation of the container.
Definition: CrestContainer.cxx:287
Crest::CrestContainer::m_payload_spec
std::vector< std::pair< std::string, TypeId > > m_payload_spec
Definition: CrestContainer.h:222
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
TypeId
Definition: IdDictMgr.cxx:29
Crest::CrestContainer::createRowArray
nlohmann::json createRowArray(const nlohmann::json &data_row) const
Definition: CrestContainer.cxx:140
Crest::ModeId::DCS
@ DCS
Crest::TypeId::String4k
@ String4k
Crest::TypeId::Int16
@ Int16
Crest::CrestContainer::addIov
void addIov(const uint64_t since)
It adds an IOV to the json object m_iov_data.
Definition: CrestContainer.cxx:155
Crest::CrestContainer::m_isVectorPayload
bool m_isVectorPayload
Definition: CrestContainer.h:229
Crest::CrestContainer::m_row
nlohmann::json m_row
Definition: CrestContainer.h:224
Crest::TypeId::Double
@ Double
Crest::CrestContainer::putRow2Vector
void putRow2Vector()
It adds row data to vector.
Definition: CrestContainer.cxx:227