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 127 of file IOVProxy.cc.

127 : m_data(), m_session() {}

◆ IOVProxy() [2/3]

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

Definition at line 129 of file IOVProxy.cc.

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

◆ IOVProxy() [3/3]

IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 131 of file IOVProxy.cc.

131 : 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 295 of file IOVProxy.cc.

295  {
296  if (!m_session.get())
297  throwException("The session is not active.", ctx);
298  if (!m_session->isTransactionActive(false))
299  throwException("The transaction is not active.", ctx);
300  }

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 302 of file IOVProxy.cc.

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

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 329 of file IOVProxy.cc.

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

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 396 of file IOVProxy.cc.

396  {
397  checkTransaction("IOVProxy::getLast");
399  bool ok = m_session->iovSchema().iovTable().getLastIov(
400  m_data->tagInfo.name, m_data->snapshotTime, ret.since, ret.payloadId);
401  if (ok) {
402  setTillToLastIov(ret, m_data->tagInfo.endOfValidity);
403  }
404  return ret;
405  }

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 282 of file IOVProxy.cc.

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

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

◆ iovSequenceInfo()

cond::TagInfo_t IOVProxy::iovSequenceInfo ( ) const

Definition at line 267 of file IOVProxy.cc.

267  {
268  if (!m_data.get())
269  throwException("No tag has been loaded.", "IOVProxy::iovSequenceInfo");
270  checkTransaction("IOVProxy::iovSequenceInfo");
272  m_session->iovSchema().iovTable().getSize(m_data->tagInfo.name, m_data->snapshotTime, ret.size);
274  bool ok = m_session->iovSchema().iovTable().getLastIov(
275  m_data->tagInfo.name, m_data->snapshotTime, ret.lastInterval.since, ret.lastInterval.payloadId);
276  if (ok) {
277  setTillToLastIov(ret.lastInterval, m_data->tagInfo.endOfValidity);
278  }
279  return ret;
280  }

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 144 of file IOVProxy.cc.

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

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 419 of file IOVProxy.cc.

419  {
420  return m_data.get() ? std::make_pair(m_data->groupLowerIov, m_data->groupHigherIov)
421  : std::make_pair(cond::time::MAX_VAL, cond::time::MIN_VAL);
422  }

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 167 of file IOVProxy.cc.

167  {
168  //if( !m_data.get() ) return;
169 
170  // clear
171  resetIOVCache();
172 
173  //checkTransaction( "IOVProxyNew::load" );
174  m_session->iovSchema().iovTable().getGroups(m_data->tagInfo.name,
175  m_data->snapshotTime,
176  cond::time::sinceGroupSize(m_data->tagInfo.timeType),
177  m_data->sinceGroups);
178  m_data->cacheInitialized = true;
179  }

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

Referenced by getInterval().

◆ numberOfQueries()

size_t IOVProxy::numberOfQueries ( ) const

Definition at line 417 of file IOVProxy.cc.

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

References m_data.

◆ operator=()

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

Definition at line 133 of file IOVProxy.cc.

133  {
134  m_data = rhs.m_data;
135  m_session = rhs.m_session;
136  return *this;
137  }

References m_data, and m_session.

◆ reset()

void IOVProxy::reset ( void  )

Definition at line 246 of file IOVProxy.cc.

246  {
247  if (m_data.get()) {
248  m_data->tagInfo.clear();
249  }
250  resetIOVCache();
251  }

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 236 of file IOVProxy.cc.

236  {
237  if (m_data.get()) {
238  m_data->groupLowerIov = cond::time::MAX_VAL;
239  m_data->groupHigherIov = cond::time::MIN_VAL;
240  m_data->sinceGroups.clear();
241  m_data->iovSequence.clear();
242  m_data->numberOfQueries = 0;
243  }
244  }

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 186 of file IOVProxy.cc.

186  {
187  if (!m_data.get())
188  throwException("No tag has been loaded.", "IOVProxy::selectAll");
189  checkTransaction("IOVProxy::selectAll");
190  IOVArray ret;
191  ret.m_tagInfo = m_data->tagInfo;
192  m_session->iovSchema().iovTable().select(
193  m_data->tagInfo.name, cond::time::MIN_VAL, cond::time::MAX_VAL, snapshottime, *ret.m_array);
194  return ret;
195  }

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 197 of file IOVProxy.cc.

197  {
198  boost::posix_time::ptime no_time;
199  return selectRange(begin, end, no_time);
200  }

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 202 of file IOVProxy.cc.

204  {
205  if (!m_data.get())
206  throwException("No tag has been loaded.", "IOVProxy::selectRange");
207 
208  checkTransaction("IOVProxy::selectRange");
209 
210  IOVArray ret;
211  ret.m_tagInfo = m_data->tagInfo;
212  m_session->iovSchema().iovTable().getRange(m_data->tagInfo.name, begin, end, snapshotTime, *ret.m_array);
213  return ret;
214  }

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 216 of file IOVProxy.cc.

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

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

◆ sequenceSize()

int IOVProxy::sequenceSize ( ) const

Definition at line 409 of file IOVProxy.cc.

409  {
410  checkTransaction("IOVProxy::sequenceSize");
411  size_t ret = 0;
412  m_session->iovSchema().iovTable().getSize(m_data->tagInfo.name, m_data->snapshotTime, ret);
413 
414  return ret;
415  }

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 424 of file IOVProxy.cc.

424 { 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:543
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:327
cond::persistency::setTillToLastIov
void setTillToLastIov(cond::Iov_t &target, cond::Time_t endOfValidity)
Definition: IOVProxy.cc:255
cond::persistency::IOVProxy::selectRange
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:197
loadRecoTauTagMVAsFromPrepDB_cfi.snapshotTime
snapshotTime
Definition: loadRecoTauTagMVAsFromPrepDB_cfi.py:10
protons_cff.time
time
Definition: protons_cff.py:35
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:181
cond::persistency::IOVProxy::load
void load(const std::string &tag)
Definition: IOVProxy.cc:139
dqmdumpme.last
last
Definition: dqmdumpme.py:56
cond::persistency::IOVProxy::resetIOVCache
void resetIOVCache()
Definition: IOVProxy.cc:236
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:167
mps_fire.end
end
Definition: mps_fire.py:242
cond::persistency::IOVProxy::session
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:424
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:246
cond::persistency::IOVProxy::checkTransaction
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:295
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:302
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