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 getLast ()
 
std::tuple< std::string, boost::posix_time::ptime, boost::posix_time::ptime > getMetadata () const
 
 IOVProxy ()
 
 IOVProxy (const std::shared_ptr< SessionImpl > &session)
 
 IOVProxy (const IOVProxy &rhs)
 
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() {}
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ 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) {}
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:404
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ 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) {}
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

Member Function Documentation

◆ checkTransaction()

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

Definition at line 288 of file IOVProxy.cc.

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

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

288  {
289  if (!m_session.get())
290  throwException("The session is not active.", ctx);
291  if (!m_session->isTransactionActive(false))
292  throwException("The transaction is not active.", ctx);
293  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ fetchSequence()

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

Definition at line 295 of file IOVProxy.cc.

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

Referenced by getInterval().

295  {
296  m_data->iovSequence.clear();
297  m_session->iovSchema().iovTable().select(
298  m_data->tagInfo.name, lowerGroup, higherGroup, m_data->snapshotTime, m_data->iovSequence);
299 
300  if (m_data->iovSequence.empty()) {
301  m_data->groupLowerIov = cond::time::MAX_VAL;
302  m_data->groupHigherIov = cond::time::MIN_VAL;
303  } else {
304  if (lowerGroup > cond::time::MIN_VAL) {
305  m_data->groupLowerIov = std::get<0>(m_data->iovSequence.front());
306  } else {
307  m_data->groupLowerIov = cond::time::MIN_VAL;
308  }
309  m_data->groupHigherIov = std::get<0>(m_data->iovSequence.back());
310  if (higherGroup < cond::time::MAX_VAL) {
311  m_data->groupHigherIov = cond::time::tillTimeFromNextSince(higherGroup, m_data->tagInfo.timeType);
312  } else {
313  m_data->groupHigherIov = cond::time::MAX_VAL;
314  }
315  }
316 
317  m_data->numberOfQueries++;
318  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
Time_t tillTimeFromNextSince(Time_t nextSince, TimeType timeType)
Definition: Time.cc:34
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())

◆ getInterval()

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

Definition at line 320 of file IOVProxy.cc.

References checkTransaction(), 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 hcalRecHitTable_cff::time.

Referenced by popcon::PopConBTransitionSourceHandler< T >::checkBOn(), popcon::PopConESTransitionSourceHandler< T >::checkLowGain(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition(), and cond::service::OnlineDBOutputService::preLoadIov().

320  {
321  if (!m_data.get())
322  throwException("No tag has been loaded.", "IOVProxy::getInterval");
323  checkTransaction("IOVProxy::getInterval");
324  if (!m_data->cacheInitialized)
325  loadGroups();
326  cond::Iov_t retVal;
327  // organize iovs in pages...
328  // first check the available iov cache:
329  if (m_data->groupLowerIov == cond::time::MAX_VAL || // case 0 : empty cache ( the first request )
330  time < m_data->groupLowerIov || time >= m_data->groupHigherIov) { // case 1 : target outside
331 
332  // a new query required!
333  // first determine the groups
334  auto iGLow = search(time, m_data->sinceGroups);
335  if (iGLow == m_data->sinceGroups.end()) {
336  // no suitable group=no iov at all! exiting...
337  return retVal;
338  }
339  auto iGHigh = iGLow;
340  cond::Time_t lowG = *iGLow;
341  iGHigh++;
343  if (iGHigh != m_data->sinceGroups.end())
344  highG = *iGHigh;
345 
346  // finally, get the iovs for the selected group interval!!
347  fetchSequence(lowG, highG);
348  }
349 
350  // the current iov set is a good one...
351  auto iIov = search(time, m_data->iovSequence);
352  if (iIov == m_data->iovSequence.end()) {
353  return retVal;
354  }
355 
356  retVal.since = std::get<0>(*iIov);
357  auto next = iIov;
358  next++;
359 
360  // default is the end of validity when set...
361  retVal.till = m_data->tagInfo.endOfValidity;
362  // for the till, the next element of the sequence has to be looked up
363  cond::Time_t tillVal;
364  if (next != m_data->iovSequence.end()) {
365  tillVal = cond::time::tillTimeFromNextSince(std::get<0>(*next), m_data->tagInfo.timeType);
366  } else {
367  tillVal = m_data->groupHigherIov;
368  }
369  if (tillVal < retVal.till)
370  retVal.till = tillVal;
371  //
372  retVal.payloadId = std::get<1>(*iIov);
373  return retVal;
374  }
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:295
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
Time_t since
Definition: Types.h:53
unsigned long long Time_t
Definition: Time.h:14
Hash payloadId
Definition: Types.h:55
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
Time_t tillTimeFromNextSince(Time_t nextSince, TimeType timeType)
Definition: Time.cc:34
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
Time_t till
Definition: Types.h:54

◆ getLast()

cond::Iov_t IOVProxy::getLast ( )

Definition at line 376 of file IOVProxy.cc.

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().

376  {
377  checkTransaction("IOVProxy::getLast");
379  bool ok = m_session->iovSchema().iovTable().getLastIov(
380  m_data->tagInfo.name, m_data->snapshotTime, ret.since, ret.payloadId);
381  if (ok) {
382  setTillToLastIov(ret, m_data->tagInfo.endOfValidity);
383  }
384  return ret;
385  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
void setTillToLastIov(cond::Iov_t &target, cond::Time_t endOfValidity)
Definition: IOVProxy.cc:248
ret
prodAgent to be discontinued
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ getMetadata()

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

Definition at line 275 of file IOVProxy.cc.

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

275  {
276  if (!m_data.get())
277  throwException("No tag has been loaded.", "IOVProxy::getMetadata");
278  checkTransaction("IOVProxy::getMetadata");
279  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime> ret;
280  if (!m_session->iovSchema().tagTable().getMetadata(
281  m_data->tagInfo.name, std::get<0>(ret), std::get<1>(ret), std::get<2>(ret))) {
282  throwException("Metadata for tag \"" + m_data->tagInfo.name + "\" have not been found in the database.",
283  "IOVProxy::getMetadata");
284  }
285  return ret;
286  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
ret
prodAgent to be discontinued
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ iovSequenceInfo()

cond::TagInfo_t IOVProxy::iovSequenceInfo ( ) const

Definition at line 260 of file IOVProxy.cc.

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

260  {
261  if (!m_data.get())
262  throwException("No tag has been loaded.", "IOVProxy::iovSequenceInfo");
263  checkTransaction("IOVProxy::iovSequenceInfo");
265  m_session->iovSchema().iovTable().getSize(m_data->tagInfo.name, m_data->snapshotTime, ret.size);
267  bool ok = m_session->iovSchema().iovTable().getLastIov(
268  m_data->tagInfo.name, m_data->snapshotTime, ret.lastInterval.since, ret.lastInterval.payloadId);
269  if (ok) {
270  setTillToLastIov(ret.lastInterval, m_data->tagInfo.endOfValidity);
271  }
272  return ret;
273  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
void setTillToLastIov(cond::Iov_t &target, cond::Time_t endOfValidity)
Definition: IOVProxy.cc:248
ret
prodAgent to be discontinued
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ 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.

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

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

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  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ loadedGroup()

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

Definition at line 399 of file IOVProxy.cc.

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

399  {
400  return m_data.get() ? std::make_pair(m_data->groupLowerIov, m_data->groupHigherIov)
401  : std::make_pair(cond::time::MAX_VAL, cond::time::MIN_VAL);
402  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
Definition: plugin.cc:23
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())

◆ loadedSize()

int IOVProxy::loadedSize ( ) const

◆ loadGroups()

void IOVProxy::loadGroups ( )
private

Definition at line 167 of file IOVProxy.cc.

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

Referenced by getInterval().

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  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
Time_t sinceGroupSize(TimeType tp)
Definition: Time.cc:68

◆ numberOfQueries()

size_t IOVProxy::numberOfQueries ( ) const

Definition at line 397 of file IOVProxy.cc.

References m_data.

397 { return m_data.get() ? m_data->numberOfQueries : 0; }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ operator=()

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

Definition at line 133 of file IOVProxy.cc.

References m_data, and m_session.

133  {
134  m_data = rhs.m_data;
135  m_session = rhs.m_session;
136  return *this;
137  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ reset()

void IOVProxy::reset ( void  )

Definition at line 239 of file IOVProxy.cc.

References m_data, and resetIOVCache().

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

239  {
240  if (m_data.get()) {
241  m_data->tagInfo.clear();
242  }
243  resetIOVCache();
244  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ resetIOVCache()

void IOVProxy::resetIOVCache ( )
private

Definition at line 229 of file IOVProxy.cc.

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

Referenced by loadGroups(), and reset().

229  {
230  if (m_data.get()) {
231  m_data->groupLowerIov = cond::time::MAX_VAL;
232  m_data->groupHigherIov = cond::time::MIN_VAL;
233  m_data->sinceGroups.clear();
234  m_data->iovSequence.clear();
235  m_data->numberOfQueries = 0;
236  }
237  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())

◆ 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.

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

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  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
ret
prodAgent to be discontinued
const Time_t MIN_VAL(0)
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ selectRange() [1/3]

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

Definition at line 197 of file IOVProxy.cc.

Referenced by FastSiPixelFEDChannelContainerFromQuality::analyze().

197  {
198  boost::posix_time::ptime no_time;
199  return selectRange(begin, end, no_time);
200  }
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:197

◆ 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.

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

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  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
ret
prodAgent to be discontinued
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ 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.

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

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  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ sequenceSize()

int IOVProxy::sequenceSize ( ) const

Definition at line 389 of file IOVProxy.cc.

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

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

389  {
390  checkTransaction("IOVProxy::sequenceSize");
391  size_t ret = 0;
392  m_session->iovSchema().iovTable().getSize(m_data->tagInfo.name, m_data->snapshotTime, ret);
393 
394  return ret;
395  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164
ret
prodAgent to be discontinued
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:288
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:163

◆ session()

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

Definition at line 404 of file IOVProxy.cc.

References m_session.

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

404 { return m_session; }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:164

◆ 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