CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_t
loadedGroup () const
 
int loadedSize () const
 
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 109 of file IOVProxy.cc.

109  :
110  m_data(),
111  m_session(){
112  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
IOVProxy::IOVProxy ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 114 of file IOVProxy.cc.

114  :
115  m_data( new IOVProxyData ),
116  m_session( session ){
117  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:361
IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 119 of file IOVProxy.cc.

119  :
120  m_data( rhs.m_data ),
121  m_session( rhs.m_session ){
122  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146

Member Function Documentation

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

Definition at line 257 of file IOVProxy.cc.

References m_data.

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

257  {
258  if( m_data.get() ){
259  return Iterator( m_data->iovSequence.begin(), m_data->iovSequence.end(),
260  m_data->timeType, m_data->groupHigherIov, m_data->endOfValidity );
261  }
262  return Iterator();
263  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
void IOVProxy::checkTransaction ( const std::string &  ctx) const
private

Definition at line 225 of file IOVProxy.cc.

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

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

225  {
226  if( !m_session.get() ) throwException("The session is not active.",ctx );
227  if( !m_session->isTransactionActive( false ) ) throwException("The transaction is not active.",ctx );
228  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
IOVProxy::Iterator IOVProxy::end ( void  ) const

Definition at line 265 of file IOVProxy.cc.

References m_data.

Referenced by cond::persistency::copyIov(), Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), find(), getInterval(), cond::persistency::importIovs(), cond::persistency::KeyList::load(), l1t::DataWriter::payloadToken(), and cond::persistency::BasePayloadProxy::setIntervalFor().

265  {
266  if( m_data.get() ){
267  return Iterator( m_data->iovSequence.end(), m_data->iovSequence.end(),
268  m_data->timeType, m_data->groupHigherIov, m_data->endOfValidity );
269  }
270  return Iterator();
271  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
cond::Time_t IOVProxy::endOfValidity ( ) const

Definition at line 203 of file IOVProxy.cc.

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

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

Definition at line 230 of file IOVProxy.cc.

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

Referenced by find().

230  {
231  m_data->iovSequence.clear();
232  if( m_data->snapshotTime.is_not_a_date_time() ){
233  m_session->iovSchema().iovTable().selectLatestByGroup( m_data->tag, lowerGroup, higherGroup, m_data->iovSequence );
234  } else {
235  m_session->iovSchema().iovTable().selectSnapshotByGroup( m_data->tag, lowerGroup, higherGroup, m_data->snapshotTime, m_data->iovSequence );
236  }
237 
238  if( m_data->iovSequence.empty() ){
239  m_data->groupLowerIov = cond::time::MAX_VAL;
240  m_data->groupHigherIov = cond::time::MIN_VAL;
241  } else {
242  if( lowerGroup > cond::time::MIN_VAL ) {
243  m_data->groupLowerIov = std::get<0>( m_data->iovSequence.front() );
244  } else {
245  m_data->groupLowerIov = cond::time::MIN_VAL;
246  }
247  if( higherGroup < cond::time::MAX_VAL ) {
248  m_data->groupHigherIov = higherGroup-1;
249  } else {
250  m_data->groupHigherIov = cond::time::MAX_VAL;
251  }
252  }
253 
254  m_data->numberOfQueries++;
255  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
IOVProxy::Iterator IOVProxy::find ( cond::Time_t  time)

Definition at line 288 of file IOVProxy.cc.

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

Referenced by BeautifulSoup.Tag::__getattr__(), cond::persistency::copyIov(), BeautifulSoup.Tag::firstText(), getInterval(), cond::persistency::importIovs(), cond::persistency::KeyList::load(), l1t::DataWriter::payloadToken(), and cond::persistency::BasePayloadProxy::setIntervalFor().

288  {
289  checkTransaction( "IOVProxy::find" );
290  // organize iovs in pages...
291  // first check the available iov cache:
292  if( m_data->groupLowerIov == cond::time::MAX_VAL || // case 0 : empty cache ( the first request )
293  time < m_data->groupLowerIov || time >= m_data->groupHigherIov ){ // case 1 : target outside
294 
295  // a new query required!
296  // first determine the groups
297  auto iGLow = search( time, m_data->sinceGroups );
298  if( iGLow == m_data->sinceGroups.end() ){
299  // no suitable group=no iov at all! exiting...
300  return end();
301  }
302  auto iGHigh = iGLow;
303  cond::Time_t lowG = *iGLow;
304  iGHigh++;
306  if( iGHigh != m_data->sinceGroups.end() ) highG = *iGHigh;
307 
308  // finally, get the iovs for the selected group interval!!
309  fetchSequence( lowG, highG );
310  }
311 
312  // the current iov set is a good one...
313  auto iIov = search( time, m_data->iovSequence );
314  return Iterator( iIov, m_data->iovSequence.end(), m_data->timeType, m_data->groupHigherIov, m_data->endOfValidity );
315  }
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:230
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:225
unsigned long long Time_t
Definition: Time.h:16
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Iterator end() const
Definition: IOVProxy.cc:265
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:282
cond::Iov_t IOVProxy::getInterval ( cond::Time_t  time)

Definition at line 317 of file IOVProxy.cc.

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

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

317  {
318  Iterator valid = find( time );
319  if( valid == end() ){
320  throwException( "Can't find a valid interval for the specified time.","IOVProxy::getInterval");
321  }
322  return *valid;
323  }
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:288
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
Iterator end() const
Definition: IOVProxy.cc:265
cond::Iov_t IOVProxy::getLast ( )

Definition at line 325 of file IOVProxy.cc.

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

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

325  {
326  checkTransaction( "IOVProxy::getLast" );
328  bool ok = false;
329  if( m_data->snapshotTime.is_not_a_date_time() ){
330  ok = m_session->iovSchema().iovTable().getLastIov( m_data->tag, ret.since, ret.payloadId );
331  } else {
332  ok = m_session->iovSchema().iovTable().getSnapshotLastIov( m_data->tag, m_data->snapshotTime, ret.since, ret.payloadId );
333  }
334  if(ok) ret.till = cond::time::MAX_VAL;
335  return ret;
336  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:225
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
Time_t since
Definition: Types.h:51
Hash payloadId
Definition: Types.h:53
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Time_t till
Definition: Types.h:52
std::tuple< std::string, boost::posix_time::ptime, boost::posix_time::ptime > IOVProxy::getMetadata ( ) const

Definition at line 211 of file IOVProxy.cc.

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

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

211  {
212  if(!m_data.get()) throwException( "No tag has been loaded.","IOVProxy::getMetadata()");
213  checkTransaction( "IOVProxy::getMetadata" );
214  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime > ret;
215  if(!m_session->iovSchema().tagTable().getMetadata( m_data->tag, std::get<0>( ret ), std::get<1>( ret ), std::get<2>( ret ) ) ){
216  throwException( "Metadata for tag \""+m_data->tag+"\" have not been found in the database.","IOVProxy::getMetadata()");
217  }
218  return ret;
219  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:225
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
bool IOVProxy::isEmpty ( ) const

Definition at line 221 of file IOVProxy.cc.

References m_data.

221  {
222  return m_data.get() ? ( m_data->sinceGroups.size()==0 && m_data->iovSequence.size()==0 ) : true;
223  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
cond::Time_t IOVProxy::lastValidatedTime ( ) const

Definition at line 207 of file IOVProxy.cc.

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

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

Definition at line 130 of file IOVProxy.cc.

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

131  {
132  boost::posix_time::ptime notime;
133  load( tag, notime, full );
134  }
std::string tag() const
Definition: IOVProxy.cc:187
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:130
Definition: GenABIO.cc:180
void IOVProxy::load ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime,
bool  full = false 
)

Definition at line 136 of file IOVProxy.cc.

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

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

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

Definition at line 357 of file IOVProxy.cc.

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

357  {
358  return m_data.get()? std::make_pair( m_data->groupLowerIov, m_data->groupHigherIov ): std::make_pair( cond::time::MAX_VAL, cond::time::MIN_VAL );
359  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::loadedSize ( ) const

Definition at line 338 of file IOVProxy.cc.

References m_data.

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

338  {
339  return m_data.get()? m_data->iovSequence.size() : 0;
340  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
size_t IOVProxy::numberOfQueries ( ) const

Definition at line 353 of file IOVProxy.cc.

References m_data.

353  {
354  return m_data.get()? m_data->numberOfQueries : 0;
355  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
IOVProxy & IOVProxy::operator= ( const IOVProxy rhs)

Definition at line 124 of file IOVProxy.cc.

References m_data, and m_session.

124  {
125  m_data = rhs.m_data;
126  m_session = rhs.m_session;
127  return *this;
128  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
std::string IOVProxy::payloadObjectType ( ) const
void IOVProxy::reload ( )

Definition at line 173 of file IOVProxy.cc.

References load(), and m_data.

Referenced by cond::persistency::BasePayloadProxy::reload().

173  {
174  if(m_data.get() && !m_data->tag.empty()) load( m_data->tag, m_data->snapshotTime );
175  }
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:130
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
void IOVProxy::reset ( void  )

Definition at line 177 of file IOVProxy.cc.

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

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

177  {
178  if( m_data.get() ){
179  m_data->groupLowerIov = cond::time::MAX_VAL;
180  m_data->groupHigherIov = cond::time::MIN_VAL;
181  m_data->sinceGroups.clear();
182  m_data->iovSequence.clear();
183  m_data->numberOfQueries = 0;
184  }
185  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::sequenceSize ( ) const

Definition at line 342 of file IOVProxy.cc.

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

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

342  {
343  checkTransaction( "IOVProxy::sequenceSize" );
344  size_t ret = 0;
345  if( m_data->snapshotTime.is_not_a_date_time() ){
346  m_session->iovSchema().iovTable().getSize( m_data->tag, ret );
347  } else {
348  m_session->iovSchema().iovTable().getSnapshotSize( m_data->tag, m_data->snapshotTime, ret );
349  }
350  return ret;
351  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:225
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
const std::shared_ptr< SessionImpl > & IOVProxy::session ( ) const

Definition at line 361 of file IOVProxy.cc.

References m_session.

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

361  {
362  return m_session;
363  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:147
cond::SynchronizationType IOVProxy::synchronizationType ( ) const

Definition at line 199 of file IOVProxy.cc.

References m_data, and cond::SYNCHRONIZATION_UNKNOWN.

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

199  {
200  return m_data.get() ? m_data->synchronizationType : cond::SYNCHRONIZATION_UNKNOWN;
201  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
std::string IOVProxy::tag ( ) const

Definition at line 187 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

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

187  {
188  return m_data.get() ? m_data->tag : std::string("");
189  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:146
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