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

119 : m_data(), m_session() {}

◆ IOVProxy() [2/3]

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

Definition at line 121 of file IOVProxy.cc.

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

◆ IOVProxy() [3/3]

IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 123 of file IOVProxy.cc.

123 : 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 285 of file IOVProxy.cc.

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

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

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

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

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

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

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

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

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

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

◆ iovSequenceInfo()

cond::TagInfo_t IOVProxy::iovSequenceInfo ( ) const

Definition at line 257 of file IOVProxy.cc.

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

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

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

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

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

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

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

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

Referenced by getInterval().

◆ numberOfQueries()

size_t IOVProxy::numberOfQueries ( ) const

Definition at line 407 of file IOVProxy.cc.

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

References m_data.

◆ operator=()

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

Definition at line 125 of file IOVProxy.cc.

125  {
126  m_data = rhs.m_data;
127  m_session = rhs.m_session;
128  return *this;
129  }

References m_data, and m_session.

◆ reset()

void IOVProxy::reset ( void  )

Definition at line 236 of file IOVProxy.cc.

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

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

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

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

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

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

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

References begin, and 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 192 of file IOVProxy.cc.

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

References begin, checkTransaction(), 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 206 of file IOVProxy.cc.

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

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

◆ sequenceSize()

int IOVProxy::sequenceSize ( ) const

Definition at line 399 of file IOVProxy.cc.

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

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

414 { 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:355
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:317
cond::persistency::setTillToLastIov
void setTillToLastIov(cond::Iov_t &target, cond::Time_t endOfValidity)
Definition: IOVProxy.cc:245
cond::persistency::IOVProxy::selectRange
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:187
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:171
end
#define end
Definition: vmac.h:39
cond::persistency::IOVProxy::load
void load(const std::string &tag)
Definition: IOVProxy.cc:131
dqmdumpme.last
last
Definition: dqmdumpme.py:56
cond::persistency::IOVProxy::resetIOVCache
void resetIOVCache()
Definition: IOVProxy.cc:226
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:157
cond::persistency::IOVProxy::session
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:414
cond::persistency::search
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:19
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:236
cond::persistency::IOVProxy::checkTransaction
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:285
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:292
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
begin
#define begin
Definition: vmac.h:32
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