CMS 3D CMS Logo

GTSchema.cc
Go to the documentation of this file.
2 #include "GTSchema.h"
3 //
4 namespace cond {
5 
6  namespace persistency {
7 
8  GLOBAL_TAG::Table::Table(coral::ISchema& schema) : m_schema(schema) {}
9 
10  bool GLOBAL_TAG::Table::exists() { return existsTable(m_schema, tname); }
11 
13  if (exists()) {
14  throwException("GLOBAL_TAG table already exists in this schema.", "GLOBAL_TAG::Table::create");
15  }
17  descr.setPrimaryKey<NAME>();
18  createTable(m_schema, descr.get());
19  }
20 
22  Query<NAME> q(m_schema);
23  q.addCondition<NAME>(name);
24  for (auto row : q) {
25  }
26 
27  return q.retrievedRows();
28  }
29 
31  cond::Time_t& validity,
32  boost::posix_time::ptime& snapshotTime) {
34  q.addCondition<NAME>(name);
35  for (auto row : q)
36  std::tie(validity, snapshotTime) = row;
37 
38  return q.retrievedRows();
39  }
40 
42  cond::Time_t& validity,
45  boost::posix_time::ptime& snapshotTime) {
47  q.addCondition<NAME>(name);
48  for (const auto& row : q)
49  std::tie(validity, description, release, snapshotTime) = row;
50 
51  return q.retrievedRows();
52  }
53 
55  cond::Time_t validity,
56  const std::string& description,
57  const std::string& release,
58  const boost::posix_time::ptime& snapshotTime,
59  const boost::posix_time::ptime& insertionTime) {
61  std::tie(name, validity, description, release, snapshotTime, insertionTime));
62  insertInTable(m_schema, tname, dataToInsert.get());
63  }
64 
66  cond::Time_t validity,
67  const std::string& description,
68  const std::string& release,
69  const boost::posix_time::ptime& snapshotTime,
70  const boost::posix_time::ptime& insertionTime) {
73  std::tie(validity, description, release, snapshotTime, insertionTime));
74  buffer.addWhereCondition<NAME>(name);
75  updateTable(m_schema, tname, buffer);
76  }
77 
78  GLOBAL_TAG_MAP::Table::Table(coral::ISchema& schema) : m_schema(schema) {}
79 
80  bool GLOBAL_TAG_MAP::Table::exists() { return existsTable(m_schema, tname); }
81 
83  if (exists()) {
84  throwException("GLOBAL_TAG_MAP table already exists in this schema.", "GLOBAL_TAG_MAP::Table::create");
85  }
88  createTable(m_schema, descr.get());
89  }
90 
92  std::vector<std::tuple<std::string, std::string, std::string> >& tags) {
94  q.addCondition<GLOBAL_TAG_NAME>(gtName);
95  q.addOrderClause<RECORD>();
96  q.addOrderClause<LABEL>();
97  for (auto row : q) {
98  if (std::get<1>(row) == "-") {
99  std::get<1>(row) = "";
100  }
101  tags.push_back(row);
102  }
103  return q.retrievedRows();
104  }
105 
107  const std::string&,
108  const std::string&,
109  std::vector<std::tuple<std::string, std::string, std::string> >& tags) {
110  return select(gtName, tags);
111  }
112 
114  const std::vector<std::tuple<std::string, std::string, std::string> >& tags) {
116  for (auto row : tags)
117  inserter.insert(std::tuple_cat(std::tie(gtName), row));
118  inserter.flush();
119  }
120 
121  GTSchema::GTSchema(coral::ISchema& schema) : m_gtTable(schema), m_gtMapTable(schema) {}
122 
124  if (!m_gtTable.exists())
125  return false;
126  if (!m_gtMapTable.exists())
127  return false;
128  return true;
129  }
130 
132  m_gtTable.create();
134  }
135 
137 
139 
140  } // namespace persistency
141 } // namespace cond
cond::persistency::GLOBAL_TAG::Table::select
bool select(const std::string &name) override
Definition: GTSchema.cc:21
cond::persistency::GTSchema::create
void create() override
Definition: GTSchema.cc:131
cond::persistency::GLOBAL_TAG_MAP::Table::Table
Table(coral::ISchema &schema)
Definition: GTSchema.cc:78
cond::persistency::GLOBAL_TAG::VALIDITY
Definition: GTSchema.h:15
Exception.h
cond::persistency::GLOBAL_TAG::DESCRIPTION
Definition: GTSchema.h:16
cond::persistency::GLOBAL_TAG_MAP::GLOBAL_TAG_NAME
Definition: GTSchema.h:55
edmLumisInFiles.description
description
Definition: edmLumisInFiles.py:11
singleTopDQM_cfi.select
select
Definition: singleTopDQM_cfi.py:50
loadRecoTauTagMVAsFromPrepDB_cfi.snapshotTime
snapshotTime
Definition: loadRecoTauTagMVAsFromPrepDB_cfi.py:10
cond::persistency::GLOBAL_TAG::RELEASE
Definition: GTSchema.h:17
cond::persistency::GLOBAL_TAG_MAP::Table::select
bool select(const std::string &gtName, std::vector< std::tuple< std::string, std::string, std::string > > &tags) override
Definition: GTSchema.cc:91
cond::persistency::BulkInserter::flush
void flush()
Definition: DbCore.h:694
cond::persistency::GLOBAL_TAG::Table::create
void create() override
Definition: GTSchema.cc:12
cond::persistency::GTSchema::GTSchema
GTSchema(coral::ISchema &schema)
Definition: GTSchema.cc:121
cond::persistency::GLOBAL_TAG_MAP::RECORD
Definition: GTSchema.h:57
cond::persistency::GLOBAL_TAG::Table
Definition: GTSchema.h:21
cond::persistency::GTSchema::gtTable
GLOBAL_TAG::Table & gtTable() override
Definition: GTSchema.cc:136
cond::persistency::GLOBAL_TAG_MAP::LABEL
Definition: GTSchema.h:59
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
cond::persistency::GTSchema::gtMapTable
GLOBAL_TAG_MAP::Table & gtMapTable() override
Definition: GTSchema.cc:138
cond::persistency::TableDescription::get
const coral::TableDescription & get()
Definition: DbCore.h:338
cond::persistency::GLOBAL_TAG::tname
static constexpr char const * tname
Definition: GTSchema.h:13
cond::persistency::GTSchema::m_gtTable
GLOBAL_TAG::Table m_gtTable
Definition: GTSchema.h:92
cond::persistency::GLOBAL_TAG::SNAPSHOT_TIME
Definition: GTSchema.h:18
cond::persistency::GLOBAL_TAG::Table::exists
bool exists() override
Definition: GTSchema.cc:10
cond::persistency::GLOBAL_TAG::INSERTION_TIME
Definition: GTSchema.h:19
cond
Definition: plugin.cc:23
cond::persistency::UpdateBuffer
Definition: DbCore.h:602
cond::persistency::BulkInserter::insert
void insert(const P &params)
Definition: DbCore.h:687
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
cond::persistency::TableDescription::setPrimaryKey
void setPrimaryKey()
Definition: DbCore.h:315
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
cond::persistency::GLOBAL_TAG::Table::update
void update(const std::string &name, cond::Time_t validity, const std::string &description, const std::string &release, const boost::posix_time::ptime &snapshotTime, const boost::posix_time::ptime &insertionTime) override
Definition: GTSchema.cc:65
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
cond::persistency::GTSchema::m_gtMapTable
GLOBAL_TAG_MAP::Table m_gtMapTable
Definition: GTSchema.h:93
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::GLOBAL_TAG::NAME
Definition: GTSchema.h:14
cond::persistency::GLOBAL_TAG_MAP::Table::insert
void insert(const std::string &gtName, const std::vector< std::tuple< std::string, std::string, std::string > > &tags) override
Definition: GTSchema.cc:113
cond::persistency::RowBuffer
Definition: DbCore.h:175
cond::persistency::RowBuffer::get
const coral::AttributeList & get() const
Definition: DbCore.h:201
cond::persistency::TableDescription
Definition: DbCore.h:286
cond::persistency::GLOBAL_TAG_MAP::Table
Definition: GTSchema.h:62
cond::persistency::GTSchema::exists
bool exists() override
Definition: GTSchema.cc:123
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
cond::persistency::Query
Definition: DbCore.h:404
cond::persistency::BulkInserter
Definition: DbCore.h:677
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
cond::persistency::GLOBAL_TAG_MAP::Table::create
void create() override
Definition: GTSchema.cc:82
cond::persistency::GLOBAL_TAG::Table::Table
Table(coral::ISchema &schema)
Definition: GTSchema.cc:8
GTSchema.h
cond::persistency::GLOBAL_TAG_MAP::Table::exists
bool exists() override
Definition: GTSchema.cc:80
cond::persistency::GLOBAL_TAG_MAP::tname
static constexpr char const * tname
Definition: GTSchema.h:52
cond::persistency::GLOBAL_TAG::Table::insert
void insert(const std::string &name, cond::Time_t validity, const std::string &description, const std::string &release, const boost::posix_time::ptime &snapshotTime, const boost::posix_time::ptime &insertionTime) override
Definition: GTSchema.cc:54