CMS 3D CMS Logo

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

#include <IOVProxy.h>

Classes

class  Iterator
 

Public Types

typedef std::vector< std::tuple< cond::Time_t, cond::Hash > > IOVContainer
 

Public Member Functions

Iterator begin () const
 
Iterator end () const
 
cond::Time_t endOfValidity () const
 
Iterator find (cond::Time_t time)
 
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)
 
bool isEmpty () const
 
cond::Time_t lastValidatedTime () const
 
void load (const std::string &tag, bool full=false)
 
void load (const std::string &tag, const boost::posix_time::ptime &snapshottime, bool full=false)
 
std::pair< cond::Time_t, cond::Time_tloadedGroup () const
 
int loadedSize () const
 
void loadRange (const std::string &tag, const cond::Time_t &begin, const cond::Time_t &end)
 
void loadRange (const std::string &tag, const cond::Time_t &begin, const cond::Time_t &end, const boost::posix_time::ptime &snapshottime)
 
size_t numberOfQueries () const
 
IOVProxyoperator= (const IOVProxy &rhs)
 
std::string payloadObjectType () const
 
void reload ()
 
void reset ()
 
int sequenceSize () const
 
const std::shared_ptr< SessionImpl > & session () const
 
cond::SynchronizationType synchronizationType () const
 
std::string tag () const
 
cond::TimeType timeType () const
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 28 of file IOVProxy.h.

Member Typedef Documentation

Definition at line 30 of file IOVProxy.h.

Constructor & Destructor Documentation

IOVProxy::IOVProxy ( )

Definition at line 111 of file IOVProxy.cc.

111  :
112  m_data(),
113  m_session(){
114  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
IOVProxy::IOVProxy ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 116 of file IOVProxy.cc.

116  :
117  m_data( new IOVProxyData ),
118  m_session( session ){
119  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:386
IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 121 of file IOVProxy.cc.

121  :
122  m_data( rhs.m_data ),
123  m_session( rhs.m_session ){
124  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152

Member Function Documentation

IOVProxy::Iterator IOVProxy::begin ( void  ) const

Definition at line 289 of file IOVProxy.cc.

References m_data.

Referenced by RunInfoUpdate::import(), cond::persistency::importIovs(), and loadRange().

289  {
290  if( m_data.get() ){
291  return Iterator( m_data->iovSequence.begin(), m_data->iovSequence.end(),
292  m_data->timeType, m_data->groupHigherIov, m_data->endOfValidity );
293  }
294  return Iterator();
295  }
TGeoIterator Iterator
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void IOVProxy::checkTransaction ( const std::string &  ctx) const
private

Definition at line 261 of file IOVProxy.cc.

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

Referenced by find(), getLast(), getMetadata(), load(), loadRange(), and sequenceSize().

261  {
262  if( !m_session.get() ) throwException("The session is not active.",ctx );
263  if( !m_session->isTransactionActive( false ) ) throwException("The transaction is not active.",ctx );
264  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
IOVProxy::Iterator IOVProxy::end ( void  ) const
cond::Time_t IOVProxy::endOfValidity ( ) const

Definition at line 239 of file IOVProxy.cc.

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

239  {
240  return m_data.get() ? m_data->endOfValidity : cond::time::MIN_VAL;
241  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void IOVProxy::fetchSequence ( cond::Time_t  lowerGroup,
cond::Time_t  higherGroup 
)
private

Definition at line 266 of file IOVProxy.cc.

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

Referenced by find().

266  {
267  m_data->iovSequence.clear();
268  m_session->iovSchema().iovTable().select( m_data->tag, lowerGroup, higherGroup, m_data->snapshotTime, m_data->iovSequence );
269 
270  if( m_data->iovSequence.empty() ){
271  m_data->groupLowerIov = cond::time::MAX_VAL;
272  m_data->groupHigherIov = cond::time::MIN_VAL;
273  } else {
274  if( lowerGroup > cond::time::MIN_VAL ) {
275  m_data->groupLowerIov = std::get<0>( m_data->iovSequence.front() );
276  } else {
277  m_data->groupLowerIov = cond::time::MIN_VAL;
278  }
279  if( higherGroup < cond::time::MAX_VAL ) {
280  m_data->groupHigherIov = higherGroup-1;
281  } else {
282  m_data->groupHigherIov = cond::time::MAX_VAL;
283  }
284  }
285 
286  m_data->numberOfQueries++;
287  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
IOVProxy::Iterator IOVProxy::find ( cond::Time_t  time)

Definition at line 320 of file IOVProxy.cc.

References checkTransaction(), end(), fetchSequence(), m_data, cond::time::MAX_VAL(), and cond::persistency::search().

Referenced by BeautifulSoup.Tag::__getattr__(), SiStripDetVOffTkMapPlotter::analyze(), SiStripDetVOffPrinter::analyze(), SiStripDetVOffTrendPlotter::analyze(), BeamSpotRcdPrinter::analyze(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), popcon::PopConESTransitionSourceHandler< T >::checkLowGain(), cond::persistency::copyIov(), BeautifulSoup.Tag::firstText(), getInterval(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition(), RunInfoUpdate::import(), cond::persistency::importIovs(), cond::persistency::KeyList::load(), l1t::DataWriterExt::payloadToken(), l1t::DataWriter::payloadToken(), and cond::persistency::BasePayloadProxy::setIntervalFor().

320  {
321  checkTransaction( "IOVProxy::find" );
322  // organize iovs in pages...
323  // first check the available iov cache:
324  if( m_data->groupLowerIov == cond::time::MAX_VAL || // case 0 : empty cache ( the first request )
325  time < m_data->groupLowerIov || time >= m_data->groupHigherIov ){ // case 1 : target outside
326 
327  // a new query required!
328  // first determine the groups
329  auto iGLow = search( time, m_data->sinceGroups );
330  if( iGLow == m_data->sinceGroups.end() ){
331  // no suitable group=no iov at all! exiting...
332  return end();
333  }
334  auto iGHigh = iGLow;
335  cond::Time_t lowG = *iGLow;
336  iGHigh++;
338  if( iGHigh != m_data->sinceGroups.end() ) highG = *iGHigh;
339 
340  // finally, get the iovs for the selected group interval!!
341  fetchSequence( lowG, highG );
342  }
343 
344  // the current iov set is a good one...
345  auto iIov = search( time, m_data->iovSequence );
346  return Iterator( iIov, m_data->iovSequence.end(), m_data->timeType, m_data->groupHigherIov, m_data->endOfValidity );
347  }
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:266
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:261
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
TGeoIterator Iterator
unsigned long long Time_t
Definition: Time.h:16
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Iterator end() const
Definition: IOVProxy.cc:297
cond::Iov_t IOVProxy::getInterval ( cond::Time_t  time)

Definition at line 349 of file IOVProxy.cc.

References end(), find(), and cond::persistency::throwException().

Referenced by cond::persistency::importIovs().

349  {
350  Iterator valid = find( time );
351  if( valid == end() ){
352  throwException( "Can't find a valid interval for the specified time.","IOVProxy::getInterval");
353  }
354  return *valid;
355  }
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
Iterator end() const
Definition: IOVProxy.cc:297
cond::Iov_t IOVProxy::getLast ( )

Definition at line 357 of file IOVProxy.cc.

References checkTransaction(), m_data, m_session, cond::time::MAX_VAL(), convertSQLiteXML::ok, cond::Iov_t::payloadId, cond::Iov_t::since, and cond::Iov_t::till.

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

357  {
358  checkTransaction( "IOVProxy::getLast" );
359  cond::Iov_t ret;
360  bool ok = m_session->iovSchema().iovTable().getLastIov( m_data->tag, m_data->snapshotTime, ret.since, ret.payloadId );
361 
362  if(ok) ret.till = cond::time::MAX_VAL;
363  return ret;
364  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:261
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
Time_t since
Definition: Types.h:55
Hash payloadId
Definition: Types.h:57
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Time_t till
Definition: Types.h:56
std::tuple< std::string, boost::posix_time::ptime, boost::posix_time::ptime > IOVProxy::getMetadata ( ) const

Definition at line 247 of file IOVProxy.cc.

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

247  {
248  if(!m_data.get()) throwException( "No tag has been loaded.","IOVProxy::getMetadata()");
249  checkTransaction( "IOVProxy::getMetadata" );
250  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime > ret;
251  if(!m_session->iovSchema().tagTable().getMetadata( m_data->tag, std::get<0>( ret ), std::get<1>( ret ), std::get<2>( ret ) ) ){
252  throwException( "Metadata for tag \""+m_data->tag+"\" have not been found in the database.","IOVProxy::getMetadata()");
253  }
254  return ret;
255  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:261
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
bool IOVProxy::isEmpty ( ) const

Definition at line 257 of file IOVProxy.cc.

References m_data.

Referenced by plotting.Plot::clone().

257  {
258  return m_data.get() ? ( m_data->sinceGroups.empty() && m_data->iovSequence.empty() ) : true;
259  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
cond::Time_t IOVProxy::lastValidatedTime ( ) const

Definition at line 243 of file IOVProxy.cc.

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

243  {
244  return m_data.get() ? m_data->lastValidatedTime : cond::time::MIN_VAL;
245  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void IOVProxy::load ( const std::string &  tag,
bool  full = false 
)

Definition at line 132 of file IOVProxy.cc.

Referenced by MatrixToProcess.MatrixToProcess::getProcess(), MatrixToProcess.MatrixToProcess::listAll(), ConfigBuilder.ConfigBuilder::prepare_FILTER(), cond::persistency::Session::readIov(), and reload().

133  {
134  boost::posix_time::ptime notime;
135  load( tag, notime, full );
136  }
std::string tag() const
Definition: IOVProxy.cc:223
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:132
Definition: GenABIO.cc:168
void IOVProxy::load ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime,
bool  full = false 
)

Definition at line 138 of file IOVProxy.cc.

References checkTransaction(), m_data, m_session, cond::time::MAX_VAL(), cond::time::MIN_VAL(), reset(), cond::time::sinceGroupSize(), loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, AlCaHLTBitMon_QueryRunRegistry::string, tag(), and cond::persistency::throwException().

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

140  {
141  if( !m_data.get() ) return;
142 
143  // clear
144  reset();
145 
146  checkTransaction( "IOVProxy::load" );
147 
149  if(!m_session->iovSchema().tagTable().select( tag, m_data->timeType, m_data->payloadType, m_data->synchronizationType,
150  m_data->endOfValidity, dummy, m_data->lastValidatedTime ) ){
151  throwException( "Tag \""+tag+"\" has not been found in the database.","IOVProxy::load");
152  }
153  m_data->tag = tag;
154 
155  // now get the iov sequence when required
156  if( full ) {
157  // load the full iov sequence in this case!
158  m_data->groupLowerIov = cond::time::MIN_VAL;
159  m_data->groupHigherIov = cond::time::MAX_VAL;
160  m_session->iovSchema().iovTable().select( m_data->tag, m_data->groupLowerIov, m_data->groupHigherIov, snapshotTime, m_data->iovSequence );
161  m_data->full = true;
162  } else {
163  m_session->iovSchema().iovTable().getGroups( m_data->tag, snapshotTime, cond::time::sinceGroupSize( m_data->timeType ), m_data->sinceGroups );
164  m_data->full = false;
165  }
166  m_data->range = false;
167  m_data->snapshotTime = snapshotTime;
168  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:261
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::string tag() const
Definition: IOVProxy.cc:223
const Time_t MIN_VAL(0)
Definition: GenABIO.cc:168
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
Time_t sinceGroupSize(TimeType tp)
Definition: Time.cc:51
std::pair< cond::Time_t, cond::Time_t > IOVProxy::loadedGroup ( ) const

Definition at line 382 of file IOVProxy.cc.

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

382  {
383  return m_data.get()? std::make_pair( m_data->groupLowerIov, m_data->groupHigherIov ): std::make_pair( cond::time::MAX_VAL, cond::time::MIN_VAL );
384  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
Definition: plugin.cc:24
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::loadedSize ( ) const
void IOVProxy::loadRange ( const std::string &  tag,
const cond::Time_t begin,
const cond::Time_t end 
)

Definition at line 170 of file IOVProxy.cc.

Referenced by cond::persistency::importIovs(), and reload().

172  {
173  boost::posix_time::ptime no_time;
174  loadRange( tag, begin, end, no_time );
175  }
std::string tag() const
Definition: IOVProxy.cc:223
Iterator begin() const
Definition: IOVProxy.cc:289
void loadRange(const std::string &tag, const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:170
Iterator end() const
Definition: IOVProxy.cc:297
void IOVProxy::loadRange ( const std::string &  tag,
const cond::Time_t begin,
const cond::Time_t end,
const boost::posix_time::ptime &  snapshottime 
)

Definition at line 177 of file IOVProxy.cc.

References begin(), checkTransaction(), end(), m_data, m_session, reset(), AlCaHLTBitMon_QueryRunRegistry::string, tag(), and cond::persistency::throwException().

180  {
181  if( !m_data.get() ) return;
182 
183  // clear
184  reset();
185 
186  checkTransaction( "IOVProxy::loadRange" );
187 
189  if(!m_session->iovSchema().tagTable().select( tag, m_data->timeType, m_data->payloadType, m_data->synchronizationType,
190  m_data->endOfValidity, dummy, m_data->lastValidatedTime ) ){
191  throwException( "Tag \""+tag+"\" has not been found in the database "+m_session->connectionString,"IOVProxy::loadRange");
192  }
193  m_data->tag = tag;
194 
195  m_session->iovSchema().iovTable().getRange( m_data->tag, begin, end, snapshotTime, m_data->iovSequence );
196 
197  m_data->full = false;
198  m_data->range = true;
199  m_data->groupLowerIov = begin;
200  m_data->groupHigherIov = end;
201 
202  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:261
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::string tag() const
Definition: IOVProxy.cc:223
Iterator begin() const
Definition: IOVProxy.cc:289
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
Iterator end() const
Definition: IOVProxy.cc:297
size_t IOVProxy::numberOfQueries ( ) const

Definition at line 378 of file IOVProxy.cc.

References m_data.

378  {
379  return m_data.get()? m_data->numberOfQueries : 0;
380  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
IOVProxy & IOVProxy::operator= ( const IOVProxy rhs)

Definition at line 126 of file IOVProxy.cc.

References m_data, and m_session.

126  {
127  m_data = rhs.m_data;
128  m_session = rhs.m_session;
129  return *this;
130  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
std::string IOVProxy::payloadObjectType ( ) const

Definition at line 231 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::persistency::copyIov(), and cond::persistency::importIovs().

231  {
232  return m_data.get() ? m_data->payloadType : std::string("");
233  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void IOVProxy::reload ( )

Definition at line 204 of file IOVProxy.cc.

References load(), loadRange(), and m_data.

204  {
205  if(m_data.get() && !m_data->tag.empty()) {
206  if(m_data->range) loadRange( m_data->tag, m_data->groupLowerIov, m_data->groupHigherIov, m_data->snapshotTime );
207  else load( m_data->tag, m_data->snapshotTime, m_data->full );
208  }
209  }
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:132
void loadRange(const std::string &tag, const cond::Time_t &begin, const cond::Time_t &end)
Definition: IOVProxy.cc:170
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
void IOVProxy::reset ( void  )

Definition at line 211 of file IOVProxy.cc.

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

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

211  {
212  if( m_data.get() ){
213  m_data->groupLowerIov = cond::time::MAX_VAL;
214  m_data->groupHigherIov = cond::time::MIN_VAL;
215  m_data->sinceGroups.clear();
216  m_data->iovSequence.clear();
217  m_data->numberOfQueries = 0;
218  m_data->full = false;
219  m_data->range = false;
220  }
221  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::sequenceSize ( ) const

Definition at line 370 of file IOVProxy.cc.

References checkTransaction(), m_data, and m_session.

Referenced by popcon::PopCon::initialize(), and cond::service::PoolDBOutputService::tagInfo().

370  {
371  checkTransaction( "IOVProxy::sequenceSize" );
372  size_t ret = 0;
373  m_session->iovSchema().iovTable().getSize( m_data->tag, m_data->snapshotTime, ret );
374 
375  return ret;
376  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:261
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
const std::shared_ptr< SessionImpl > & IOVProxy::session ( ) const

Definition at line 386 of file IOVProxy.cc.

References m_session.

Referenced by cond::persistency::KeyList::load().

386  {
387  return m_session;
388  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:153
cond::SynchronizationType IOVProxy::synchronizationType ( ) const

Definition at line 235 of file IOVProxy.cc.

References m_data, and cond::SYNCH_ANY.

Referenced by cond::persistency::copyIov(), and cond::persistency::importIovs().

235  {
236  return m_data.get() ? m_data->synchronizationType : cond::SYNCH_ANY;
237  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
std::string IOVProxy::tag ( ) const

Definition at line 223 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by load(), loadRange(), and cond::persistency::BasePayloadProxy::reload().

223  {
224  return m_data.get() ? m_data->tag : std::string("");
225  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:152
cond::TimeType IOVProxy::timeType ( ) const

Member Data Documentation

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