ATLAS Offline Software
Loading...
Searching...
No Matches
ThinningCache.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
14
15
16namespace SG {
17
18
23{
24 return m_map.empty();
25}
26
27
36ThinningCache::thinning (const std::string& key) const
37{
38 auto it = m_map.find (key);
39 if (it != m_map.end()) {
40 return it->second.m_decision;
41 }
42 return nullptr;
43}
44
45
55{
56 auto it = m_sgmap.find (sgkey);
57 if (it != m_sgmap.end()) {
58 return it->second.m_decision;
59 }
60 return nullptr;
61}
62
63
77void ThinningCache::addThinning (const std::string& key,
78 const std::vector<sgkey_t>& sgkeys,
80 bool unique /*= false*/)
81{
82 if (!thinning) return;
83
84 {
85 ThinningInfo& info = m_map[key];
86 if (info.m_decision) {
87 if (!unique) {
88 merge (info, sgkeys, *thinning);
89 return;
90 }
91 throw std::runtime_error ("Duplicated thinning definition");
92 }
93 else {
94 info.m_decision = thinning;
95 }
96 }
97
98 for (sgkey_t sgkey : sgkeys) {
99 ThinningInfo& info = m_sgmap[sgkey];
100 if (info.m_decision) {
101 throw std::runtime_error ("Duplicated thinning definition");
102 }
103 info.m_decision = thinning;
104 }
105}
106
107
116
117
126
127
135{
136 for (const std::unique_ptr<ThinningDecisionBase>& dec : m_owned) {
137 dec->buildIndexMap();
138 }
139}
140
141
148void ThinningCache::setVetoed (const std::string& key,
149 const CxxUtils::ConcurrentBitset& vetoed)
150{
151 m_map[key].m_vetoed = vetoed;
152}
153
160void ThinningCache::setCompression(const std::string& key,
161 const ThinningInfo::compression_map_t& compression)
162{
163 m_map[key].m_compression = compression;
164}
165
172const ThinningInfo*
173ThinningCache::thinningInfo (const std::string& key) const
174{
175 auto it = m_map.find (key);
176 if (it != m_map.end()) {
177 return &it->second;
178 }
179 return nullptr;
180}
181
182
187{
188 m_map.clear();
189 m_sgmap.clear();
190 m_owned.clear();
192}
193
194
204 const std::vector<sgkey_t>& sgkeys,
206{
207 // The existing thinning object.
208 ThinningDecisionBase* oldThinning = nullptr;
209
210 // Look for the existing object in our list of owned decision objects.
211 // If we don't find it, then we'll need to make a copy of the existing
212 // decision so that we can modify it.
213 // We expect this to be relatively rare and the number of such objects
214 // to be small, so just use a linear search.
215 auto ownedIt = std::find_if (m_owned.begin(), m_owned.end(),
216 [old = info.m_decision]
217 (const std::unique_ptr<SG::ThinningDecisionBase>& p)
218 { return p.get() == old; });
219
220 if (ownedIt != m_owned.end()) {
221 // We already own the existing decision. We can just use it.
222 oldThinning = ownedIt->get();
223 }
224 else {
225 // We need to make a copy of the existing decision and enter it into the maps.
226 m_owned.push_back (std::make_unique<SG::ThinningDecisionBase> (info.m_decision->size()));
227 oldThinning = m_owned.back().get();
228 oldThinning->thin (*info.m_decision);
229 info.m_decision = oldThinning;
230
231 for (sgkey_t sgkey : sgkeys) {
232 m_sgmap[sgkey].m_decision = oldThinning;
233 }
234 }
235
236 // Merge the decisions.
238}
239
240
241} // namespace SG
Hold thinning decisions for one container.
Variable-sized bitset allowing (mostly) concurrent access.
Define interface for doing TrigNavigation thinning.
std::vector< std::unique_ptr< ThinningDecisionBase > > m_owned
List of decision objects we've copied in order to handle merges.
const ThinningInfo * thinningInfo(const std::string &key) const
Return thinning information for key.
const ThinningDecisionBase * thinning(const std::string &key) const
Return thinning for key.
bool empty() const
Test to see if there's any thinning defined.
void merge(ThinningInfo &info, const std::vector< sgkey_t > &sgkeys, const ThinningDecisionBase &thinning)
Merge a new thinning request into an existing one via AND.
const ITrigNavigationThinningSvc * trigNavigationThinningSvc() const
Return the TrigNavigation helper for this stream, or nullptr.
void setVetoed(const std::string &key, const CxxUtils::ConcurrentBitset &vetoed)
Set vetoed variable information one object.
void setTrigNavigationThinningSvc(const ITrigNavigationThinningSvc *thinning)
Set the TrigNavigation helper for this stream.
void clear()
Clear the cache.
const ITrigNavigationThinningSvc * m_trigNavigationThinningSvc
Optional TrigNavigation thinning helper for this stream.
void lockOwned()
Lock all the ThinningDecisionBase objects that we own.
void setCompression(const std::string &key, const ThinningInfo::compression_map_t &compression)
Set lossy float compression information for the object.
void addThinning(const std::string &key, const std::vector< sgkey_t > &sgkeys, const ThinningDecisionBase *thinning, bool unique=false)
Add thinning information for one object.
Hold thinning decisions for one container.
void thin(size_t ndx)
Mark that index ndx in the container should be thinned away.
Hold thinning/slimming information for a given object.
std::map< unsigned int, CxxUtils::ConcurrentBitset > compression_map_t
This map holds a set of auxids to be lossy compressed for each compression level (nmantissa).
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition merge.py:1