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

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

Definition at line 107 of file IOVProxy.cc.

107  :
108  m_data( new IOVProxyData ),
109  m_session( session ){
110  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:305
IOVProxy::IOVProxy ( const IOVProxy rhs)

Definition at line 112 of file IOVProxy.cc.

112  :
113  m_data( rhs.m_data ),
114  m_session( rhs.m_session ){
115  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138

Member Function Documentation

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

Definition at line 200 of file IOVProxy.cc.

References m_data.

200  {
201  if( m_data.get() ){
202  return Iterator( m_data->iovSequence.begin(), m_data->iovSequence.end(),
203  m_data->timeType, m_data->endOfValidity );
204  }
205  return Iterator();
206  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
void IOVProxy::checkTransaction ( const std::string &  ctx) const
private

Definition at line 185 of file IOVProxy.cc.

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

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

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

Definition at line 208 of file IOVProxy.cc.

References m_data.

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

208  {
209  if( m_data.get() ){
210  return Iterator( m_data->iovSequence.end(), m_data->iovSequence.end(), m_data->timeType, m_data->endOfValidity );
211  }
212  return Iterator();
213  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
cond::Time_t IOVProxy::endOfValidity ( ) const

Definition at line 173 of file IOVProxy.cc.

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

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

Definition at line 190 of file IOVProxy.cc.

References m_data, and m_session.

Referenced by find().

190  {
191  m_data->iovSequence.clear();
192  m_session->iovSchema().iovTable().selectLatestByGroup( m_data->tag, lowerGroup, higherGroup, m_data->iovSequence );
193 
194  m_data->lowerGroup = lowerGroup;
195  m_data->higherGroup = higherGroup;
196 
197  m_data->numberOfQueries++;
198  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
IOVProxy::Iterator IOVProxy::find ( cond::Time_t  time)

Definition at line 230 of file IOVProxy.cc.

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

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

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

Definition at line 269 of file IOVProxy.cc.

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

269  {
270  Iterator valid = find( time );
271  if( valid == end() ){
272  throwException( "Can't find a valid interval for the specified time.","IOVProxy::getInterval");
273  }
274  return *valid;
275  }
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:230
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
Iterator end() const
Definition: IOVProxy.cc:208
cond::Iov_t IOVProxy::getLast ( )

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

277  {
278  checkTransaction( "IOVProxy::getLast" );
280  if( m_session->iovSchema().iovTable().getLastIov( m_data->tag, ret.since, ret.payloadId ) ){
282  }
283  return ret;
284  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:185
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
Time_t since
Definition: Types.h:46
Hash payloadId
Definition: Types.h:48
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
Time_t till
Definition: Types.h:47
bool IOVProxy::isEmpty ( ) const

Definition at line 181 of file IOVProxy.cc.

References m_data.

181  {
182  return m_data.get() ? ( m_data->sinceGroups.size()==0 && m_data->iovSequence.size()==0 ) : true;
183  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
cond::Time_t IOVProxy::lastValidatedTime ( ) const

Definition at line 177 of file IOVProxy.cc.

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

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

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

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

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

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

Definition at line 286 of file IOVProxy.cc.

References m_data.

286  {
287  return m_data.get()? m_data->iovSequence.size() : 0;
288  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
size_t IOVProxy::numberOfQueries ( ) const

Definition at line 297 of file IOVProxy.cc.

References m_data.

297  {
298  return m_data.get()? m_data->numberOfQueries : 0;
299  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
IOVProxy & IOVProxy::operator= ( const IOVProxy rhs)

Definition at line 117 of file IOVProxy.cc.

References m_data, and m_session.

117  {
118  m_data = rhs.m_data;
119  m_session = rhs.m_session;
120  return *this;
121  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
std::string IOVProxy::payloadObjectType ( ) const

Definition at line 169 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

169  {
170  return m_data.get() ? m_data->payloadType : std::string("");
171  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
void IOVProxy::reload ( )

Definition at line 147 of file IOVProxy.cc.

References load(), and m_data.

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

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

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

Definition at line 290 of file IOVProxy.cc.

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

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

290  {
291  checkTransaction( "IOVProxy::sequenceSize" );
292  size_t ret = 0;
293  m_session->iovSchema().iovTable().getSize( m_data->tag, ret );
294  return ret;
295  }
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:185
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
const std::shared_ptr< SessionImpl > & IOVProxy::session ( ) const

Definition at line 305 of file IOVProxy.cc.

References m_session.

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

305  {
306  return m_session;
307  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:139
std::string IOVProxy::tag ( ) const

Definition at line 161 of file IOVProxy.cc.

References m_data, and AlCaHLTBitMon_QueryRunRegistry::string.

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

161  {
162  return m_data.get() ? m_data->tag : std::string("");
163  }
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:138
cond::TimeType IOVProxy::timeType ( ) const

Definition at line 165 of file IOVProxy.cc.

References cond::invalid, and m_data.

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

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

Member Data Documentation

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