CMS 3D CMS Logo

KeyList.cc
Go to the documentation of this file.
3 
4 namespace cond {
5 
6  namespace persistency {
7 
8  void KeyList::init(IOVProxy iovProxy) {
9  m_proxy = iovProxy;
10  m_data.clear();
11  m_keys.clear();
12  }
13 
14  void KeyList::init(KeyList const& originalKeyList) { init(originalKeyList.m_proxy); }
15 
16  void KeyList::setKeys(const std::vector<unsigned long long>& keys) {
17  std::shared_ptr<SessionImpl> simpl = m_proxy.session();
18  if (!simpl.get())
19  cond::throwException("The KeyList has not been initialized.", "KeyList::setKeys");
20  Session s(simpl);
21  s.transaction().start(true);
22  m_keys = keys;
23  std::sort(m_keys.begin(), m_keys.end(), std::less<unsigned long long>());
24  m_data.clear();
25  m_data.resize(keys.size(), std::make_pair("", std::make_pair(cond::Binary(), cond::Binary())));
26  IOVArray keyIovs = m_proxy.selectAll();
27  for (size_t i = 0; i < m_keys.size(); ++i) {
28  if (m_keys[i] != 0) {
29  auto p = keyIovs.find(m_keys[i]);
30  if (p != keyIovs.end()) {
31  auto& item = m_data[i];
32  if (!s.fetchPayloadData((*p).payloadId, item.first, item.second.first, item.second.second))
33  cond::throwException("The Iov contains a broken payload reference.", "KeyList::setKeys");
34  }
35  }
36  }
37  s.transaction().commit();
38  }
39 
40  std::pair<std::string, std::pair<cond::Binary, cond::Binary> > KeyList::loadFromDB(unsigned long long key) const {
41  std::pair<std::string, std::pair<cond::Binary, cond::Binary> > item;
42  if (key == 0) {
43  return item;
44  }
45  std::shared_ptr<SessionImpl> simpl = m_proxy.session();
46  if (!simpl.get())
47  cond::throwException("The KeyList has not been initialized.", "KeyList::loadFromDB");
48  Session s(simpl);
49  s.transaction().start(true);
50  IOVArray keyIovs = m_proxy.selectAll();
51  auto p = keyIovs.find(key);
52  if (p != keyIovs.end()) {
53  if (!s.fetchPayloadData((*p).payloadId, item.first, item.second.first, item.second.second))
54  cond::throwException("The Iov contains a broken payload reference.", "KeyList::loadFromDB");
55  } else {
56  throwException("Payload for key " + std::to_string(key) + " has not been found.", "KeyList::loadFromDB");
57  }
58  s.transaction().commit();
59  return item;
60  }
61 
62  } // namespace persistency
63 } // namespace cond
mps_fire.i
i
Definition: mps_fire.py:355
cond::persistency::KeyList::m_keys
std::vector< unsigned long long > m_keys
Definition: KeyList.h:70
cond::Binary
Definition: Binary.h:15
cond::persistency::IOVArray::end
Iterator end() const
Definition: IOVProxy.cc:91
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:171
cond::persistency::IOVArray::find
Iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:93
cond::persistency::KeyList::setKeys
void setKeys(const std::vector< unsigned long long > &keys)
determines which keys to use to read from the DB. Should only be used by PoolDBESSource
Definition: KeyList.cc:16
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cond::persistency::IOVArray
Definition: IOVProxy.h:29
cond::persistency::IOVProxy::session
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:414
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
cond
Definition: plugin.cc:23
cond::persistency::Session
Definition: Session.h:63
cond::persistency::KeyList::m_data
std::vector< std::pair< std::string, std::pair< cond::Binary, cond::Binary > > > m_data
Definition: KeyList.h:71
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
cond::persistency::KeyList::init
void init(IOVProxy iovProxy)
Called by PoolDBESSource.
Definition: KeyList.cc:8
KeyList.h
cond::persistency::KeyList::loadFromDB
std::pair< std::string, std::pair< cond::Binary, cond::Binary > > loadFromDB(unsigned long long key) const
Definition: KeyList.cc:40
cond::persistency::KeyList::m_proxy
IOVProxy m_proxy
Definition: KeyList.h:68
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
cond::persistency::KeyList
Definition: KeyList.h:33
Session.h
crabWrapper.key
key
Definition: crabWrapper.py:19
cond::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18