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 DTKeyedConfigListRcd &keyRecord, int cfgId, const DTKeyedConfig *&obj)
 
void getData (const DTKeyedConfigListRcd &keyRecord, 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)
 
const DTKeyedConfigCacheoperator= (const DTKeyedConfigCache &x)
 

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 28 of file DTKeyedConfigCache.h.

Member Typedef Documentation

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

Definition at line 52 of file DTKeyedConfigCache.h.

Constructor & Destructor Documentation

DTKeyedConfigCache::DTKeyedConfigCache ( )

Definition at line 37 of file DTKeyedConfigCache.cc.

DTKeyedConfigCache::~DTKeyedConfigCache ( )
virtual

Definition at line 47 of file DTKeyedConfigCache.cc.

References purge().

47  {
48  purge();
49 }
DTKeyedConfigCache::DTKeyedConfigCache ( const DTKeyedConfigCache x)
private

Member Function Documentation

int DTKeyedConfigCache::get ( const DTKeyedConfigListRcd keyRecord,
int  cfgId,
const DTKeyedConfig *&  obj 
)

Definition at line 52 of file DTKeyedConfigCache.cc.

References brickMap, cachedBrickNumber, cachedByteNumber, cachedStringNumber, DTKeyedConfig::dataBegin(), DTKeyedConfig::dataEnd(), MillePedeFileConverter_cfg::e, mps_splice::entry, cppFunctionSkipper::exception, cond::persistency::KeyList::get(), edm::eventsetup::EventSetupRecord::get(), DTKeyedConfig::getId(), cond::persistency::KeyList::load(), maxBrickNumber, maxByteNumber, maxStringNumber, edm::ESHandle< T >::product(), and findQualityFiles::size.

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

53  {
54 
55  bool cacheFound = false;
56  int cacheAge = 999999999;
57  std::map<int,counted_brick>::iterator cache_iter = brickMap.begin();
58  std::map<int,counted_brick>::iterator cache_icfg = brickMap.find( cfgId );
59  std::map<int,counted_brick>::iterator cache_iend = brickMap.end();
60  if ( cache_icfg != cache_iend ) {
61  std::pair<const int,counted_brick>& entry = *cache_icfg;
62  counted_brick& cBrick = entry.second;
63  cacheAge = cBrick.first;
64  obj = cBrick.second;
65  cacheFound = true;
66  }
67 
68  std::map<int,const DTKeyedConfig*> ageMap;
69  if ( cacheFound ) {
70  if ( !cacheAge ) return 0;
71  while ( cache_iter != cache_iend ) {
72  std::pair<const int,counted_brick>& entry = *cache_iter++;
73  counted_brick& cBrick = entry.second;
74  int& brickAge = cBrick.first;
75  if ( brickAge < cacheAge ) brickAge++;
76  if ( entry.first == cfgId ) brickAge = 0;
77  }
78  return 0;
79  }
80  else {
81  while ( cache_iter != cache_iend ) {
82  std::pair<const int,counted_brick>& entry = *cache_iter++;
83  counted_brick& cBrick = entry.second;
84  ageMap.insert( std::pair<int,const DTKeyedConfig*>(
85  ++cBrick.first, entry.second.second ) );
86  }
87  }
88 
89 // get dummy brick list
91  keyRecord.get( klh );
92  cond::persistency::KeyList const & kl= *klh.product();
93  // This const_cast and usage of KeyList is a problem
94  // that will need to be addressed in the future.
95  // I'm not fixing now, because I want to finish what I am
96  // fixing. One thing at a time. (This was already in the
97  // the code I copied to make this file)
98  cond::persistency::KeyList* keyList = const_cast<cond::persistency::KeyList*>( &kl );
99  if ( keyList == 0 ) return 999;
100 
101  std::vector<unsigned long long> checkedKeys;
102  std::shared_ptr<DTKeyedConfig> kBrick;
103  checkedKeys.push_back( cfgId );
104  bool brickFound = false;
105  try {
106  keyList->load( checkedKeys );
107  kBrick = keyList->get<DTKeyedConfig>( 0 );
108  if ( kBrick.get() ) brickFound = ( kBrick->getId() == cfgId );
109  }
110  catch ( std::exception const & e ) {
111  }
112  if ( brickFound ) {
113  counted_brick cBrick( 0, obj = new DTKeyedConfig( *kBrick ) );
114  brickMap.insert( std::pair<int,counted_brick>( cfgId, cBrick ) );
115  DTKeyedConfig::data_iterator d_iter = kBrick->dataBegin();
116  DTKeyedConfig::data_iterator d_iend = kBrick->dataEnd();
118  cachedStringNumber += ( d_iend - d_iter );
119  while ( d_iter != d_iend ) cachedByteNumber += ( *d_iter++ ).size();
120  }
121  std::map<int,const DTKeyedConfig*>::reverse_iterator iter = ageMap.rbegin();
122  while ( ( cachedBrickNumber > maxBrickNumber ) ||
125  const DTKeyedConfig* oldestBrick = iter->second;
126  int oldestId = oldestBrick->getId();
128  DTKeyedConfig::data_iterator d_iter = oldestBrick->dataBegin();
129  DTKeyedConfig::data_iterator d_iend = oldestBrick->dataEnd();
130  cachedStringNumber -= ( d_iend - d_iter );
131  while ( d_iter != d_iend ) cachedByteNumber -= ( *d_iter++ ).size();
132  brickMap.erase( oldestId );
133  delete iter->second;
134  iter++;
135  }
136 
137  return 999;
138 
139 }
size
Write out results.
std::map< int, counted_brick > brickMap
data_iterator dataBegin() const
void get(HolderT &iHolder) const
static const int maxByteNumber
std::shared_ptr< T > get(size_t n) const
Definition: KeyList.h:40
int getId() const
std::vector< std::string >::const_iterator data_iterator
Definition: DTKeyedConfig.h:58
static const int maxBrickNumber
void load(const std::vector< unsigned long long > &keys)
Definition: KeyList.cc:14
std::pair< int, const DTKeyedConfig * > counted_brick
static const int maxStringNumber
T const * product() const
Definition: ESHandle.h:86
data_iterator dataEnd() const
void DTKeyedConfigCache::getData ( const DTKeyedConfigListRcd keyRecord,
int  cfgId,
std::vector< std::string > &  list 
)

Definition at line 142 of file DTKeyedConfigCache.cc.

References DTKeyedConfig::dataBegin(), DTKeyedConfig::dataEnd(), DTKeyedConfig::linkBegin(), DTKeyedConfig::linkEnd(), and MuonAssociatorByHits_cfi::obj.

Referenced by DTConfigDBProducer::readDTCCBConfig().

144  {
145  const DTKeyedConfig* obj = 0;
146  get( keyRecord, cfgId, obj );
147  if ( obj == 0 ) return;
148  DTKeyedConfig::data_iterator d_iter = obj->dataBegin();
149  DTKeyedConfig::data_iterator d_iend = obj->dataEnd();
150  while ( d_iter != d_iend ) list.push_back( *d_iter++ );
151  DTKeyedConfig::link_iterator l_iter = obj->linkBegin();
152  DTKeyedConfig::link_iterator l_iend = obj->linkEnd();
153  while ( l_iter != l_iend ) getData( keyRecord, *l_iter++, list );
154  return;
155 }
void getData(const DTKeyedConfigListRcd &keyRecord, int cfgId, std::vector< std::string > &list)
data_iterator dataBegin() const
link_iterator linkBegin() const
link_iterator linkEnd() const
std::vector< int >::const_iterator link_iterator
Definition: DTKeyedConfig.h:59
std::vector< std::string >::const_iterator data_iterator
Definition: DTKeyedConfig.h:58
data_iterator dataEnd() const
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
const DTKeyedConfigCache& DTKeyedConfigCache::operator= ( const DTKeyedConfigCache x)
private
void DTKeyedConfigCache::purge ( )

Definition at line 158 of file DTKeyedConfigCache.cc.

References brickMap, cachedBrickNumber, cachedByteNumber, and cachedStringNumber.

Referenced by ~DTKeyedConfigCache().

158  {
159  std::map<int,counted_brick>::const_iterator iter = brickMap.begin();
160  std::map<int,counted_brick>::const_iterator iend = brickMap.end();
161  while ( iter != iend ) {
162  delete iter->second.second;
163  iter++;
164  }
165  brickMap.clear();
166  cachedBrickNumber = 0;
167  cachedStringNumber = 0;
168  cachedByteNumber = 0;
169  return;
170 }
std::map< int, counted_brick > brickMap

Member Data Documentation

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

Definition at line 53 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

int DTKeyedConfigCache::cachedBrickNumber
private

Definition at line 54 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

int DTKeyedConfigCache::cachedByteNumber
private

Definition at line 56 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

int DTKeyedConfigCache::cachedStringNumber
private

Definition at line 55 of file DTKeyedConfigCache.h.

Referenced by get(), and purge().

const int DTKeyedConfigCache::maxBrickNumber = 5000
static

Definition at line 43 of file DTKeyedConfigCache.h.

Referenced by get().

const int DTKeyedConfigCache::maxByteNumber = 10000000
static

Definition at line 45 of file DTKeyedConfigCache.h.

Referenced by get().

const int DTKeyedConfigCache::maxStringNumber = 100000
static

Definition at line 44 of file DTKeyedConfigCache.h.

Referenced by get().