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

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

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

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

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

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

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 ntuplemaker::time.

◆ getLast()

cond::Iov_t IOVProxy::getLast ( )

Definition at line 388 of file IOVProxy.cc.

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

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

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

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

◆ iovSequenceInfo()

cond::TagInfo_t IOVProxy::iovSequenceInfo ( ) const

Definition at line 259 of file IOVProxy.cc.

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

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  if (!m_session->iovSchema().tagTable().select(tagName,
148  m_data->tagInfo.timeType,
149  m_data->tagInfo.payloadType,
150  m_data->tagInfo.synchronizationType,
151  m_data->tagInfo.endOfValidity,
152  m_data->tagInfo.lastValidatedTime)) {
153  throwException("Tag \"" + tagName + "\" has not been found in the database.", "IOVProxy::load");
154  }
155  m_data->tagInfo.name = tagName;
156  m_data->snapshotTime = snapshotTime;
157  }

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

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

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

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

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

Referenced by getInterval().

◆ numberOfQueries()

size_t IOVProxy::numberOfQueries ( ) const

Definition at line 409 of file IOVProxy.cc.

409 { 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 238 of file IOVProxy.cc.

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

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

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

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

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

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

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

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

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

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

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

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

◆ sequenceSize()

int IOVProxy::sequenceSize ( ) const

Definition at line 401 of file IOVProxy.cc.

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

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

416 { 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:367
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:319
cond::persistency::setTillToLastIov
void setTillToLastIov(cond::Iov_t &target, cond::Time_t endOfValidity)
Definition: IOVProxy.cc:247
cond::persistency::IOVProxy::selectRange
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:189
loadRecoTauTagMVAsFromPrepDB_cfi.snapshotTime
snapshotTime
Definition: loadRecoTauTagMVAsFromPrepDB_cfi.py:10
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:173
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:228
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:159
mps_fire.end
end
Definition: mps_fire.py:242
cond::persistency::IOVProxy::session
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:416
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:238
cond::persistency::IOVProxy::checkTransaction
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:287
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:294
cond::Iov_t
Definition: Types.h:47
cond::TagInfo_t
Definition: Types.h:69
ntuplemaker.time
time
Definition: ntuplemaker.py:310
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