CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::IOVProxy Class Reference

#include <IOVProxy.h>

Public Member Functions

cond::Iov_t getInterval (cond::Time_t time)
 
cond::Iov_t getInterval (cond::Time_t time, cond::Time_t defaultIovSize)
 
cond::Iov_t getLast ()
 
std::tuple< std::string, boost::posix_time::ptime, boost::posix_time::ptime > getMetadata () const
 
 IOVProxy ()
 
 IOVProxy (const IOVProxy &rhs)
 
 IOVProxy (const std::shared_ptr< SessionImpl > &session)
 
cond::TagInfo_t iovSequenceInfo () const
 
void load (const std::string &tag)
 
void load (const std::string &tag, const boost::posix_time::ptime &snapshottime)
 
std::pair< cond::Time_t, cond::Time_tloadedGroup () const
 
int loadedSize () const
 
size_t numberOfQueries () const
 
IOVProxyoperator= (const IOVProxy &rhs)
 
void reset ()
 
IOVArray selectAll ()
 
IOVArray selectAll (const boost::posix_time::ptime &snapshottime)
 
IOVArray selectRange (const cond::Time_t &begin, const cond::Time_t &end)
 
IOVArray selectRange (const cond::Time_t &begin, const cond::Time_t &end, const boost::posix_time::ptime &snapshottime)
 
bool selectRange (const cond::Time_t &begin, const cond::Time_t &end, IOVContainer &destination)
 
int sequenceSize () const
 
const std::shared_ptr< SessionImpl > & session () const
 
cond::Tag_t tagInfo () const
 

Private Member Functions

void checkTransaction (const std::string &ctx) const
 
void fetchSequence (cond::Time_t lowerGroup, cond::Time_t higherGroup)
 
void loadGroups ()
 
void resetIOVCache ()
 

Private Attributes

std::shared_ptr< IOVProxyDatam_data
 
std::shared_ptr< SessionImplm_session
 

Detailed Description

Definition at line 92 of file IOVProxy.h.

Constructor & Destructor Documentation

◆ IOVProxy() [1/3]

IOVProxy::IOVProxy ( )

Definition at line 121 of file IOVProxy.cc.

121 : m_data(), m_session() {}

◆ IOVProxy() [2/3]

IOVProxy::IOVProxy ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 123 of file IOVProxy.cc.

123 : m_data(new IOVProxyData), m_session(session) {}

◆ IOVProxy() [3/3]

IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 125 of file IOVProxy.cc.

125 : m_data(rhs.m_data), m_session(rhs.m_session) {}

Member Function Documentation

◆ checkTransaction()

void IOVProxy::checkTransaction ( const std::string &  ctx) const
private

Definition at line 289 of file IOVProxy.cc.

289  {
290  if (!m_session.get())
291  throwException("The session is not active.", ctx);
292  if (!m_session->isTransactionActive(false))
293  throwException("The transaction is not active.", ctx);
294  }

References m_session, and cond::persistency::throwException().

Referenced by getInterval(), getLast(), getMetadata(), iovSequenceInfo(), load(), selectAll(), selectRange(), and sequenceSize().

◆ fetchSequence()

void IOVProxy::fetchSequence ( cond::Time_t  lowerGroup,
cond::Time_t  higherGroup 
)
private

Definition at line 296 of file IOVProxy.cc.

296  {
297  m_data->iovSequence.clear();
298  m_session->iovSchema().iovTable().select(
299  m_data->tagInfo.name, lowerGroup, higherGroup, m_data->snapshotTime, m_data->iovSequence);
300 
301  if (m_data->iovSequence.empty()) {
302  m_data->groupLowerIov = cond::time::MAX_VAL;
303  m_data->groupHigherIov = cond::time::MIN_VAL;
304  } else {
305  if (lowerGroup > cond::time::MIN_VAL) {
306  m_data->groupLowerIov = std::get<0>(m_data->iovSequence.front());
307  } else {
308  m_data->groupLowerIov = cond::time::MIN_VAL;
309  }
310  m_data->groupHigherIov = std::get<0>(m_data->iovSequence.back());
311  if (higherGroup < cond::time::MAX_VAL) {
312  m_data->groupHigherIov = cond::time::tillTimeFromNextSince(higherGroup, m_data->tagInfo.timeType);
313  } else {
314  m_data->groupHigherIov = cond::time::MAX_VAL;
315  }
316  }
317 
318  m_data->numberOfQueries++;
319  }

References m_data, m_session, cond::time::MAX_VAL(), cond::time::MIN_VAL(), and cond::time::tillTimeFromNextSince().

Referenced by getInterval().

◆ getInterval() [1/2]

cond::Iov_t IOVProxy::getInterval ( cond::Time_t  time)

◆ getInterval() [2/2]

cond::Iov_t IOVProxy::getInterval ( cond::Time_t  time,
cond::Time_t  defaultIovSize 
)

Definition at line 323 of file IOVProxy.cc.

323  {
324  if (!m_data.get())
325  throwException("No tag has been loaded.", "IOVProxy::getInterval");
326  checkTransaction("IOVProxy::getInterval");
327  if (!m_data->cacheInitialized)
328  loadGroups();
329  cond::Iov_t retVal;
330  // organize iovs in pages...
331  // first check the available iov cache:
332  if (m_data->groupLowerIov == cond::time::MAX_VAL || // case 0 : empty cache ( the first request )
333  time < m_data->groupLowerIov || time >= m_data->groupHigherIov) { // case 1 : target outside
334 
335  // a new query required!
336  // first determine the groups
337  auto iGLow = search(time, m_data->sinceGroups);
338  if (iGLow == m_data->sinceGroups.end()) {
339  // no suitable group=no iov at all! exiting...
340  return retVal;
341  }
342  auto iGHigh = iGLow;
343  cond::Time_t lowG = *iGLow;
344  iGHigh++;
346  if (iGHigh != m_data->sinceGroups.end())
347  highG = *iGHigh;
348 
349  // finally, get the iovs for the selected group interval!!
350  fetchSequence(lowG, highG);
351  }
352 
353  // the current iov set is a good one...
354  auto iIov = search(time, m_data->iovSequence);
355  if (iIov == m_data->iovSequence.end()) {
356  return retVal;
357  }
358 
359  retVal.since = std::get<0>(*iIov);
360  auto next = iIov;
361  next++;
362 
363  // default is the end of validity when set...
364  retVal.till = m_data->tagInfo.endOfValidity;
365  // for the till, the next element of the sequence has to be looked up
366  cond::Time_t tillVal;
367  if (next != m_data->iovSequence.end()) {
368  tillVal = cond::time::tillTimeFromNextSince(std::get<0>(*next), m_data->tagInfo.timeType);
369  } else {
370  tillVal = m_data->groupHigherIov;
371  }
372  if (tillVal < retVal.till)
373  retVal.till = tillVal;
374  //
375  retVal.payloadId = std::get<1>(*iIov);
376  if (retVal.till == cond::time::MAX_VAL && defaultIovSize != cond::time::MAX_VAL) {
377  if (defaultIovSize == 0) {
378  // ???? why?
379  retVal.clear();
380  } else {
381  retVal.since = time;
382  retVal.till = retVal.since + defaultIovSize - 1;
383  if (time > retVal.till)
384  retVal.till = time;
385  }
386  }
387  return retVal;
388  }

References checkTransaction(), cond::Iov_t::clear(), fetchSequence(), loadGroups(), m_data, cond::time::MAX_VAL(), GetRecoTauVFromDQM_MC_cff::next, cond::Iov_t::payloadId, cond::persistency::search(), cond::Iov_t::since, cond::persistency::throwException(), cond::Iov_t::till, cond::time::tillTimeFromNextSince(), and protons_cff::time.

◆ getLast()

cond::Iov_t IOVProxy::getLast ( )

Definition at line 390 of file IOVProxy.cc.

390  {
391  checkTransaction("IOVProxy::getLast");
393  bool ok = m_session->iovSchema().iovTable().getLastIov(
394  m_data->tagInfo.name, m_data->snapshotTime, ret.since, ret.payloadId);
395  if (ok) {
396  setTillToLastIov(ret, m_data->tagInfo.endOfValidity);
397  }
398  return ret;
399  }

References checkTransaction(), m_data, m_session, convertSQLiteXML::ok, runTheMatrix::ret, and cond::persistency::setTillToLastIov().

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), cond::service::PoolDBOutputService::getTagInfo(), and popcon::PopCon::initialize().

◆ getMetadata()

std::tuple< std::string, boost::posix_time::ptime, boost::posix_time::ptime > IOVProxy::getMetadata ( ) const

Definition at line 276 of file IOVProxy.cc.

276  {
277  if (!m_data.get())
278  throwException("No tag has been loaded.", "IOVProxy::getMetadata");
279  checkTransaction("IOVProxy::getMetadata");
280  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime> ret;
281  if (!m_session->iovSchema().tagTable().getMetadata(
282  m_data->tagInfo.name, std::get<0>(ret), std::get<1>(ret), std::get<2>(ret))) {
283  throwException("Metadata for tag \"" + m_data->tagInfo.name + "\" have not been found in the database.",
284  "IOVProxy::getMetadata");
285  }
286  return ret;
287  }

References checkTransaction(), m_data, m_session, runTheMatrix::ret, and cond::persistency::throwException().

◆ iovSequenceInfo()

cond::TagInfo_t IOVProxy::iovSequenceInfo ( ) const

Definition at line 261 of file IOVProxy.cc.

261  {
262  if (!m_data.get())
263  throwException("No tag has been loaded.", "IOVProxy::iovSequenceInfo");
264  checkTransaction("IOVProxy::iovSequenceInfo");
266  m_session->iovSchema().iovTable().getSize(m_data->tagInfo.name, m_data->snapshotTime, ret.size);
268  bool ok = m_session->iovSchema().iovTable().getLastIov(
269  m_data->tagInfo.name, m_data->snapshotTime, ret.lastInterval.since, ret.lastInterval.payloadId);
270  if (ok) {
271  setTillToLastIov(ret.lastInterval, m_data->tagInfo.endOfValidity);
272  }
273  return ret;
274  }

References checkTransaction(), dqmdumpme::last, m_data, m_session, convertSQLiteXML::ok, runTheMatrix::ret, cond::persistency::setTillToLastIov(), and cond::persistency::throwException().

◆ load() [1/2]

void IOVProxy::load ( const std::string &  tag)

◆ load() [2/2]

void IOVProxy::load ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime 
)

Definition at line 138 of file IOVProxy.cc.

138  {
139  if (!m_data.get())
140  return;
141 
142  // clear
143  reset();
144 
145  checkTransaction("IOVProxyNew::load");
146 
147  int dummy;
148  if (!m_session->iovSchema().tagTable().select(tagName,
149  m_data->tagInfo.timeType,
150  m_data->tagInfo.payloadType,
151  m_data->tagInfo.synchronizationType,
152  m_data->tagInfo.endOfValidity,
153  m_data->tagInfo.lastValidatedTime,
154  dummy)) {
155  throwException("Tag \"" + tagName + "\" has not been found in the database.", "IOVProxy::load");
156  }
157  m_data->tagInfo.name = tagName;
158  m_data->snapshotTime = snapshotTime;
159  }

References checkTransaction(), m_data, m_session, reset(), loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, JetPartonCorrections_cff::tagName, and cond::persistency::throwException().

Referenced by MatrixToProcess.MatrixToProcess::getProcess(), MatrixToProcess.MatrixToProcess::listAll(), and ConfigBuilder.ConfigBuilder::prepare_FILTER().

◆ loadedGroup()

std::pair< cond::Time_t, cond::Time_t > IOVProxy::loadedGroup ( ) const

Definition at line 413 of file IOVProxy.cc.

413  {
414  return m_data.get() ? std::make_pair(m_data->groupLowerIov, m_data->groupHigherIov)
415  : std::make_pair(cond::time::MAX_VAL, cond::time::MIN_VAL);
416  }

References m_data, cond::time::MAX_VAL(), and cond::time::MIN_VAL().

◆ loadedSize()

int IOVProxy::loadedSize ( ) const

◆ loadGroups()

void IOVProxy::loadGroups ( )
private

Definition at line 161 of file IOVProxy.cc.

161  {
162  //if( !m_data.get() ) return;
163 
164  // clear
165  resetIOVCache();
166 
167  //checkTransaction( "IOVProxyNew::load" );
168  m_session->iovSchema().iovTable().getGroups(m_data->tagInfo.name,
169  m_data->snapshotTime,
170  cond::time::sinceGroupSize(m_data->tagInfo.timeType),
171  m_data->sinceGroups);
172  m_data->cacheInitialized = true;
173  }

References m_data, m_session, resetIOVCache(), and cond::time::sinceGroupSize().

Referenced by getInterval().

◆ numberOfQueries()

size_t IOVProxy::numberOfQueries ( ) const

Definition at line 411 of file IOVProxy.cc.

411 { return m_data.get() ? m_data->numberOfQueries : 0; }

References m_data.

◆ operator=()

IOVProxy & IOVProxy::operator= ( const IOVProxy rhs)

Definition at line 127 of file IOVProxy.cc.

127  {
128  m_data = rhs.m_data;
129  m_session = rhs.m_session;
130  return *this;
131  }

References m_data, and m_session.

◆ reset()

void IOVProxy::reset ( void  )

Definition at line 240 of file IOVProxy.cc.

240  {
241  if (m_data.get()) {
242  m_data->tagInfo.clear();
243  }
244  resetIOVCache();
245  }

References m_data, and resetIOVCache().

Referenced by MatrixReader.MatrixReader::__init__(), load(), data_sources.json_list::next(), and MatrixReader.MatrixReader::showRaw().

◆ resetIOVCache()

void IOVProxy::resetIOVCache ( )
private

Definition at line 230 of file IOVProxy.cc.

230  {
231  if (m_data.get()) {
232  m_data->groupLowerIov = cond::time::MAX_VAL;
233  m_data->groupHigherIov = cond::time::MIN_VAL;
234  m_data->sinceGroups.clear();
235  m_data->iovSequence.clear();
236  m_data->numberOfQueries = 0;
237  }
238  }

References m_data, cond::time::MAX_VAL(), and cond::time::MIN_VAL().

Referenced by loadGroups(), and reset().

◆ selectAll() [1/2]

IOVArray IOVProxy::selectAll ( )

◆ selectAll() [2/2]

IOVArray IOVProxy::selectAll ( const boost::posix_time::ptime &  snapshottime)

Definition at line 180 of file IOVProxy.cc.

180  {
181  if (!m_data.get())
182  throwException("No tag has been loaded.", "IOVProxy::selectAll");
183  checkTransaction("IOVProxy::selectAll");
184  IOVArray ret;
185  ret.m_tagInfo = m_data->tagInfo;
186  m_session->iovSchema().iovTable().select(
187  m_data->tagInfo.name, cond::time::MIN_VAL, cond::time::MAX_VAL, snapshottime, *ret.m_array);
188  return ret;
189  }

References checkTransaction(), m_data, m_session, cond::time::MAX_VAL(), cond::time::MIN_VAL(), runTheMatrix::ret, and cond::persistency::throwException().

◆ selectRange() [1/3]

IOVArray IOVProxy::selectRange ( const cond::Time_t begin,
const cond::Time_t end 
)

Definition at line 191 of file IOVProxy.cc.

191  {
192  boost::posix_time::ptime no_time;
193  return selectRange(begin, end, no_time);
194  }

References mps_fire::end.

Referenced by cond::payloadInspector::PlotBase::exec_process().

◆ selectRange() [2/3]

IOVArray IOVProxy::selectRange ( const cond::Time_t begin,
const cond::Time_t end,
const boost::posix_time::ptime &  snapshottime 
)

Definition at line 196 of file IOVProxy.cc.

198  {
199  if (!m_data.get())
200  throwException("No tag has been loaded.", "IOVProxy::selectRange");
201 
202  checkTransaction("IOVProxy::selectRange");
203 
204  IOVArray ret;
205  ret.m_tagInfo = m_data->tagInfo;
206  m_session->iovSchema().iovTable().getRange(m_data->tagInfo.name, begin, end, snapshotTime, *ret.m_array);
207  return ret;
208  }

References checkTransaction(), mps_fire::end, m_data, m_session, runTheMatrix::ret, loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, and cond::persistency::throwException().

◆ selectRange() [3/3]

bool IOVProxy::selectRange ( const cond::Time_t begin,
const cond::Time_t end,
IOVContainer destination 
)

Definition at line 210 of file IOVProxy.cc.

210  {
211  if (!m_data.get())
212  throwException("No tag has been loaded.", "IOVProxy::selectRange");
213 
214  checkTransaction("IOVProxy::selectRange");
215 
216  boost::posix_time::ptime no_time;
217  size_t prevSize = destination.size();
218  m_session->iovSchema().iovTable().getRange(m_data->tagInfo.name, begin, end, no_time, destination);
219  size_t niov = destination.size() - prevSize;
220  return niov > 0;
221  }

References checkTransaction(), HLTMuonOfflineAnalyzer_cff::destination, mps_fire::end, m_data, m_session, and cond::persistency::throwException().

◆ sequenceSize()

int IOVProxy::sequenceSize ( ) const

Definition at line 403 of file IOVProxy.cc.

403  {
404  checkTransaction("IOVProxy::sequenceSize");
405  size_t ret = 0;
406  m_session->iovSchema().iovTable().getSize(m_data->tagInfo.name, m_data->snapshotTime, ret);
407 
408  return ret;
409  }

References checkTransaction(), m_data, m_session, and runTheMatrix::ret.

Referenced by popcon::PopCon::initialize().

◆ session()

const std::shared_ptr< SessionImpl > & IOVProxy::session ( ) const

Definition at line 418 of file IOVProxy.cc.

418 { return m_session; }

References m_session.

Referenced by cond::persistency::KeyList::loadFromDB(), and cond::persistency::KeyList::setKeys().

◆ tagInfo()

cond::Tag_t IOVProxy::tagInfo ( ) const

Member Data Documentation

◆ m_data

std::shared_ptr<IOVProxyData> cond::persistency::IOVProxy::m_data
private

◆ m_session

std::shared_ptr<SessionImpl> cond::persistency::IOVProxy::m_session
private
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
cond::time::MIN_VAL
const Time_t MIN_VAL(0)
cond::persistency::IOVProxy::getInterval
cond::Iov_t getInterval(cond::Time_t time)
Definition: IOVProxy.cc:321
cond::persistency::setTillToLastIov
void setTillToLastIov(cond::Iov_t &target, cond::Time_t endOfValidity)
Definition: IOVProxy.cc:249
cond::persistency::IOVProxy::selectRange
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:191
loadRecoTauTagMVAsFromPrepDB_cfi.snapshotTime
snapshotTime
Definition: loadRecoTauTagMVAsFromPrepDB_cfi.py:10
protons_cff.time
time
Definition: protons_cff.py:39
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:175
cond::persistency::IOVProxy::load
void load(const std::string &tag)
Definition: IOVProxy.cc:133
dqmdumpme.last
last
Definition: dqmdumpme.py:56
cond::persistency::IOVProxy::resetIOVCache
void resetIOVCache()
Definition: IOVProxy.cc:230
cond::time::tillTimeFromNextSince
Time_t tillTimeFromNextSince(Time_t nextSince, TimeType timeType)
Definition: Time.cc:34
cond::Iov_t::till
Time_t till
Definition: Types.h:54
cond::persistency::IOVProxy::loadGroups
void loadGroups()
Definition: IOVProxy.cc:161
mps_fire.end
end
Definition: mps_fire.py:242
cond::persistency::IOVProxy::session
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:418
cond::persistency::search
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
cond
Definition: plugin.cc:23
cond::Iov_t::payloadId
Hash payloadId
Definition: Types.h:55
cond::Iov_t::since
Time_t since
Definition: Types.h:53
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
cond::Iov_t::clear
virtual void clear()
Definition: Types.cc:10
cond::persistency::IOVProxy::m_data
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:164
cond::time::MAX_VAL
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
cond::Tag_t
Definition: Types.h:58
HLTMuonOfflineAnalyzer_cff.destination
destination
Definition: HLTMuonOfflineAnalyzer_cff.py:50
std
Definition: JetResolutionObject.h:76
cond::persistency::IOVProxy::reset
void reset()
Definition: IOVProxy.cc:240
cond::persistency::IOVProxy::checkTransaction
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:289
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
cond::persistency::IOVProxy::fetchSequence
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:296
cond::Iov_t
Definition: Types.h:47
dummy
Definition: DummySelector.h:38
cond::TagInfo_t
Definition: Types.h:69
JetPartonCorrections_cff.tagName
tagName
Definition: JetPartonCorrections_cff.py:12
cond::time::sinceGroupSize
Time_t sinceGroupSize(TimeType tp)
Definition: Time.cc:56
cond::persistency::IOVProxy::m_session
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:165
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31