|
|
Go to the documentation of this file.
4 #include <openssl/sha.h>
8 namespace persistency {
12 if (!SHA1_Init(&ctx)) {
13 throwException(
"SHA1 initialization error.",
"IOVSchema::makeHash");
15 if (!SHA1_Update(&ctx, objectType.c_str(), objectType.size())) {
16 throwException(
"SHA1 processing error (1).",
"IOVSchema::makeHash");
18 if (!SHA1_Update(&ctx,
data.data(),
data.size())) {
19 throwException(
"SHA1 processing error (2).",
"IOVSchema::makeHash");
21 unsigned char hash[SHA_DIGEST_LENGTH];
22 if (!SHA1_Final(
hash, &ctx)) {
26 char tmp[SHA_DIGEST_LENGTH * 2 + 1];
28 for (
unsigned int i = 0;
i < 20;
i++) {
37 bool TAG::Table::Table::exists() {
return existsTable(m_schema,
tname); }
41 throwException(
"TAG table already exists in this schema.",
"TAG::Table::create");
53 descr.setPrimaryKey<
NAME>();
54 createTable(m_schema, descr.get());
63 return q.retrievedRows();
75 std::tie(timeType, objectType, synchronizationType, endOfValidity, lastValidatedTime) = row;
77 return q.retrievedRows();
82 boost::posix_time::ptime& insertionTime,
83 boost::posix_time::ptime& modificationTime) {
87 std::tie(
description, insertionTime, modificationTime) = row;
88 return q.retrievedRows();
98 const boost::posix_time::ptime& insertionTime) {
108 dataToInsert(std::tie(
name,
117 insertInTable(m_schema,
tname, dataToInsert.get());
124 const boost::posix_time::ptime& updateTime) {
127 std::tie(synchronizationType, endOfValidity, lastValidatedTime, updateTime));
134 const boost::posix_time::ptime& updateTime) {
143 const boost::posix_time::ptime& updateTime) {
156 throwException(
"IOV table already exists in this schema.",
"IOV::Schema::create");
163 createTable(m_schema, descr.
get());
168 unsigned long long gSize,
169 std::vector<cond::Time_t>& groups) {
178 groups.push_back(std::get<0>(row));
180 return q.retrievedRows();
187 std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) {
190 if (lowerSinceGroup > 0)
191 q.addCondition<
SINCE>(lowerSinceGroup,
">=");
193 q.addCondition<
SINCE>(upperSinceGroup,
"<");
197 q.addOrderClause<
SINCE>();
199 size_t initialSize = iovs.
size();
202 if (iovs.size() - initialSize && std::get<0>(iovs.back()) == std::get<0>(row))
206 return iovs.size() - initialSize;
218 q.addOrderClause<
SINCE>(
false);
220 q.limitReturnedRows(1);
222 since = std::get<0>(row);
223 hash = std::get<1>(row);
236 size = std::get<0>(row);
246 std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) {
254 for (
auto row :
q0) {
255 lower_since = std::get<0>(row);
261 q1.addCondition<
SINCE>(lower_since,
">=");
268 size_t initialSize = iovs.
size();
269 for (
auto row :
q1) {
271 if (iovs.size() - initialSize && std::get<0>(iovs.back()) == std::get<0>(row))
275 return iovs.size() - initialSize;
281 const boost::posix_time::ptime& insertTimeStamp) {
283 std::tie(
tag,
since, payloadHash, insertTimeStamp));
284 insertInTable(m_schema,
tname, dataToInsert.
get());
289 const std::vector<std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime> >& iovs) {
291 for (
auto row : iovs)
292 inserter.
insert(std::tuple_cat(std::tie(
tag), row));
306 for (
auto iov : iovs)
307 deleter.erase(std::tuple_cat(std::tie(
tag), iov));
323 throwException(
"TAG_LOG table already exists in this schema.",
"TAG_LOG::create");
328 createTable(m_schema, descr.
get());
332 const boost::posix_time::ptime& eventTime,
340 insertInTable(m_schema,
tname, dataToInsert.
get());
349 throwException(
"Payload table already exists in this schema.",
"PAYLOAD::Schema::create");
354 createTable(m_schema, descr.
get());
359 q.addCondition<
HASH>(payloadHash);
363 return q.retrievedRows();
368 q.addCondition<
HASH>(payloadHash);
370 objectType = std::get<0>(row);
373 return q.retrievedRows();
381 q.addCondition<
HASH>(payloadHash);
383 std::tie(payloadData, streamerInfoData, objectType) = row;
385 return q.retrievedRows();
392 const boost::posix_time::ptime& insertionTime) {
395 if (!sinfoData.
size())
398 std::tie(payloadHash, objectType, payloadData, sinfoData,
version, insertionTime));
399 bool failOnDuplicate =
false;
400 return insertInTable(m_schema,
tname, dataToInsert.
get(), failOnDuplicate);
406 const boost::posix_time::ptime& insertionTime) {
409 if (!
select(payloadHash)) {
410 insert(payloadHash, payloadObjectType, payloadData, streamerInfoData, insertionTime);
416 : m_tagTable(schema), m_iovTable(schema), m_tagLogTable(schema), m_payloadTable(schema) {}
429 bool created =
false;
Table(coral::ISchema &schema)
bool insert(const cond::Hash &payloadHash, const std::string &objectType, const cond::Binary &payloadData, const cond::Binary &streamerInfoData, const boost::posix_time::ptime &insertionTime)
void updateMetadata(const std::string &name, const std::string &description, const boost::posix_time::ptime &updateTime) override
void eraseMany(const std::string &tag, const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
void erase(const std::string &tag) override
void eraseOne(const std::string &tag, cond::Time_t since, cond::Hash payloadId) override
Table(coral::ISchema &schema)
void update(const std::string &name, cond::SynchronizationType synchronizationType, cond::Time_t &endOfValidity, cond::Time_t lastValidatedTime, const boost::posix_time::ptime &updateTime) override
PAYLOAD::Table m_payloadTable
void insert(const std::string &tag, const boost::posix_time::ptime &eventTime, const std::string &userName, const std::string &hostName, const std::string &command, const std::string &action, const std::string &userText) override
void insert(const std::string &name, cond::TimeType timeType, const std::string &objectType, cond::SynchronizationType synchronizationType, cond::Time_t endOfValidity, const std::string &description, cond::Time_t lastValidatedTime, const boost::posix_time::ptime &insertionTime) override
TAG_LOG::Table m_tagLogTable
ITagLogTable & tagLogTable() override
cond::Hash makeHash(const std::string &objectType, const cond::Binary &data)
void copy(const std::string &source)
size_t select(const std::string &tag, cond::Time_t lowerGroup, cond::Time_t upperGroup, const boost::posix_time::ptime &snapshotTime, std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
Table(coral::ISchema &schema)
const coral::TableDescription & get()
void updateValidity(const std::string &name, cond::Time_t lastValidatedTime, const boost::posix_time::ptime &updateTime) override
static constexpr char const * tname
IPayloadTable & payloadTable() override
bool select(const std::string &name) override
static constexpr char const * tname
static std::string group(unsigned long long groupSize)
void insertMany(const std::string &tag, const std::vector< std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > > &iovs) override
bool getLastIov(const std::string &tag, const boost::posix_time::ptime &snapshotTime, cond::Time_t &since, cond::Hash &hash) override
void insertOne(const std::string &tag, cond::Time_t since, cond::Hash payloadHash, const boost::posix_time::ptime &insertTime) override
static constexpr char const * tname
void insert(const P ¶ms)
bool getMetadata(const std::string &name, std::string &description, boost::posix_time::ptime &insertionTime, boost::posix_time::ptime &modificationTime) override
cond::Hash insertIfNew(const std::string &objectType, const cond::Binary &payloadData, const cond::Binary &streamerInfoData, const boost::posix_time::ptime &insertionTime) override
bool getSize(const std::string &tag, const boost::posix_time::ptime &snapshotTime, size_t &size) override
unsigned long long Time_t
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
size_t getGroups(const std::string &tag, const boost::posix_time::ptime &snapshotTime, unsigned long long groupSize, std::vector< cond::Time_t > &groups) override
IOVSchema(coral::ISchema &schema)
bool select(const cond::Hash &payloadHash)
const coral::AttributeList & get() const
static constexpr size_t size
IIOVTable & iovTable() override
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
bool getRange(const std::string &tag, cond::Time_t begin, cond::Time_t end, const boost::posix_time::ptime &snapshotTime, std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
void throwException(const std::string &message, const std::string &methodName)
char data[epos_bytes_allocation]
ITagTable & tagTable() override
static constexpr char const * tname
void setForeignKey(const std::string &name)
bool getType(const cond::Hash &payloadHash, std::string &objectType) override
Table(coral::ISchema &schema)