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 ()
 
 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:141
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
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:141
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:310
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:141
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140

Member Function Documentation

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

Definition at line 205 of file IOVProxy.cc.

References m_data.

205  {
206  if( m_data.get() ){
207  return Iterator( m_data->iovSequence.begin(), m_data->iovSequence.end(),
208  m_data->timeType, m_data->endOfValidity );
209  }
210  return Iterator();
211  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
void IOVProxy::checkTransaction ( const std::string &  ctx) const
private

Definition at line 190 of file IOVProxy.cc.

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

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

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

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

213  {
214  if( m_data.get() ){
215  return Iterator( m_data->iovSequence.end(), m_data->iovSequence.end(), m_data->timeType, m_data->endOfValidity );
216  }
217  return Iterator();
218  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
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:140
void IOVProxy::fetchSequence ( cond::Time_t  lowerGroup,
cond::Time_t  higherGroup 
)
private

Definition at line 195 of file IOVProxy.cc.

References m_data, and m_session.

Referenced by find().

195  {
196  m_data->iovSequence.clear();
197  m_session->iovSchema().iovTable().selectLatestByGroup( m_data->tag, lowerGroup, higherGroup, m_data->iovSequence );
198 
199  m_data->lowerGroup = lowerGroup;
200  m_data->higherGroup = higherGroup;
201 
202  m_data->numberOfQueries++;
203  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:141
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
IOVProxy::Iterator IOVProxy::find ( cond::Time_t  time)

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

235  {
236  checkTransaction( "IOVProxy::find" );
237  // first check the available iov cache:
238  // case 0 empty cache ( the first request )
239 
240  if( m_data->lowerGroup==cond::time::MAX_VAL ||
241  // case 1 : target outside
242  time < m_data->lowerGroup || time>= m_data->higherGroup ){
243 
244  // a new query required!
245  // first determine the groups
246  auto iGLow = search( time, m_data->sinceGroups );
247  if( iGLow == m_data->sinceGroups.end() ){
248  // so suitable group=no iov at all! exiting...
249  return end();
250  }
251  auto iGHigh = iGLow;
252  cond::Time_t lowG = 0;
253  // unless the low group is the first one available, move the previous one to fully cover the interval
254  if( iGLow != m_data->sinceGroups.begin() ){
255  iGLow--;
256  lowG = *iGLow;
257  }
258  // the upper group will be also extended to the next (covering in total up to three groups )
259  iGHigh++;
261  if( iGHigh != m_data->sinceGroups.end() ) {
262  iGHigh++;
263  if( iGHigh != m_data->sinceGroups.end() ) highG = *iGHigh;
264  }
265  // finally, get the iovs for the selected group interval!!
266  fetchSequence( lowG, highG );
267  }
268 
269  // the current iov set is a good one...
270  auto iIov = search( time, m_data->iovSequence );
271  return Iterator( iIov, m_data->iovSequence.end(), m_data->timeType, m_data->endOfValidity );
272  }
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:195
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:190
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:229
unsigned long long Time_t
Definition: Time.h:16
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Iterator end() const
Definition: IOVProxy.cc:213
cond::Iov_t IOVProxy::getInterval ( cond::Time_t  time)

Definition at line 274 of file IOVProxy.cc.

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

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

274  {
275  Iterator valid = find( time );
276  if( valid == end() ){
277  throwException( "Can't find a valid interval for the specified time.","IOVProxy::getInterval");
278  }
279  return *valid;
280  }
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:235
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
Iterator end() const
Definition: IOVProxy.cc:213
cond::Iov_t IOVProxy::getLast ( )

Definition at line 282 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 cond::service::PoolDBOutputService::tagInfo().

282  {
283  checkTransaction( "IOVProxy::getLast" );
285  if( m_session->iovSchema().iovTable().getLastIov( m_data->tag, ret.since, ret.payloadId ) ){
287  }
288  return ret;
289  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:190
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:141
Time_t since
Definition: Types.h:51
Hash payloadId
Definition: Types.h:53
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Time_t till
Definition: Types.h:52
bool IOVProxy::isEmpty ( ) const

Definition at line 186 of file IOVProxy.cc.

References m_data.

186  {
187  return m_data.get() ? ( m_data->sinceGroups.size()==0 && m_data->iovSequence.size()==0 ) : true;
188  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
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:140
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->lowerGroup = cond::time::MIN_VAL;
142  m_data->higherGroup = 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:190
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:141
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:140
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 306 of file IOVProxy.cc.

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

306  {
307  return m_data.get()? std::make_pair( m_data->lowerGroup, m_data->higherGroup ): std::make_pair( cond::time::MAX_VAL, cond::time::MIN_VAL );
308  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::loadedSize ( ) const

Definition at line 291 of file IOVProxy.cc.

References m_data.

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

291  {
292  return m_data.get()? m_data->iovSequence.size() : 0;
293  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
size_t IOVProxy::numberOfQueries ( ) const

Definition at line 302 of file IOVProxy.cc.

References m_data.

302  {
303  return m_data.get()? m_data->numberOfQueries : 0;
304  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
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:141
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
std::string IOVProxy::payloadObjectType ( ) const

Definition at line 170 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

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

170  {
171  return m_data.get() ? m_data->payloadType : std::string("");
172  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
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:140
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->lowerGroup = cond::time::MAX_VAL;
155  m_data->higherGroup = 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:140
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
int IOVProxy::sequenceSize ( ) const

Definition at line 295 of file IOVProxy.cc.

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

Referenced by cond::service::PoolDBOutputService::tagInfo().

295  {
296  checkTransaction( "IOVProxy::sequenceSize" );
297  size_t ret = 0;
298  m_session->iovSchema().iovTable().getSize( m_data->tag, ret );
299  return ret;
300  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:190
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:141
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
const std::shared_ptr< SessionImpl > & IOVProxy::session ( ) const

Definition at line 310 of file IOVProxy.cc.

References m_session.

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

310  {
311  return m_session;
312  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:141
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(), and cond::persistency::importIovs().

174  {
175  return m_data.get() ? m_data->synchronizationType : cond::SYNCHRONIZATION_UNKNOWN;
176  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
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:140
cond::TimeType IOVProxy::timeType ( ) const

Definition at line 166 of file IOVProxy.cc.

References cond::invalid, and m_data.

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

166  {
167  return m_data.get() ? m_data->timeType : cond::invalid;
168  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140

Member Data Documentation

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