ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12
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
21namespace Crest {
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
162 nlohmann::json getPayloadSpec();
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);
210 nlohmann::json getStoreSetDto(uint64_t period=-1);
214 uint64_t getFirstTime();
219 void parseData(const nlohmann::json & values);
220
221 private:
222 std::vector<std::pair<std::string,TypeId>> m_payload_spec;
223 nlohmann::json m_payload={};
224 nlohmann::json m_row={};
225 nlohmann::json m_iov_data={};
226 nlohmann::json m_vector_data=nlohmann::json::array();
227 std::map<uint64_t,nlohmann::json> m_full_data;
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
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
std::string getJsonPayload()
It returns the json representation of the container.
std::vector< uint64_t > fromJson(uint64_t since, const nlohmann::json &j)
It reads a json object to fill the container.
bool isVectorPayload()
It sets the Vector mode of the container.
int getColumnIndex(const std::string &name)
It returns the index of the column with the given name.
nlohmann::json m_payload
nlohmann::json getStoreSetDto(uint64_t period=-1)
It return StoreSetDto in json format.
void dumpJsonToFile(const nlohmann::json &j, const std::string &filename)
It creates a file with the json representation of the container.
void parseOldFormat(const std::string &colName, const TypeId &typespec, const nlohmann::json &j)
void addIov(const uint64_t since)
It adds an IOV to the json object m_iov_data.
std::string getJsonIovData()
It returns the json representation of the container.
std::vector< std::string > channelIds()
Return list of channel id in string format.
void addRecord(const std::string &name, int number,...)
It adds a record to the payload.
void readCommonType(uint64_t since, const nlohmann::json &j_in)
nlohmann::json getPayloadSpec()
Return payload specification in json format.
void selectIov(const uint64_t since)
It select timestamp as active.
CrestContainer(ModeId mode=ModeId::Standard)
Constructor of CrestContainer.
uint64_t getFirstTime()
It return minimal timestamp in concainer.
void addColumn(const std::string &name, TypeId type)
It adds a column to the payload specification.
const nlohmann::json & getIovData()
Return selected IOV in json format.
void addExternalData(const std::string &channel_id, const nlohmann::json &data)
It associate the payload row to a channel_id.
nlohmann::json m_vector_data
nlohmann::json m_iov_data
const nlohmann::json getPayloadChannel(const std::string &channel_id)
Return payload in json format for selected channel id.
std::vector< std::pair< std::string, TypeId > > m_payload_spec
void parseData(const nlohmann::json &values)
It reads a json object, parse it and fill the container.
void addNullRecord(const std::string &name)
It adds a null value to the payload.
~CrestContainer()
Destructor of CrestContainer.
const std::vector< std::pair< std::string, TypeId > > & getMPayloadSpec()
Return tag specification in vector format.
std::map< uint64_t, nlohmann::json > m_full_data
void flush()
It reinitializes the containers.
nlohmann::json createRowArray(const nlohmann::json &data_row) const
const nlohmann::json & getPayload()
Return current payload in json format.
void setPayloadSpec(const nlohmann::json &j)
std::vector< uint64_t > readDcsFullType(const nlohmann::json &j_in)
const nlohmann::json & getRow()
void setIovData(const nlohmann::json &j)
void clear()
It clear data the container.
void addData(const std::string &channel_id)
It associate the payload row to a channel_id.
void putRow2Vector()
It adds row data to vector.
nlohmann::json readJsonFromFile(const std::string &filename, const std::string &spec_filename)
It reads a json file and returns the json object.
void setPayload(const nlohmann::json &j)
void setVectorPayload(bool isVectorPayload)
Set the Vectore mode of the container.
static const std::map< TypeId, std::string > s_typeToString
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186