CMS 3D CMS Logo

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
 
ProductProvenance const * branchIDToProvenanceForProducedOnly (BranchID const &bid) const
 
void deepCopy (ProductProvenanceRetriever const &)
 
void insertIntoSet (ProductProvenance provenanceProduct) const
 
void mergeParentProcessRetriever (ProductProvenanceRetriever const &provRetriever)
 
void mergeProvenanceRetrievers (std::shared_ptr< ProductProvenanceRetriever > other)
 
ProductProvenanceRetrieveroperator= (ProductProvenanceRetriever const &)=delete
 
 ProductProvenanceRetriever (unsigned int iTransitionIndex)
 
 ProductProvenanceRetriever (std::unique_ptr< ProvenanceReaderBase > reader)
 
void readProvenanceAsync (WaitingTask *task, ModuleCallingContext const *moduleCallingContext) const
 
void reset ()
 
 ~ProductProvenanceRetriever ()
 

Private Member Functions

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

Private Attributes

tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqualentryInfoSet_
 
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
 
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
 
std::shared_ptr< const ProvenanceReaderBaseprovenanceReader_
 
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
 
unsigned int transitionIndex_
 

Detailed Description

Definition at line 55 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_(),
17  parentProcessRetriever_(nullptr),
19  transitionIndex_(iTransitionIndex){
20  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
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 22 of file ProductProvenanceRetriever.cc.

References provenanceReader_.

22  :
23  entryInfoSet_(),
26  parentProcessRetriever_(nullptr),
27  provenanceReader_(reader.release()),
29  {
30  assert(provenanceReader_);
31  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
edm::ProductProvenanceRetriever::~ProductProvenanceRetriever ( )

Definition at line 33 of file ProductProvenanceRetriever.cc.

References readEntryInfoSet_.

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

Member Function Documentation

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

Definition at line 114 of file ProductProvenanceRetriever.cc.

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

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

114  {
115  ProductProvenance ei(bid);
116  auto it = entryInfoSet_.find(ei);
117  if(it == entryInfoSet_.end()) {
119  return parentProcessRetriever_->branchIDToProvenance(bid);
120  }
121  //check in source
122  readProvenance();
123  auto ptr =readEntryInfoSet_.load();
124  if(ptr) {
125  auto it = ptr->find(ei);
126  if(it!= ptr->end()) {
127  return &*it;
128  }
129  }
130  if(nextRetriever_) {
131  return nextRetriever_->branchIDToProvenance(bid);
132  }
133  return nullptr;
134  }
135  return &*it;
136  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
ProductProvenance const * edm::ProductProvenanceRetriever::branchIDToProvenanceForProducedOnly ( BranchID const &  bid) const

Definition at line 139 of file ProductProvenanceRetriever.cc.

References entryInfoSet_, nextRetriever_, and parentProcessRetriever_.

Referenced by edm::PoolOutputModule::updateBranchParentsForOneBranch().

139  {
140  ProductProvenance ei(bid);
141  auto it = entryInfoSet_.find(ei);
142  if(it == entryInfoSet_.end()) {
144  return parentProcessRetriever_->branchIDToProvenanceForProducedOnly(bid);
145  }
146  if(nextRetriever_) {
147  return nextRetriever_->branchIDToProvenanceForProducedOnly(bid);
148  }
149  return nullptr;
150  }
151  return &*it;
152  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
void edm::ProductProvenanceRetriever::deepCopy ( ProductProvenanceRetriever const &  iFrom)

Definition at line 59 of file ProductProvenanceRetriever.cc.

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

60  {
61  if(iFrom.readEntryInfoSet_) {
62  if (readEntryInfoSet_) {
63  delete readEntryInfoSet_.exchange(nullptr);
64  }
65  readEntryInfoSet_ = new std::set<ProductProvenance>(*iFrom.readEntryInfoSet_);
66  } else {
67  if(readEntryInfoSet_) {
68  delete readEntryInfoSet_.load();
69  readEntryInfoSet_ = nullptr;
70  }
71  }
72  entryInfoSet_ = iFrom.entryInfoSet_;
73  provenanceReader_ = iFrom.provenanceReader_;
74 
75  if(iFrom.nextRetriever_) {
76  if(not nextRetriever_) {
77  nextRetriever_ = std::make_shared<ProductProvenanceRetriever>(transitionIndex_);
78  }
79  nextRetriever_->deepCopy(*(iFrom.nextRetriever_));
80  }
81  }
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  provenanceProduct) const

Definition at line 95 of file ProductProvenanceRetriever.cc.

References entryInfoSet_, and eostools::move().

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

95  {
96  //NOTE:do not read provenance here because we only need the full
97  // provenance when someone tries to access it not when doing the insert
98  // doing the delay saves 20% of time when doing an analysis job
99  //readProvenance();
100  entryInfoSet_.insert(std::move(entryInfo));
101  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
def move(src, dest)
Definition: eostools.py:511
void edm::ProductProvenanceRetriever::mergeParentProcessRetriever ( ProductProvenanceRetriever const &  provRetriever)

Definition at line 109 of file ProductProvenanceRetriever.cc.

References parentProcessRetriever_.

109  {
110  parentProcessRetriever_ = &provRetriever;
111  }
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
void edm::ProductProvenanceRetriever::mergeProvenanceRetrievers ( std::shared_ptr< ProductProvenanceRetriever other)

Definition at line 104 of file ProductProvenanceRetriever.cc.

References nextRetriever_, and trackingPlots::other.

104  {
106  }
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
ProductProvenanceRetriever& edm::ProductProvenanceRetriever::operator= ( ProductProvenanceRetriever const &  )
delete
void edm::ProductProvenanceRetriever::readProvenance ( ) const
private

Definition at line 38 of file ProductProvenanceRetriever.cc.

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

Referenced by branchIDToProvenance().

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

Definition at line 49 of file ProductProvenanceRetriever.cc.

References nextRetriever_, provenanceReader_, readEntryInfoSet_, and transitionIndex_.

49  {
50  if(provenanceReader_ and nullptr == readEntryInfoSet_.load() ) {
51  provenanceReader_->readProvenanceAsync(task, moduleCallingContext,transitionIndex_,readEntryInfoSet_);
52  }
53  if(nextRetriever_) {
54  nextRetriever_->readProvenanceAsync(task,moduleCallingContext);
55  }
56  }
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
void edm::ProductProvenanceRetriever::reset ( void  )

Definition at line 84 of file ProductProvenanceRetriever.cc.

References entryInfoSet_, nextRetriever_, parentProcessRetriever_, and readEntryInfoSet_.

84  {
85  delete readEntryInfoSet_.load();
86  readEntryInfoSet_ = nullptr;
87  entryInfoSet_.clear();
88  if(nextRetriever_) {
89  nextRetriever_->reset();
90  }
91  parentProcessRetriever_ = nullptr;
92  }
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
edm::propagate_const< ProductProvenanceRetriever const * > parentProcessRetriever_
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 82 of file ProductProvenanceRetriever.h.

82  {
83  transitionIndex_=transitionIndex;
84  }

Member Data Documentation

tbb::concurrent_unordered_set<ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual> edm::ProductProvenanceRetriever::entryInfoSet_
mutableprivate
edm::propagate_const<std::shared_ptr<ProductProvenanceRetriever> > edm::ProductProvenanceRetriever::nextRetriever_
private
edm::propagate_const<ProductProvenanceRetriever const*> edm::ProductProvenanceRetriever::parentProcessRetriever_
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 91 of file ProductProvenanceRetriever.h.

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