CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions
edm::MergeableInputProductResolver Class Reference

#include <ProductResolvers.h>

Inheritance diagram for edm::MergeableInputProductResolver:
edm::DataManagingProductResolver edm::DataManagingOrAliasProductResolver edm::ProductResolverBase edm::DelayedReaderInputProductResolver edm::PutOnReadInputProductResolver

Public Member Functions

 MergeableInputProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
- Public Member Functions inherited from edm::DataManagingProductResolver
void connectTo (ProductResolverBase const &, Principal const *) final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetProductData_ (bool deleteEarly) override
 
void resetStatus ()
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
- Public Member Functions inherited from edm::DataManagingOrAliasProductResolver
 DataManagingOrAliasProductResolver ()
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTaskHolder waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
std::string const & processName () const
 
ProductID const & productID () const
 
std::string const & productInstanceName () const
 
ProductProvenance const * productProvenancePtr () const
 
bool productResolved () const
 
 ProductResolverBase ()
 
 ProductResolverBase (ProductResolverBase const &)=delete
 
TypeID productType () const
 
bool productUnavailable () const
 
bool productWasDeleted () const
 
bool productWasFetchedAndIsValid (bool iSkipCurrentProcess) const
 
Provenance const * provenance () const
 
bool provenanceAvailable () const
 
void resetBranchDescription (std::shared_ptr< BranchDescription const > bd)
 
void resetProductData ()
 
std::string const & resolvedModuleLabel () const
 
Resolution resolveProduct (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void retrieveAndMerge (Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
 
void setMergeableRunProductMetadata (MergeableRunProductMetadata const *mrpm)
 
void setProductID (ProductID const &pid)
 
void setProductProvenanceRetriever (ProductProvenanceRetriever const *provRetriever)
 
virtual void setupUnscheduled (UnscheduledConfigurator const &)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 

Protected Member Functions

void mergeProduct (std::shared_ptr< WrapperBase > edp, MergeableRunProductMetadata const *) const
 
void setOrMergeProduct (std::shared_ptr< WrapperBase > prod, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
 
- Protected Member Functions inherited from edm::DataManagingProductResolver
void checkType (WrapperBase const &prod) const
 
ProductStatus defaultStatus () const
 
ProductData const & getProductData () const final
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setMergeableRunProductMetadataInProductData (MergeableRunProductMetadata const *)
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
void setProduct (std::shared_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Additional Inherited Members

- Public Types inherited from edm::DataManagingProductResolver
enum  ProductStatus {
  ProductStatus::ProductSet, ProductStatus::NotPut, ProductStatus::ResolveFailed, ProductStatus::ResolveNotRun,
  ProductStatus::ProductDeleted
}
 

Detailed Description

Definition at line 106 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ MergeableInputProductResolver()

edm::MergeableInputProductResolver::MergeableInputProductResolver ( std::shared_ptr< BranchDescription const >  bd,
ProductStatus  iDefaultStatus 
)
inline

Definition at line 108 of file ProductResolvers.h.

109  : DataManagingProductResolver(bd, iDefaultStatus) {}
DataManagingProductResolver(std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)

Member Function Documentation

◆ mergeProduct()

void edm::MergeableInputProductResolver::mergeProduct ( std::shared_ptr< WrapperBase edp,
MergeableRunProductMetadata const *  mergeableRunProductMetadata 
) const
protected

Definition at line 79 of file ProductResolvers.cc.

References cms::cuda::assert(), edm::ProductResolverBase::branchDescription(), edm::BranchDescription::branchName(), edm::DataManagingProductResolver::checkType(), submitPVResolutionJobs::desc, Exception, edm::MergeableRunProductMetadata::getMergeDecision(), edm::DataManagingProductResolver::getProductData(), edm::InRun, edm::MergeableRunProductMetadata::MERGE, edm::errors::MismatchedInputFiles, eostools::move(), definitions::original, edm::DataManagingProductResolver::ProductSet, edm::MergeableRunProductMetadata::REPLACE, edm::DataManagingProductResolver::ResolveFailed, edm::DataManagingProductResolver::setProduct(), edm::DataManagingProductResolver::status(), and edm::ProductData::unsafe_wrapper().

Referenced by setOrMergeProduct().

80  {
81  // if its not mergeable and the previous read failed, go ahead and use this one
83  setProduct(std::move(iFrom));
84  return;
85  }
86 
88  if (not iFrom) {
89  return;
90  }
91 
92  checkType(*iFrom);
93 
95  if (original->isMergeable()) {
96  if (original->isPresent() != iFrom->isPresent()) {
98  << "Merge of Run or Lumi product failed for branch " << branchDescription().branchName() << "\n"
99  << "Was trying to merge objects where one product had been put in the input file and the other had not "
100  "been."
101  << "\n"
102  << "The solution is to drop the branch on input. Or better do not create inconsistent files\n"
103  << "that need to be merged in the first place.\n";
104  }
105  if (original->isPresent()) {
106  BranchDescription const& desc = branchDescription();
107  if (mergeableRunProductMetadata == nullptr || desc.branchType() != InRun) {
108  original->mergeProduct(iFrom.get());
109  } else {
111  mergeableRunProductMetadata->getMergeDecision(desc.processName());
112  if (decision == MergeableRunProductMetadata::MERGE) {
113  original->mergeProduct(iFrom.get());
114  } else if (decision == MergeableRunProductMetadata::REPLACE) {
115  // Note this swaps the content of the product where the
116  // both products branches are present and the product is
117  // also present (was put) in the branch. A module might
118  // have already gotten a pointer to the product so we
119  // keep those pointers valid. This does not call swap
120  // on the Wrapper.
121  original->swapProduct(iFrom.get());
122  }
123  // If the decision is IGNORE, do nothing
124  }
125  }
126  // If both have isPresent false, do nothing
127 
128  } else if (original->hasIsProductEqual()) {
129  if (original->isPresent() && iFrom->isPresent()) {
130  if (!original->isProductEqual(iFrom.get())) {
131  auto const& bd = branchDescription();
132  edm::LogError("RunLumiMerging")
133  << "ProductResolver::mergeTheProduct\n"
134  << "Two run/lumi products for the same run/lumi which should be equal are not\n"
135  << "Using the first, ignoring the second\n"
136  << "className = " << bd.className() << "\n"
137  << "moduleLabel = " << bd.moduleLabel() << "\n"
138  << "instance = " << bd.productInstanceName() << "\n"
139  << "process = " << bd.processName() << "\n";
140  }
141  } else if (!original->isPresent() && iFrom->isPresent()) {
142  setProduct(std::move(iFrom));
143  }
144  // if not iFrom->isPresent(), do nothing
145  } else {
146  auto const& bd = branchDescription();
147  edm::LogWarning("RunLumiMerging") << "ProductResolver::mergeTheProduct\n"
148  << "Run/lumi product has neither a mergeProduct nor isProductEqual function\n"
149  << "Using the first, ignoring the second in merge\n"
150  << "className = " << bd.className() << "\n"
151  << "moduleLabel = " << bd.moduleLabel() << "\n"
152  << "instance = " << bd.productInstanceName() << "\n"
153  << "process = " << bd.processName() << "\n";
154  if (!original->isPresent() && iFrom->isPresent()) {
155  setProduct(std::move(iFrom));
156  }
157  // In other cases, do nothing
158  }
159  }
void checkType(WrapperBase const &prod) const
Log< level::Error, false > LogError
assert(be >=bs)
ProductData const & getProductData() const final
std::string const & branchName() const
WrapperBase * unsafe_wrapper() const
Definition: ProductData.h:36
BranchDescription const & branchDescription() const
void setProduct(std::unique_ptr< WrapperBase > edp) const
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511

◆ setOrMergeProduct()

void edm::MergeableInputProductResolver::setOrMergeProduct ( std::shared_ptr< WrapperBase prod,
MergeableRunProductMetadata const *  mergeableRunProductMetadata 
) const
protected

Definition at line 256 of file ProductResolvers.cc.

References edm::DataManagingProductResolver::defaultStatus(), mergeProduct(), eostools::move(), dumpMFGeometry_cfg::prod, edm::DataManagingProductResolver::setProduct(), and edm::DataManagingProductResolver::status().

Referenced by edm::PutOnReadInputProductResolver::putOrMergeProduct(), and edm::DelayedReaderInputProductResolver::retrieveAndMerge_().

257  {
258  if (status() == defaultStatus()) {
259  //resolveProduct has not been called or it failed
261  } else {
262  mergeProduct(std::move(prod), mergeableRunProductMetadata);
263  }
264  }
void mergeProduct(std::shared_ptr< WrapperBase > edp, MergeableRunProductMetadata const *) const
ProductStatus defaultStatus() const
void setProduct(std::unique_ptr< WrapperBase > edp) const
def move(src, dest)
Definition: eostools.py:511