CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::ProductProvenanceRetriever Class Reference

#include <ProductProvenanceRetriever.h>

Public Member Functions

ProductProvenance const * branchIDToProvenance (BranchID const &bid) const
 
void deepCopy (ProductProvenanceRetriever const &)
 
void insertIntoSet (ProductProvenance const &provenanceProduct) const
 
void mergeProvenanceRetrievers (std::shared_ptr< ProductProvenanceRetriever > other)
 
ProductProvenanceRetrieveroperator= (ProductProvenanceRetriever const &)=delete
 
 ProductProvenanceRetriever (unsigned int iTransitionIndex)
 
 ProductProvenanceRetriever (std::unique_ptr< ProvenanceReaderBase > reader)
 
void reset ()
 
 ~ProductProvenanceRetriever ()
 

Private Member Functions

void readProvenance () const
 
void setTransitionIndex (unsigned int transitionIndex)
 

Private Attributes

tbb::concurrent_unordered_set
< ProductProvenance,
ProductProvenanceHasher,
ProductProvenanceEqual
entryInfoSet_
 
edm::propagate_const
< std::shared_ptr
< ProductProvenanceRetriever > > 
nextRetriever_
 
std::shared_ptr< const
ProvenanceReaderBase
provenanceReader_
 
std::atomic< const std::set
< ProductProvenance > * > 
readEntryInfoSet_
 
unsigned int transitionIndex_
 

Detailed Description

Definition at line 41 of file ProductProvenanceRetriever.h.

Constructor & Destructor Documentation

edm::ProductProvenanceRetriever::ProductProvenanceRetriever ( unsigned int  iTransitionIndex)
explicit

Definition at line 13 of file ProductProvenanceRetriever.cc.

13  :
14  entryInfoSet_(),
18  transitionIndex_(iTransitionIndex){
19  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
edm::ProductProvenanceRetriever::ProductProvenanceRetriever ( std::unique_ptr< ProvenanceReaderBase reader)
explicit

Definition at line 21 of file ProductProvenanceRetriever.cc.

References assert(), and provenanceReader_.

21  :
22  entryInfoSet_(),
25  provenanceReader_(reader.release()),
27  {
29  }
assert(m_qm.get())
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
edm::ProductProvenanceRetriever::~ProductProvenanceRetriever ( )

Definition at line 31 of file ProductProvenanceRetriever.cc.

References readEntryInfoSet_.

31  {
32  delete readEntryInfoSet_.load();
33  }
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_

Member Function Documentation

ProductProvenance const * edm::ProductProvenanceRetriever::branchIDToProvenance ( BranchID const &  bid) const

Definition at line 95 of file ProductProvenanceRetriever.cc.

References entryInfoSet_, nextRetriever_, readEntryInfoSet_, and readProvenance().

Referenced by edm::RootOutputFile::insertAncestors(), and edm::Provenance::productProvenance().

95  {
96  ProductProvenance ei(bid);
97  auto it = entryInfoSet_.find(ei);
98  if(it == entryInfoSet_.end()) {
99  //check in source
100  readProvenance();
101  auto ptr =readEntryInfoSet_.load();
102  if(ptr) {
103  auto it = ptr->find(ei);
104  if(it!= ptr->end()) {
105  return &*it;
106  }
107  }
108  if(nextRetriever_) {
109  return nextRetriever_->branchIDToProvenance(bid);
110  }
111  return nullptr;
112  }
113  return &*it;
114  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
void edm::ProductProvenanceRetriever::deepCopy ( ProductProvenanceRetriever const &  iFrom)

Definition at line 46 of file ProductProvenanceRetriever.cc.

References entryInfoSet_, nextRetriever_, provenanceReader_, readEntryInfoSet_, and transitionIndex_.

47  {
48  if(iFrom.readEntryInfoSet_) {
49  if (readEntryInfoSet_) {
50  delete readEntryInfoSet_.exchange(nullptr);
51  }
52  readEntryInfoSet_ = new std::set<ProductProvenance>(*iFrom.readEntryInfoSet_);
53  } else {
54  if(readEntryInfoSet_) {
55  delete readEntryInfoSet_.load();
56  readEntryInfoSet_ = nullptr;
57  }
58  }
59  entryInfoSet_ = iFrom.entryInfoSet_;
60  provenanceReader_ = iFrom.provenanceReader_;
61 
62  if(iFrom.nextRetriever_) {
63  if(not nextRetriever_) {
64  nextRetriever_ = std::make_shared<ProductProvenanceRetriever>(transitionIndex_);
65  }
66  nextRetriever_->deepCopy(*(iFrom.nextRetriever_));
67  }
68  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
void edm::ProductProvenanceRetriever::insertIntoSet ( ProductProvenance const &  provenanceProduct) const

Definition at line 81 of file ProductProvenanceRetriever.cc.

References entryInfoSet_.

Referenced by edm::EventPrincipal::put(), and edm::EventPrincipal::putOnRead().

81  {
82  //NOTE:do not read provenance here because we only need the full
83  // provenance when someone tries to access it not when doing the insert
84  // doing the delay saves 20% of time when doing an analysis job
85  //readProvenance();
86  entryInfoSet_.insert(entryInfo);
87  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
void edm::ProductProvenanceRetriever::mergeProvenanceRetrievers ( std::shared_ptr< ProductProvenanceRetriever other)

Definition at line 90 of file ProductProvenanceRetriever.cc.

References nextRetriever_.

90  {
91  nextRetriever_ = other;
92  }
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
ProductProvenanceRetriever& edm::ProductProvenanceRetriever::operator= ( ProductProvenanceRetriever const &  )
delete
void edm::ProductProvenanceRetriever::readProvenance ( ) const
private

Definition at line 36 of file ProductProvenanceRetriever.cc.

References provenanceReader_, readEntryInfoSet_, groupFilesInBlocks::temp, and transitionIndex_.

Referenced by branchIDToProvenance().

36  {
37  if(nullptr == readEntryInfoSet_.load() && provenanceReader_) {
38  auto temp = std::make_unique<std::set<ProductProvenance> const>(provenanceReader_->readProvenance(transitionIndex_));
39  std::set<ProductProvenance> const* expected = nullptr;
40  if(readEntryInfoSet_.compare_exchange_strong(expected, temp.get())) {
41  temp.release();
42  }
43  }
44  }
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
void edm::ProductProvenanceRetriever::reset ( void  )

Definition at line 71 of file ProductProvenanceRetriever.cc.

References entryInfoSet_, nextRetriever_, and readEntryInfoSet_.

71  {
72  delete readEntryInfoSet_.load();
73  readEntryInfoSet_ = nullptr;
74  entryInfoSet_.clear();
75  if(nextRetriever_) {
76  nextRetriever_->reset();
77  }
78  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
void edm::ProductProvenanceRetriever::setTransitionIndex ( unsigned int  transitionIndex)
inlineprivate

Definition at line 61 of file ProductProvenanceRetriever.h.

References transitionIndex_.

61  {
62  transitionIndex_=transitionIndex;
63  }

Member Data Documentation

tbb::concurrent_unordered_set<ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual> edm::ProductProvenanceRetriever::entryInfoSet_
mutableprivate

Definition at line 65 of file ProductProvenanceRetriever.h.

Referenced by branchIDToProvenance(), deepCopy(), insertIntoSet(), and reset().

edm::propagate_const<std::shared_ptr<ProductProvenanceRetriever> > edm::ProductProvenanceRetriever::nextRetriever_
private
std::shared_ptr<const ProvenanceReaderBase> edm::ProductProvenanceRetriever::provenanceReader_
private
std::atomic<const std::set<ProductProvenance>*> edm::ProductProvenanceRetriever::readEntryInfoSet_
mutableprivate
unsigned int edm::ProductProvenanceRetriever::transitionIndex_
private

Definition at line 69 of file ProductProvenanceRetriever.h.

Referenced by deepCopy(), readProvenance(), and setTransitionIndex().