20std::shared_ptr<GraphDrawing::GraphNode>
22 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap)
26 auto duplicateDefineIt = visitedMap.find((
void *)columnPtr);
27 if (duplicateDefineIt != visitedMap.end())
28 return duplicateDefineIt->second;
30 auto node = std::make_shared<GraphNode>(
"Define\\n" + columnName, visitedMap.size(), ENodeType::kDefine);
31 visitedMap[(
void *)columnPtr] = node;
35std::shared_ptr<GraphDrawing::GraphNode>
37 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap)
40 auto duplicateFilterIt = visitedMap.find((
void *)filterPtr);
41 if (duplicateFilterIt != visitedMap.end()) {
42 duplicateFilterIt->second->SetNotNew();
43 return duplicateFilterIt->second;
46 auto node = std::make_shared<GraphNode>((filterPtr->
HasName() ? filterPtr->
GetName() :
"Filter"), visitedMap.size(),
48 visitedMap[(
void *)filterPtr] = node;
52std::shared_ptr<GraphDrawing::GraphNode>
54 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap)
57 auto duplicateRangeIt = visitedMap.find((
void *)rangePtr);
58 if (duplicateRangeIt != visitedMap.end()) {
59 duplicateRangeIt->second->SetNotNew();
60 return duplicateRangeIt->second;
63 auto node = std::make_shared<GraphNode>(
"Range", visitedMap.size(), ENodeType::kRange);
64 visitedMap[(
void *)rangePtr] = node;
68std::shared_ptr<GraphDrawing::GraphNode>
70 const std::vector<std::string> &prevNodeDefines,
71 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap)
73 auto upmostNode = node;
74 const auto &defineNames = colRegister.
GetNames();
75 for (
auto i =
int(defineNames.size()) - 1; i >= 0; --i) {
76 const auto colName = defineNames[i];
80 const bool isANewDefine =
81 std::find(prevNodeDefines.begin(), prevNodeDefines.end(), colName) == prevNodeDefines.end();
87 upmostNode->SetPrevNode(defineNode);
88 upmostNode = defineNode;
94namespace GraphDrawing {
99 std::stringstream dotStringLabels;
101 std::stringstream dotStringGraph;
106 dotStringLabels <<
"\t" << leaf->
GetID() <<
" [label=\"" << leaf->
GetName()
107 <<
"\", style=\"filled\", fillcolor=\"" << leaf->
GetColor() <<
"\", shape=\"" << leaf->
GetShape()
115 return "digraph {\n" + dotStringLabels.str() + dotStringGraph.str() +
"}";
121 std::stringstream dotStringLabels;
123 std::stringstream dotStringGraph;
125 for (
auto leafShPtr : leaves) {
128 dotStringLabels <<
"\t" << leaf->
GetID() <<
" [label=\"" << leaf->
GetName()
129 <<
"\", style=\"filled\", fillcolor=\"" << leaf->
GetColor() <<
"\", shape=\""
139 return "digraph {\n" + dotStringLabels.str() + dotStringGraph.str() +
"}";
156 std::vector<std::shared_ptr<GraphNode>> nodes;
157 nodes.reserve(actions.size() + edges.size());
159 for (
auto *action : actions)
161 for (
auto *edge : edges)
std::string GetName() const
The head node of a RDF computation graph.
std::vector< RDFInternal::RActionBase * > GetAllActions() const
Return all actions, either booked or already run.
std::vector< RNodeBase * > GetGraphEdges() const
Return all graph edges known to RLoopManager This includes Filters and Ranges but not Defines.
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
std::string FromGraphLeafToDot(const GraphNode &leaf) const
Starting from any leaf (Action, Filter, Range) it draws the dot representation of the branch.
std::string RepresentGraph(ROOT::RDataFrame &rDataFrame)
Starting from the root node, prints the entire graph.
std::string FromGraphActionsToDot(std::vector< std::shared_ptr< GraphNode > > leaves) const
Starting by an array of leaves, it draws the entire graph.
std::unordered_map< void *, std::shared_ptr< GraphNode > > fVisitedMap
Map to keep track of visited nodes when constructing the computation graph (SaveGraph)
Class used to create the operation graph to be printed in the dot representation.
void SetExplored()
Allows to stop the graph traversal when an explored node is encountered.
std::string GetColor() const
std::string GetShape() const
std::string GetName() const
unsigned int GetID() const
GraphNode * GetPrevNode() const
A binder for user-defined columns, variations and aliases.
bool IsDefineOrAlias(std::string_view name) const
Check if the provided name is tracked in the names list.
RDFDetail::RDefineBase * GetDefine(const std::string &colName) const
Return the RDefine for the requested column name, or nullptr.
ColumnNames_t GetNames() const
Return the list of the names of the defined columns (Defines + Aliases).
RDFDetail::RLoopManager * GetLoopManager() const
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
std::shared_ptr< GraphNode > CreateFilterNode(const ROOT::Detail::RDF::RFilterBase *filterPtr, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
std::shared_ptr< GraphNode > CreateRangeNode(const ROOT::Detail::RDF::RRangeBase *rangePtr, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
std::shared_ptr< GraphNode > AddDefinesToGraph(std::shared_ptr< GraphNode > node, const RColumnRegister &colRegister, const std::vector< std::string > &prevNodeDefines, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
std::shared_ptr< GraphNode > CreateDefineNode(const std::string &columnName, const ROOT::Detail::RDF::RDefineBase *columnPtr, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
bool IsInternalColumn(std::string_view colName)
Whether custom column with name colName is an "internal" column such as rdfentry_ or rdfslot_.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.