diff --git a/tree/dataframe/inc/ROOT/RDFNodes.hxx b/tree/dataframe/inc/ROOT/RDFNodes.hxx index d568d2cea7991d096c7dc0a0c6eb832fe3ab1972..ddfa09e5b6389241ef028eb8df2ed7fa083c0f24 100644 --- a/tree/dataframe/inc/ROOT/RDFNodes.hxx +++ b/tree/dataframe/inc/ROOT/RDFNodes.hxx @@ -95,7 +95,11 @@ class RLoopManager; /// It only exposes the bare minimum interface required to work as a generic part of the computation graph. /// RDataFrames and results of transformations can be cast to this type via ROOT::RDF::ToCommonNodeType. class RNode { +protected: + RLoopManager *fLoopManager; + public: + RNode(RLoopManager *lm) : fLoopManager(lm) {} virtual ~RNode() {} virtual bool CheckFilters(unsigned int, Long64_t) = 0; virtual void Report(ROOT::RDF::RCutFlowReport &) const = 0; @@ -103,6 +107,7 @@ public: virtual void IncrChildrenCount() = 0; virtual void StopProcessing() = 0; virtual void AddFilterName(std::vector<std::string> &filters) = 0; + RLoopManager *GetLoopManagerUnchecked() const { return fLoopManager; } }; class RLoopManager : public RNode { @@ -198,7 +203,6 @@ public: void BuildJittedNodes(); void Run(); - RLoopManager *GetLoopManagerUnchecked(); const ColumnNames_t &GetDefaultColumnNames() const; TTree *GetTree() const; ::TDirectory *GetDirectory() const; @@ -748,8 +752,6 @@ public: class RFilterBase : public RNode { protected: - RLoopManager *fLoopManager; ///< A raw pointer to the RLoopManager at the root of this functional graph. It is only - /// guaranteed to contain a valid address during an event loop. std::vector<Long64_t> fLastCheckedEntry; std::vector<int> fLastResult = {true}; // std::vector<bool> cannot be used in a MT context safely std::vector<ULong64_t> fAccepted = {0}; @@ -768,7 +770,6 @@ public: virtual ~RFilterBase() { fLoopManager->Deregister(this); } virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0; - RLoopManager *GetLoopManagerUnchecked() const; bool HasName() const; std::string GetName() const; virtual void FillReport(ROOT::RDF::RCutFlowReport &) const; @@ -976,8 +977,6 @@ public: class RRangeBase : public RNode { protected: - RLoopManager *fLoopManager; ///< A raw pointer to the RLoopManager at the root of this functional graph. It is only - /// guaranteed to contain a valid address during an event loop. unsigned int fStart; unsigned int fStop; unsigned int fStride; @@ -998,8 +997,6 @@ public: RRangeBase &operator=(const RRangeBase &) = delete; virtual ~RRangeBase() { fLoopManager->Deregister(this); } - RLoopManager *GetLoopManagerUnchecked() const; - void ResetChildrenCount() { fNChildren = 0; diff --git a/tree/dataframe/src/RDFNodes.cxx b/tree/dataframe/src/RDFNodes.cxx index 384760f887a4237fc728b2e85c97f7db5218894c..c3fae1ac14fb0fb0eb0c29cf9a8b12e4e37ed32a 100644 --- a/tree/dataframe/src/RDFNodes.cxx +++ b/tree/dataframe/src/RDFNodes.cxx @@ -204,16 +204,11 @@ void RJittedCustomColumn::InitNode() RFilterBase::RFilterBase(RLoopManager *implPtr, std::string_view name, const unsigned int nSlots, const RDFInternal::RBookedCustomColumns &customColumns) - : fLoopManager(implPtr), fLastResult(nSlots), fAccepted(nSlots), fRejected(nSlots), fName(name), fNSlots(nSlots), + : RNode(implPtr), fLastResult(nSlots), fAccepted(nSlots), fRejected(nSlots), fName(name), fNSlots(nSlots), fCustomColumns(customColumns) { } -RLoopManager *RFilterBase::GetLoopManagerUnchecked() const -{ - return fLoopManager; -} - bool RFilterBase::HasName() const { return !fName.empty(); @@ -396,20 +391,20 @@ unsigned int TSlotStack::GetSlot() } RLoopManager::RLoopManager(TTree *tree, const ColumnNames_t &defaultBranches) - : fTree(std::shared_ptr<TTree>(tree, [](TTree *) {})), fDefaultColumns(defaultBranches), + : RNode(this), fTree(std::shared_ptr<TTree>(tree, [](TTree *) {})), fDefaultColumns(defaultBranches), fNSlots(RDFInternal::GetNSlots()), fLoopType(ROOT::IsImplicitMTEnabled() ? ELoopType::kROOTFilesMT : ELoopType::kROOTFiles) { } RLoopManager::RLoopManager(ULong64_t nEmptyEntries) - : fNEmptyEntries(nEmptyEntries), fNSlots(RDFInternal::GetNSlots()), + : RNode(this), fNEmptyEntries(nEmptyEntries), fNSlots(RDFInternal::GetNSlots()), fLoopType(ROOT::IsImplicitMTEnabled() ? ELoopType::kNoFilesMT : ELoopType::kNoFiles) { } RLoopManager::RLoopManager(std::unique_ptr<RDataSource> ds, const ColumnNames_t &defaultBranches) - : fDefaultColumns(defaultBranches), fNSlots(RDFInternal::GetNSlots()), + : RNode(this), fDefaultColumns(defaultBranches), fNSlots(RDFInternal::GetNSlots()), fLoopType(ROOT::IsImplicitMTEnabled() ? ELoopType::kDataSourceMT : ELoopType::kDataSource), fDataSource(std::move(ds)) { @@ -688,11 +683,6 @@ void RLoopManager::Run() CleanUpNodes(); } -RLoopManager *RLoopManager::GetLoopManagerUnchecked() -{ - return this; -} - /// Return the list of default columns -- empty if none was provided when constructing the RDataFrame const ColumnNames_t &RLoopManager::GetDefaultColumnNames() const { @@ -780,13 +770,8 @@ std::vector<RDFInternal::RActionBase *> RLoopManager::GetAllActions(){ RRangeBase::RRangeBase(RLoopManager *implPtr, unsigned int start, unsigned int stop, unsigned int stride, const unsigned int nSlots) - : fLoopManager(implPtr), fStart(start), fStop(stop), fStride(stride), fNSlots(nSlots) -{ -} - -RLoopManager *RRangeBase::GetLoopManagerUnchecked() const + : RNode(implPtr), fStart(start), fStop(stop), fStride(stride), fNSlots(nSlots) { - return fLoopManager; } std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode> RLoopManager::GetGraph()