ATLAS Offline Software
IovStore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "IovStore.h"
6 
7 namespace IOVDbNamespace{
8 
9  IovStore::IovStore()= default;
11  IovStore::IovStore(const IovStore::Iov_t & cacheBounds):m_cacheBounds(cacheBounds){
12  //
13  }
15  void
17  m_iovs.push_back(iov);
18  const auto straddles = straddling(iov, m_cacheBounds);
19  m_countStraddling.first += straddles.first;
20  m_countStraddling.second += straddles.second;
21  if (straddles.first) m_maxStraddlingSince = std::max(m_maxStraddlingSince, iov.first);
22  if (straddles.second) m_minStraddlingUntil = std::min(m_minStraddlingUntil, iov.second);
23  }
24  void
25  IovStore::addIov(const cool::ValidityKey & since, const cool::ValidityKey & until){
27  }
28 
32  return m_cacheBounds;
33  }
35  void
37  if (cacheBounds.second > cool::ValidityKeyMax){
38  m_cacheBounds=IovStore::Iov_t(cacheBounds.first, cool::ValidityKeyMax);
39  } else {
40  m_cacheBounds = cacheBounds;
41  }
42  }
47  }
48 
50  std::pair<unsigned int, unsigned int>
52  return m_countStraddling;
53  }
54 
57  {
58  m_iovs.clear();
59  m_countStraddling = std::make_pair(0,0);
60  }
61 
63  std::vector<IovStore::Iov_t> &
65  return m_iovs;
66  }
67 
68  std::pair<bool,bool>
69  IovStore::straddling(const Iov_t & iov, const Iov_t & bounds) {
70  std::pair<bool, bool> straddles(false, false);
71  straddles.first = (iov.first<=bounds.first) and (iov.second>bounds.first);
72  straddles.second = (iov.first<bounds.second) and (iov.second>bounds.second);
73  return straddles;
74  }
75 
76  void
77  IovStore::extendIov(const unsigned int idx, const cool::ValidityKey & newUntilTime){
78  m_iovs[idx].second = newUntilTime;
79  }
80 
81  void
85  }
86 
88  bool
90  const bool extend = m_maxStraddlingSince < m_cacheBounds.first;
91  if (extend) m_cacheBounds.first = m_maxStraddlingSince;
92  return extend;
93  }
95  bool
97  const bool extend = m_minStraddlingUntil > m_cacheBounds.second;
98  if (extend) m_cacheBounds.second = m_minStraddlingUntil;
99  return extend;
100  }
101 
102 
103 
104 
105 
106 
107 }
IOVDbNamespace::IovStore::extendIov
void extendIov(const unsigned int idx, const cool::ValidityKey &newUntilTime)
Extend a specific iov at the index to a new 'until' time.
Definition: IovStore.cxx:77
CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
max
#define max(a, b)
Definition: cfImp.cxx:41
IOVDbNamespace::IovStore::vectorStore
std::vector< Iov_t > & vectorStore()
Return the internal vector store.
Definition: IovStore.cxx:64
IOVDbNamespace::IovStore::getMinimumStraddlingSpan
Iov_t getMinimumStraddlingSpan() const
Get the minimum straddling span (max 'since' to min 'until')
Definition: IovStore.cxx:45
IOVDbNamespace::IovStore::numberOfIovsOnBoundaries
std::pair< unsigned int, unsigned int > numberOfIovsOnBoundaries() const
Return the current count of added Iovs which straddled cache boundaries.
Definition: IovStore.cxx:51
IOVDbNamespace::IovStore::clear
void clear()
clear the store
Definition: IovStore.cxx:56
IOVDbNamespace::IovStore::Iov_t
std::pair< cool::ValidityKey, cool::ValidityKey > Iov_t
Definition: IovStore.h:22
IOVDbNamespace::IovStore::m_cacheBounds
Iov_t m_cacheBounds
cache bounds, 'since', 'until', corresponds to m_cachestart, m_cachestop in original
Definition: IovStore.h:61
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
IOVDbNamespace::IovStore::IovStore
IovStore()
Default constructor, cache bounds set to 0,0.
IOVDbNamespace::IovStore::m_iovs
std::vector< Iov_t > m_iovs
main vector of iovs
Definition: IovStore.h:59
IOVDbNamespace::IovStore::m_maxStraddlingSince
cool::ValidityKey m_maxStraddlingSince
max 'since' of the iovs which straddle the cache boundary, corresponds to 'm_boundmin' in the origina...
Definition: IovStore.h:65
IOVDbNamespace::IovStore::getCacheBounds
Iov_t getCacheBounds() const
Report the current cache bounds.
Definition: IovStore.cxx:31
IOVDbNamespace::IovStore::setCacheBounds
void setCacheBounds(const Iov_t &cacheBounds)
Set the cache bound variables.
Definition: IovStore.cxx:36
min
#define min(a, b)
Definition: cfImp.cxx:40
IOVDbNamespace::IovStore::m_minStraddlingUntil
cool::ValidityKey m_minStraddlingUntil
min 'until' of the iovs which straddle the boundary corresponds to 'm_boundmax' in the original code
Definition: IovStore.h:69
IOVDbNamespace::IovStore::addIov
void addIov(const Iov_t &iov)
Add an iov to the store and update the span variables.
Definition: IovStore.cxx:16
IOVDbNamespace::IovStore::m_countStraddling
std::pair< unsigned int, unsigned int > m_countStraddling
count of iovs straddling the since or until boundaries
Definition: IovStore.h:71
IOVDbNamespace::IovStore::extendCacheHi
bool extendCacheHi()
Extend upper cache bound to the minimum 'until' time; return whether this changes its value.
Definition: IovStore.cxx:96
IovStore.h
helper class for IOVDbFolder managing cached iov since/until pairs
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
IOVDbNamespace::IovStore::extendCacheLo
bool extendCacheLo()
Extend lower cache bound to the maximum 'since' time; return whether this changes its value.
Definition: IovStore.cxx:89
IOVDbNamespace::IovStore::straddling
static std::pair< bool, bool > straddling(const Iov_t &iov, const Iov_t &bounds)
Definition: IovStore.cxx:69
IOVDbNamespace::IovStore::setIovSpan
void setIovSpan(const Iov_t &span)
Set span.
Definition: IovStore.cxx:82
IOVDbNamespace
Definition: Base64Codec.cxx:16