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

103  :
104  m_data(),
105  m_session(){
106  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
IOVProxy::IOVProxy ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 108 of file IOVProxy.cc.

108  :
109  m_data( new IOVProxyData ),
110  m_session( session ){
111  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:339
IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 113 of file IOVProxy.cc.

113  :
114  m_data( rhs.m_data ),
115  m_session( rhs.m_session ){
116  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142

Member Function Documentation

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

Definition at line 228 of file IOVProxy.cc.

References m_data.

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

228  {
229  if( m_data.get() ){
230  return Iterator( m_data->iovSequence.begin(), m_data->iovSequence.end(),
231  m_data->timeType, m_data->endOfValidity );
232  }
233  return Iterator();
234  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
void IOVProxy::checkTransaction ( const std::string &  ctx) const
private

Definition at line 200 of file IOVProxy.cc.

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

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

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

Definition at line 236 of file IOVProxy.cc.

References m_data.

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

236  {
237  if( m_data.get() ){
238  return Iterator( m_data->iovSequence.end(), m_data->iovSequence.end(), m_data->timeType, m_data->endOfValidity );
239  }
240  return Iterator();
241  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
cond::Time_t IOVProxy::endOfValidity ( ) const

Definition at line 178 of file IOVProxy.cc.

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

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

Definition at line 205 of file IOVProxy.cc.

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

Referenced by find().

205  {
206  m_data->iovSequence.clear();
207  m_session->iovSchema().iovTable().selectLatestByGroup( m_data->tag, lowerGroup, higherGroup, m_data->iovSequence );
208 
209  if( m_data->iovSequence.empty() ){
210  m_data->groupLowerIov = cond::time::MAX_VAL;
211  m_data->groupHigherIov = cond::time::MIN_VAL;
212  } else {
213  if( lowerGroup > cond::time::MIN_VAL ) {
214  m_data->groupLowerIov = std::get<0>( m_data->iovSequence.front() );
215  } else {
216  m_data->groupLowerIov = cond::time::MIN_VAL;
217  }
218  if( higherGroup < cond::time::MAX_VAL ) {
219  m_data->groupHigherIov = std::get<0>(m_data->iovSequence.back());
220  } else {
221  m_data->groupHigherIov = cond::time::MAX_VAL;
222  }
223  }
224 
225  m_data->numberOfQueries++;
226  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
IOVProxy::Iterator IOVProxy::find ( cond::Time_t  time)
      Pageing switched off temporarily 
  if( m_data->groupLowerIov == cond::time::MAX_VAL ||

case 1 : target outside time < m_data->groupLowerIov || time >= m_data->groupHigherIov ){

a new query required! first determine the groups auto iGLow = search( time, m_data->sinceGroups ); if( iGLow == m_data->sinceGroups.end() ){ so suitable group=no iov at all! exiting... return end(); } auto iGHigh = iGLow; cond::Time_t lowG = 0; unless the low group is the first one available, move the previous one to fully cover the interval if( iGLow != m_data->sinceGroups.begin() ){ iGLow–; lowG = *iGLow; } the upper group will be also extended to the next (covering in total up to three groups ) iGHigh++; cond::Time_t highG = cond::time::MAX_VAL; if( iGHigh != m_data->sinceGroups.end() ) { iGHigh++; if( iGHigh != m_data->sinceGroups.end() ) highG = *iGHigh; } finally, get the iovs for the selected group interval!! fetchSequence( lowG, highG ); }

Definition at line 258 of file IOVProxy.cc.

References checkTransaction(), fetchSequence(), m_data, cond::time::MAX_VAL(), cond::time::MIN_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().

258  {
259  checkTransaction( "IOVProxy::find" );
260  // first check the available iov cache:
261  // case 0 empty cache ( the first request )
262 
293  // only one page...
294  if( m_data->groupLowerIov == cond::time::MAX_VAL ){
296  }
297 
298  // the current iov set is a good one...
299  auto iIov = search( time, m_data->iovSequence );
300  return Iterator( iIov, m_data->iovSequence.end(), m_data->timeType, m_data->endOfValidity );
301  }
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:205
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:200
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:252
cond::Iov_t IOVProxy::getInterval ( cond::Time_t  time)

Definition at line 303 of file IOVProxy.cc.

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

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

303  {
304  Iterator valid = find( time );
305  if( valid == end() ){
306  throwException( "Can't find a valid interval for the specified time.","IOVProxy::getInterval");
307  }
308  return *valid;
309  }
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:258
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
Iterator end() const
Definition: IOVProxy.cc:236
cond::Iov_t IOVProxy::getLast ( )

Definition at line 311 of file IOVProxy.cc.

References checkTransaction(), m_data, m_session, cond::time::MAX_VAL(), 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().

311  {
312  checkTransaction( "IOVProxy::getLast" );
314  if( m_session->iovSchema().iovTable().getLastIov( m_data->tag, ret.since, ret.payloadId ) ){
316  }
317  return ret;
318  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:200
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
Time_t since
Definition: Types.h:51
Hash payloadId
Definition: Types.h:53
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
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 186 of file IOVProxy.cc.

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

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

186  {
187  if(!m_data.get()) throwException( "No tag has been loaded.","IOVProxy::getMetadata()");
188  checkTransaction( "IOVProxy::getMetadata" );
189  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime > ret;
190  if(!m_session->iovSchema().tagTable().getMetadata( m_data->tag, std::get<0>( ret ), std::get<1>( ret ), std::get<2>( ret ) ) ){
191  throwException( "Metadata for tag \""+m_data->tag+"\" have not been found in the database.","IOVProxy::getMetadata()");
192  }
193  return ret;
194  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:200
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
bool IOVProxy::isEmpty ( ) const

Definition at line 196 of file IOVProxy.cc.

References m_data.

196  {
197  return m_data.get() ? ( m_data->sinceGroups.size()==0 && m_data->iovSequence.size()==0 ) : true;
198  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
cond::Time_t IOVProxy::lastValidatedTime ( ) const

Definition at line 182 of file IOVProxy.cc.

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

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

Definition at line 124 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(), MatrixToProcess.MatrixToProcess::listAll(), cond::persistency::Session::readIov(), and reload().

124  {
125  // clear
126  reset();
127 
128  checkTransaction( "IOVProxy::load" );
129  std::string dummy;
130  if(!m_session->iovSchema().tagTable().select( tag, m_data->timeType, m_data->payloadType, m_data->synchronizationType,
131  m_data->endOfValidity, dummy, m_data->lastValidatedTime ) ){
132  throwException( "Tag \""+tag+"\" has not been found in the database.","IOVProxy::load");
133  }
134  m_data->tag = tag;
135 
136  // now get the iov sequence when required
137  if( full ) {
138 
139  // load the full iov sequence in this case!
140  m_session->iovSchema().iovTable().selectLatest( m_data->tag, m_data->iovSequence );
141  m_data->groupLowerIov = cond::time::MIN_VAL;
142  m_data->groupHigherIov = cond::time::MAX_VAL;
143  } else {
144  m_session->iovSchema().iovTable().selectGroups( m_data->tag, m_data->sinceGroups );
145  }
146  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:200
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::string tag() const
Definition: IOVProxy.cc:162
const Time_t MIN_VAL(0)
Definition: GenABIO.cc:180
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
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 335 of file IOVProxy.cc.

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

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

Definition at line 320 of file IOVProxy.cc.

References m_data.

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

320  {
321  return m_data.get()? m_data->iovSequence.size() : 0;
322  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
size_t IOVProxy::numberOfQueries ( ) const

Definition at line 331 of file IOVProxy.cc.

References m_data.

331  {
332  return m_data.get()? m_data->numberOfQueries : 0;
333  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
IOVProxy & IOVProxy::operator= ( const IOVProxy rhs)

Definition at line 118 of file IOVProxy.cc.

References m_data, and m_session.

118  {
119  m_data = rhs.m_data;
120  m_session = rhs.m_session;
121  return *this;
122  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
std::string IOVProxy::payloadObjectType ( ) const
void IOVProxy::reload ( )

Definition at line 148 of file IOVProxy.cc.

References load(), and m_data.

148  {
149  if(m_data.get() && !m_data->tag.empty()) load( m_data->tag );
150  }
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:124
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
void IOVProxy::reset ( void  )

Definition at line 152 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().

152  {
153  if( m_data.get() ){
154  m_data->groupLowerIov = cond::time::MAX_VAL;
155  m_data->groupHigherIov = cond::time::MIN_VAL;
156  m_data->sinceGroups.clear();
157  m_data->iovSequence.clear();
158  m_data->numberOfQueries = 0;
159  }
160  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::sequenceSize ( ) const

Definition at line 324 of file IOVProxy.cc.

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

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

324  {
325  checkTransaction( "IOVProxy::sequenceSize" );
326  size_t ret = 0;
327  m_session->iovSchema().iovTable().getSize( m_data->tag, ret );
328  return ret;
329  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:200
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
const std::shared_ptr< SessionImpl > & IOVProxy::session ( ) const

Definition at line 339 of file IOVProxy.cc.

References m_session.

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

339  {
340  return m_session;
341  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
cond::SynchronizationType IOVProxy::synchronizationType ( ) const

Definition at line 174 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().

174  {
175  return m_data.get() ? m_data->synchronizationType : cond::SYNCHRONIZATION_UNKNOWN;
176  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
std::string IOVProxy::tag ( ) const

Definition at line 162 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

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

162  {
163  return m_data.get() ? m_data->tag : std::string("");
164  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:142
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