Skip to content

Commit

Permalink
[df] Introduce function to retrieve type of data source
Browse files Browse the repository at this point in the history
Introduce a new method to get a label for the data source that the current RDataFrame is processing. There are three main types:
* The dataframe will process a TTree dataset
* The dataframe will process an empty dataset
* The dataframe will process data from an RDataSource

The function returns a label with the suffix "DS" also for the first two cases, to be aligned as much as possible with the RDataSource infrastructure.
  • Loading branch information
vepadulano committed Sep 23, 2024
1 parent 74b5614 commit 75999ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tree/dataframe/inc/ROOT/RDF/RInterface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class GraphCreatorHelper;
void ChangeEmptyEntryRange(const ROOT::RDF::RNode &node, std::pair<ULong64_t, ULong64_t> &&newRange);
void ChangeSpec(const ROOT::RDF::RNode &node, ROOT::RDF::Experimental::RDatasetSpec &&spec);
void TriggerRun(ROOT::RDF::RNode node);
std::string GetDataSourceLabel(const ROOT::RDF::RNode &node);
} // namespace RDF
} // namespace Internal

Expand Down Expand Up @@ -121,7 +122,7 @@ class RInterface : public RInterfaceBase {
friend void RDFInternal::TriggerRun(RNode node);
friend void RDFInternal::ChangeEmptyEntryRange(const RNode &node, std::pair<ULong64_t, ULong64_t> &&newRange);
friend void RDFInternal::ChangeSpec(const RNode &node, ROOT::RDF::Experimental::RDatasetSpec &&spec);

friend std::string ROOT::Internal::RDF::GetDataSourceLabel(const RNode &node);
std::shared_ptr<Proxied> fProxiedPtr; ///< Smart pointer to the graph node encapsulated by this RInterface.

public:
Expand Down
11 changes: 11 additions & 0 deletions tree/dataframe/src/RInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ void ROOT::Internal::RDF::TriggerRun(ROOT::RDF::RNode node)
{
node.fLoopManager->Run();
}

std::string ROOT::Internal::RDF::GetDataSourceLabel(const ROOT::RDF::RNode &node)
{
if (node.fLoopManager->GetTree()) {
return "TTreeDS";
} else if (node.fDataSource) {
return node.fDataSource->GetLabel();
} else {
return "EmptyDS";
}
}

0 comments on commit 75999ea

Please sign in to comment.