CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOVProxy.cc
Go to the documentation of this file.
3 
6  // loading the lazy-loading Queryable vector...
7  data->loadAll();
8  //**** temporary for the schema transition
9  if( dbSession.isOldSchema() ){
11  data->swapTokens( parser );
12  }
13 }
14 
16  dbSession = newSession;
17  refresh();
18 }
19 
20 std::pair<int,int> cond::IOVProxyData::range( cond::Time_t since,
21  cond::Time_t till ){
22  int low = -1;
23  int high = -1;
24  if( data->iovs().size() ){
25  cond::Time_t firstSince = data->iovs().front().sinceTime();
26  if( till >= firstSince ){
27  low = (since < firstSince) ? 0 :
28  data->find(since)-data->iovs().begin();
29  high = data->find(till) - data->iovs().begin();
30  high = std::min( high+1,(int)data->iovs().size())-1;
31  }
32  }
33  return std::make_pair( low, high );
34 }
35 
36 void cond::IOVElementProxy::set(IOVSequence const & v, int ii) {
37  if (ii>=(int)v.iovs().size() || ii<0) {
39  return;
40  }
41  size_t i =ii;
42  m_token = v.iovs()[i].token();
43  m_since = v.iovs()[i].sinceTime();
44  if(i+1==v.iovs().size()) {
45  m_till = v.lastTill();
46  return;
47  }
48  cond::UnpackedTime unpackedTime;
49  cond::Time_t totalNanoseconds;
50  cond::Time_t totalSecondsInNanoseconds;
51  switch (v.timeType()) {
52  case timestamp:
53  //unpacking
54  unpackedTime = cond::time::unpack(v.iovs()[i+1].sinceTime());
55  //number of seconds in nanoseconds (avoid multiply and divide by 1e09)
56  totalSecondsInNanoseconds = ((cond::Time_t)unpackedTime.first)*1000000000;
57  //total number of nanoseconds
58  totalNanoseconds = totalSecondsInNanoseconds + ((cond::Time_t)(unpackedTime.second));
59  //now decrementing of 1 nanosecond
60  totalNanoseconds--;
61  //now repacking (just change the value of the previous pair)
62  unpackedTime.first = (unsigned int) (totalNanoseconds/1000000000);
63  unpackedTime.second = (unsigned int)(totalNanoseconds - (cond::Time_t)unpackedTime.first*1000000000);
64  m_till = cond::time::pack(unpackedTime);
65  break;
66  default:
67  m_till = v.iovs()[i+1].sinceTime()-1;
68  }
69 }
70 
72  lowBound(0),
73  iov(&(*impl.data)),
74  elem(){
75 }
77  lowBound(lb),
78  iov(&(*impl.data)),
79  elem(){
80 }
81 
83  m_iov(),
84  m_low(-1),
85  m_high(-1),
86  m_lowBound(0){
87 }
88 
89 cond::IOVRange::IOVRange( const boost::shared_ptr<IOVProxyData>& iov,
90  cond::Time_t since,
91  cond::Time_t till,
92  int selection ):
93  m_iov( iov ),
94  m_low( -1 ),
95  m_high( -1 ),
96  m_lowBound(0){
97  std::pair<int,int> rg = m_iov->range( since, till );
98  m_low = rg.first;
99  m_high = rg.second;
100  if( selection > 0 ){
101  m_low = rg.first;
102  m_high = std::min( rg.first-selection-1, rg.second );
103  } else if( selection < 0 ){
104  m_low = std::max( rg.second-selection+1,rg.first);
105  m_high = rg.second;
106  }
107  cond::Time_t tlow = m_iov->data->iovs()[m_low].sinceTime();
108  if( since < tlow ) since = tlow;
109  m_lowBound = since;
110 }
111 
112 cond::IOVRange::IOVRange( const boost::shared_ptr<IOVProxyData>& iov,
113  int selection ):
114  m_iov(iov),
115  m_low(-1),
116  m_high(-1),
117  m_lowBound(0){
118  int sz = iov->data->iovs().size();
119  m_low = 0;
120  m_high = sz-1;
121  if( selection > 0 ){
122  m_high = std::min( selection, sz-1 );
123  } else if( selection < 0 ){
124  m_low = sz+selection;
125  if(m_low < 0) m_low = 0;
126  }
127 }
128 
130  m_iov( rhs.m_iov ),
131  m_low( rhs.m_low ),
132  m_high( rhs.m_high ),
133  m_lowBound( rhs.m_lowBound){
134 }
135 
137  m_iov = rhs.m_iov;
138  m_low = rhs.m_low;
139  m_high = rhs.m_high;
140  m_lowBound = rhs.m_lowBound;
141  return *this;
142 }
143 
145  int n = m_iov->data->find(time)-m_iov->data->iovs().begin();
146  return (n<m_low || m_high<n ) ?
147  end() :
148  boost::make_transform_iterator(boost::counting_iterator<int>(n),
149  IterHelp(*m_iov, m_lowBound));
150 }
151 
153  IterHelp helper(*m_iov, m_lowBound);
154  return helper( m_low );
155 }
156 
158  IterHelp helper(*m_iov, m_lowBound);
159  return helper( m_high );
160 }
161 
162 size_t cond::IOVRange::size() const {
163  size_t sz = 0;
164  if( m_high>=0 && m_low>=0 ) sz = m_high-m_low+1;
165  return sz;
166 }
167 
169  m_iov(){
170 }
171 
173 }
174 
176  m_iov(new IOVProxyData(dbSession)){
177 }
178 
180  const std::string & token):
181  m_iov(new IOVProxyData(dbSession,token)){
182 }
183 
184 cond::IOVProxy::IOVProxy( boost::shared_ptr<IOVProxyData>& data ):
185  m_iov( data ){
186 }
187 
189  m_iov( rhs.m_iov ){
190 }
191 
193  m_iov = rhs.m_iov;
194  return *this;
195 }
196 
197 void cond::IOVProxy::load( const std::string & token){
198  m_iov->token = token;
199  m_iov->refresh();
200 }
201 
203  int oldsize = size();
204  m_iov->refresh();
205  return oldsize<size();
206 }
207 
209  int oldsize = size();
210  m_iov->refresh( newSession );
211  return oldsize<size();
212 }
213 
214 const std::string& cond::IOVProxy::token(){
215  return m_iov->token;
216 }
217 
219  return ( currenttime >= iov().firstSince() &&
220  currenttime <= iov().lastTill() );
221 }
222 
223 std::pair<cond::Time_t, cond::Time_t> cond::IOVProxy::validity( cond::Time_t currenttime ){
224  cond::Time_t since=iov().firstSince();
225  cond::Time_t till=iov().lastTill();
226  IOVSequence::const_iterator iter=iov().find(currenttime);
227  if (iter!=iov().iovs().end()) {
228  since=iter->sinceTime();
229  iter++;
230  if (iter!=iov().iovs().end())
231  till = iter->sinceTime()-1;
232  }
233  else {
234  since=iov().lastTill();
235  }
236  return std::pair<cond::Time_t, cond::Time_t>(since,till);
237 }
238 
240  cond::Time_t till) const {
241  return IOVRange( m_iov, since, till );
242 }
243 
245  cond::Time_t till,
246  int n) const {
247  return IOVRange( m_iov, since, till, n );
248 }
249 
251  cond::Time_t till,
252  int n) const {
253  return IOVRange( m_iov, since, till, -n );
254 }
255 
257  return IOVRange( m_iov, n );
258 }
259 
261  return IOVRange( m_iov, -n );
262 }
263 
265  int n = iov().find(time)-iov().iovs().begin();
266  return ( n<0 || n>size() ) ?
267  end() :
268  boost::make_transform_iterator(boost::counting_iterator<int>(n),
269  IterHelp(*m_iov));
270 }
271 
272 int cond::IOVProxy::size() const {
273  return iov().iovs().size();
274 }
275 
277  return *(m_iov->data);
278 }
279 
281  return iov().timeType();
282 }
283 
285  return iov().firstSince();
286 }
287 
289  return iov().lastTill();
290 }
291 
292 std::set<std::string> const&
294  return iov().payloadClasses();
295 }
296 
297 std::string
299  return iov().comment();
300 }
301 
302 int
304  return iov().revision();
305 }
306 
308  return iov().timestamp();
309 }
310 
312  return m_iov->dbSession;
313 }
314 
315 
316 
const_iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:144
int i
Definition: DBlmapReader.cc:9
cond::Time_t lastTill() const
Definition: IOVSequence.h:64
cond::Time_t firstSince() const
Definition: IOVProxy.cc:284
IOVRange rangeTail(cond::Time_t since, cond::Time_t till, int n) const
Definition: IOVProxy.cc:250
std::string comment() const
Definition: IOVProxy.cc:298
cond::Time_t timestamp() const
Definition: IOVProxy.cc:307
DbSession & db() const
Definition: IOVProxy.cc:311
Container const & iovs() const
Definition: IOVSequence.cc:76
selection
main part
Definition: corrVsCorr.py:98
std::pair< cond::Time_t, cond::Time_t > validity(cond::Time_t currenttime)
Definition: IOVProxy.cc:223
TimeType timetype() const
Definition: IOVProxy.cc:280
IOVRange range(cond::Time_t since, cond::Time_t till) const
Definition: IOVProxy.cc:239
cond::Time_t pack(cond::UnpackedTime iValue)
#define min(a, b)
Definition: mlp_lapack.h:161
Container::const_iterator const_iterator
Definition: IOVSequence.h:28
boost::shared_ptr< IOVProxyData > m_iov
Definition: IOVProxy.h:150
TimeType
Definition: Time.h:21
IOVElementProxy front() const
Definition: IOVProxy.cc:152
const_iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:264
unsigned long long Time_t
Definition: Time.h:16
tuple iov
Definition: o2o.py:307
const T & max(const T &a, const T &b)
void set(cond::Time_t is, cond::Time_t it, std::string const &itoken)
Definition: IOVProxy.h:59
IOVRange rangeHead(cond::Time_t since, cond::Time_t till, int n) const
Definition: IOVProxy.cc:244
const Time_t invalidTime(0)
IOVSequence const & iov() const
Definition: IOVProxy.cc:276
#define end
Definition: vmac.h:38
cond::Time_t m_lowBound
Definition: IOVProxy.h:153
int revision() const
Definition: IOVProxy.cc:303
IOVProxy & operator=(const IOVProxy &rhs)
Definition: IOVProxy.cc:192
const std::string & token()
Definition: IOVProxy.cc:214
std::pair< int, int > range(cond::Time_t since, cond::Time_t till)
Definition: IOVProxy.cc:20
int size() const
Definition: IOVProxy.cc:272
bool refresh()
Definition: IOVProxy.cc:202
iov_range_iterator const_iterator
Definition: IOVProxy.h:114
bool isOldSchema()
Definition: DbSession.cc:215
cond::Time_t lastTill() const
Definition: IOVProxy.cc:288
size_t size() const
Definition: IOVProxy.cc:162
boost::shared_ptr< IOVProxyData > m_iov
Definition: IOVProxy.h:239
std::pair< unsigned int, unsigned int > UnpackedTime
Definition: Time.h:17
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::set< std::string > const & payloadClasses() const
Definition: IOVProxy.cc:293
boost::shared_ptr< cond::IOVSequence > data
Definition: IOVProxy.h:43
IOVRange head(int n) const
Definition: IOVProxy.cc:256
std::string token
Definition: IOVProxy.h:44
boost::shared_ptr< T > getTypedObject(const std::string &objectId)
Definition: DbSession.h:125
ora::Database & storage()
Definition: DbSession.cc:198
tuple size
Write out results.
mathSSE::Vec4< T > v
iov_range_iterator const_iterator
Definition: IOVProxy.h:160
bool isValid(cond::Time_t currenttime)
Definition: IOVProxy.cc:218
IOVElementProxy back() const
Definition: IOVProxy.cc:157
cond::TimeType timeType() const
Definition: IOVSequence.h:59
IOVRange tail(int n) const
Definition: IOVProxy.cc:260
IOVRange & operator=(const IOVRange &rhs)
Definition: IOVProxy.cc:136
cond::DbSession dbSession
Definition: IOVProxy.h:42
cond::UnpackedTime unpack(cond::Time_t iValue)
void load(const std::string &token)
Definition: IOVProxy.cc:197
void set(const std::string &name, int value)
set the flag, with a run-time name