CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
DTKeyedConfigCache Class Reference

#include <DTKeyedConfigCache.h>

Public Member Functions

 DTKeyedConfigCache ()
 
int get (const cond::persistency::KeyList &keyList, int cfgId, const DTKeyedConfig *&obj)
 
void getData (const cond::persistency::KeyList &keyList, int cfgId, std::vector< std::string > &list)
 
void purge ()
 
virtual ~DTKeyedConfigCache ()
 

Static Public Attributes

static const int maxBrickNumber = 5000
 
static const int maxByteNumber = 10000000
 
static const int maxStringNumber = 100000
 

Private Types

typedef std::pair< int, const DTKeyedConfig * > counted_brick
 

Private Member Functions

 DTKeyedConfigCache (const DTKeyedConfigCache &x)=delete
 
const DTKeyedConfigCacheoperator= (const DTKeyedConfigCache &x)=delete
 

Private Attributes

std::map< int, counted_brickbrickMap
 
int cachedBrickNumber
 
int cachedByteNumber
 
int cachedStringNumber
 

Detailed Description

Description: Class to hold configuration identifier for chambers

This class was originally defined in CondCore/DTPlugins/interface/DTConfigPluginHandler.h It was moved, renamed, and modified to not be a singleton for thread safety, but otherwise little was changed.

Author
Paolo Ronchese INFN Padova

Definition at line 29 of file DTKeyedConfigCache.h.

Member Typedef Documentation

◆ counted_brick

typedef std::pair<int, const DTKeyedConfig*> DTKeyedConfigCache::counted_brick
private

Definition at line 48 of file DTKeyedConfigCache.h.

Constructor & Destructor Documentation

◆ DTKeyedConfigCache() [1/2]

DTKeyedConfigCache::DTKeyedConfigCache ( )

Definition at line 35 of file DTKeyedConfigCache.cc.

◆ ~DTKeyedConfigCache()

DTKeyedConfigCache::~DTKeyedConfigCache ( )
virtual

Definition at line 40 of file DTKeyedConfigCache.cc.

40 { purge(); }

References purge().

◆ DTKeyedConfigCache() [2/2]

DTKeyedConfigCache::DTKeyedConfigCache ( const DTKeyedConfigCache x)
privatedelete

Member Function Documentation

◆ get()

int DTKeyedConfigCache::get ( const cond::persistency::KeyList keyList,
int  cfgId,
const DTKeyedConfig *&  obj 
)

Definition at line 42 of file DTKeyedConfigCache.cc.

42  {
43  bool cacheFound = false;
44  int cacheAge = 999999999;
45  std::map<int, counted_brick>::iterator cache_iter = brickMap.begin();
46  std::map<int, counted_brick>::iterator cache_icfg = brickMap.find(cfgId);
47  std::map<int, counted_brick>::iterator cache_iend = brickMap.end();
48  if (cache_icfg != cache_iend) {
49  std::pair<const int, counted_brick>& entry = *cache_icfg;
50  counted_brick& cBrick = entry.second;
51  cacheAge = cBrick.first;
52  obj = cBrick.second;
53  cacheFound = true;
54  }
55 
56  std::map<int, const DTKeyedConfig*> ageMap;
57  if (cacheFound) {
58  if (!cacheAge)
59  return 0;
60  while (cache_iter != cache_iend) {
61  std::pair<const int, counted_brick>& entry = *cache_iter++;
62  counted_brick& cBrick = entry.second;
63  int& brickAge = cBrick.first;
64  if (brickAge < cacheAge)
65  brickAge++;
66  if (entry.first == cfgId)
67  brickAge = 0;
68  }
69  return 0;
70  } else {
71  while (cache_iter != cache_iend) {
72  std::pair<const int, counted_brick>& entry = *cache_iter++;
73  counted_brick& cBrick = entry.second;
74  ageMap.insert(std::pair<int, const DTKeyedConfig*>(++cBrick.first, entry.second.second));
75  }
76  }
77 
78  std::shared_ptr<DTKeyedConfig> kBrick;
79  bool brickFound = false;
80  try {
81  kBrick = keyList.getUsingKey<DTKeyedConfig>(cfgId);
82  if (kBrick.get())
83  brickFound = (kBrick->getId() == cfgId);
84  } catch (std::exception const& e) {
85  }
86  if (brickFound) {
87  counted_brick cBrick(0, obj = new DTKeyedConfig(*kBrick));
88  brickMap.insert(std::pair<int, counted_brick>(cfgId, cBrick));
89  DTKeyedConfig::data_iterator d_iter = kBrick->dataBegin();
90  DTKeyedConfig::data_iterator d_iend = kBrick->dataEnd();
92  cachedStringNumber += (d_iend - d_iter);
93  while (d_iter != d_iend)
94  cachedByteNumber += (*d_iter++).size();
95  }
96  std::map<int, const DTKeyedConfig*>::reverse_iterator iter = ageMap.rbegin();
99  const DTKeyedConfig* oldestBrick = iter->second;
100  int oldestId = oldestBrick->getId();
102  DTKeyedConfig::data_iterator d_iter = oldestBrick->dataBegin();
103  DTKeyedConfig::data_iterator d_iend = oldestBrick->dataEnd();
104  cachedStringNumber -= (d_iend - d_iter);
105  while (d_iter != d_iend)
106  cachedByteNumber -= (*d_iter++).size();
107  brickMap.erase(oldestId);
108  delete iter->second;
109  iter++;
110  }
111 
112  return 999;
113 }

References brickMap, cachedBrickNumber, cachedByteNumber, cachedStringNumber, DTKeyedConfig::dataBegin(), DTKeyedConfig::dataEnd(), MillePedeFileConverter_cfg::e, mps_splice::entry, cppFunctionSkipper::exception, DTKeyedConfig::getId(), cond::persistency::KeyList::getUsingKey(), maxBrickNumber, maxByteNumber, maxStringNumber, getGTfromDQMFile::obj, and findQualityFiles::size.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), getData(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), util.rrapi.RRApi::report(), util.rrapi.RRApi::reports(), rrapi.RRApi::reports(), util.rrapi.RRApi::tables(), rrapi.RRApi::tables(), util.rrapi.RRApi::tags(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), rrapi.RRApi::workspaces(), and util.rrapi.RRApi::workspaces().

◆ getData()

void DTKeyedConfigCache::getData ( const cond::persistency::KeyList keyList,
int  cfgId,
std::vector< std::string > &  list 
)

Definition at line 115 of file DTKeyedConfigCache.cc.

115  {
116  const DTKeyedConfig* obj = nullptr;
117  get(keyList, cfgId, obj);
118  if (obj == nullptr)
119  return;
120  DTKeyedConfig::data_iterator d_iter = obj->dataBegin();
121  DTKeyedConfig::data_iterator d_iend = obj->dataEnd();
122  while (d_iter != d_iend)
123  list.push_back(*d_iter++);
124  DTKeyedConfig::link_iterator l_iter = obj->linkBegin();
125  DTKeyedConfig::link_iterator l_iend = obj->linkEnd();
126  while (l_iter != l_iend)
127  getData(keyList, *l_iter++, list);
128  return;
129 }

References get(), list(), and getGTfromDQMFile::obj.

Referenced by DTConfigDBProducer::readDTCCBConfig().

◆ operator=()

const DTKeyedConfigCache& DTKeyedConfigCache::operator= ( const DTKeyedConfigCache x)
privatedelete

◆ purge()

void DTKeyedConfigCache::purge ( )

Definition at line 131 of file DTKeyedConfigCache.cc.

131  {
132  std::map<int, counted_brick>::const_iterator iter = brickMap.begin();
133  std::map<int, counted_brick>::const_iterator iend = brickMap.end();
134  while (iter != iend) {
135  delete iter->second.second;
136  iter++;
137  }
138  brickMap.clear();
139  cachedBrickNumber = 0;
140  cachedStringNumber = 0;
141  cachedByteNumber = 0;
142  return;
143 }

References brickMap, cachedBrickNumber, cachedByteNumber, and cachedStringNumber.

Referenced by ~DTKeyedConfigCache().

Member Data Documentation

◆ brickMap

std::map<int, counted_brick> DTKeyedConfigCache::brickMap
private

Definition at line 49 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

◆ cachedBrickNumber

int DTKeyedConfigCache::cachedBrickNumber
private

Definition at line 50 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

◆ cachedByteNumber

int DTKeyedConfigCache::cachedByteNumber
private

Definition at line 52 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

◆ cachedStringNumber

int DTKeyedConfigCache::cachedStringNumber
private

Definition at line 51 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

◆ maxBrickNumber

const int DTKeyedConfigCache::maxBrickNumber = 5000
static

Definition at line 40 of file DTKeyedConfigCache.h.

Referenced by get().

◆ maxByteNumber

const int DTKeyedConfigCache::maxByteNumber = 10000000
static

Definition at line 42 of file DTKeyedConfigCache.h.

Referenced by get().

◆ maxStringNumber

const int DTKeyedConfigCache::maxStringNumber = 100000
static

Definition at line 41 of file DTKeyedConfigCache.h.

Referenced by get().

mps_splice.entry
entry
Definition: mps_splice.py:68
cond::persistency::KeyList::getUsingKey
std::shared_ptr< T > getUsingKey(unsigned long long key) const
Definition: KeyList.h:57
DTKeyedConfigCache::maxStringNumber
static const int maxStringNumber
Definition: DTKeyedConfigCache.h:41
DTKeyedConfigCache::getData
void getData(const cond::persistency::KeyList &keyList, int cfgId, std::vector< std::string > &list)
Definition: DTKeyedConfigCache.cc:115
DTKeyedConfig::data_iterator
std::vector< std::string >::const_iterator data_iterator
Definition: DTKeyedConfig.h:54
DTKeyedConfigCache::brickMap
std::map< int, counted_brick > brickMap
Definition: DTKeyedConfigCache.h:49
DTKeyedConfigCache::cachedBrickNumber
int cachedBrickNumber
Definition: DTKeyedConfigCache.h:50
DTKeyedConfigCache::counted_brick
std::pair< int, const DTKeyedConfig * > counted_brick
Definition: DTKeyedConfigCache.h:48
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
DTKeyedConfig::getId
int getId() const
Definition: DTKeyedConfig.cc:53
DTKeyedConfigCache::cachedByteNumber
int cachedByteNumber
Definition: DTKeyedConfigCache.h:52
DTKeyedConfig
Definition: DTKeyedConfig.h:35
DTKeyedConfigCache::maxByteNumber
static const int maxByteNumber
Definition: DTKeyedConfigCache.h:42
DTKeyedConfigCache::maxBrickNumber
static const int maxBrickNumber
Definition: DTKeyedConfigCache.h:40
DTKeyedConfigCache::purge
void purge()
Definition: DTKeyedConfigCache.cc:131
DTKeyedConfigCache::get
int get(const cond::persistency::KeyList &keyList, int cfgId, const DTKeyedConfig *&obj)
Definition: DTKeyedConfigCache.cc:42
DTKeyedConfig::dataBegin
data_iterator dataBegin() const
Definition: DTKeyedConfig.cc:61
DTKeyedConfig::dataEnd
data_iterator dataEnd() const
Definition: DTKeyedConfig.cc:63
DTKeyedConfig::link_iterator
std::vector< int >::const_iterator link_iterator
Definition: DTKeyedConfig.h:55
list
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*", "!HLTx*" if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL. It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of "!*" before the partial wildcard feature was incorporated). Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DTKeyedConfigCache::cachedStringNumber
int cachedStringNumber
Definition: DTKeyedConfigCache.h:51