CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 38 of file DTKeyedConfigCache.cc.

DTKeyedConfigCache::~DTKeyedConfigCache ( )
virtual

Definition at line 48 of file DTKeyedConfigCache.cc.

References purge().

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

Member Function Documentation

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

Definition at line 53 of file DTKeyedConfigCache.cc.

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

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

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

Definition at line 143 of file DTKeyedConfigCache.cc.

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

Referenced by DTConfigDBProducer::readDTCCBConfig().

145  {
146  const DTKeyedConfig* obj = 0;
147  get( keyRecord, cfgId, obj );
148  if ( obj == 0 ) return;
149  DTKeyedConfig::data_iterator d_iter = obj->dataBegin();
150  DTKeyedConfig::data_iterator d_iend = obj->dataEnd();
151  while ( d_iter != d_iend ) list.push_back( *d_iter++ );
152  DTKeyedConfig::link_iterator l_iter = obj->linkBegin();
153  DTKeyedConfig::link_iterator l_iend = obj->linkEnd();
154  while ( l_iter != l_iend ) getData( keyRecord, *l_iter++, list );
155  return;
156 }
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 159 of file DTKeyedConfigCache.cc.

References brickMap, cachedBrickNumber, cachedByteNumber, cachedStringNumber, and getDQMSummary::iter.

Referenced by ~DTKeyedConfigCache().

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