Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
GraphUtils.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo, CERN, Massimo Tumolo Politecnico di Torino 08/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_GRAPHUTILS
12#define ROOT_GRAPHUTILS
13
14#include <ROOT/RDataFrame.hxx>
17
18#include <string>
19#include <vector>
20#include <unordered_map>
21#include <memory>
22
23namespace ROOT {
24namespace Detail {
25namespace RDF {
26class RDefineBase;
27class RFilterBase;
28class RRangeBase;
29} // namespace RDF
30} // namespace Detail
31
32namespace Internal {
33namespace RDF {
34class RColumnRegister;
35namespace GraphDrawing {
36
37std::shared_ptr<GraphNode> CreateDefineNode(const std::string &columnName,
39 std::unordered_map<void *, std::shared_ptr<GraphNode>> &visitedMap);
40
41std::shared_ptr<GraphNode> CreateFilterNode(const ROOT::Detail::RDF::RFilterBase *filterPtr,
42 std::unordered_map<void *, std::shared_ptr<GraphNode>> &visitedMap);
43
44std::shared_ptr<GraphNode> CreateRangeNode(const ROOT::Detail::RDF::RRangeBase *rangePtr,
45 std::unordered_map<void *, std::shared_ptr<GraphNode>> &visitedMap);
46
47// clang-format off
48/**
49\class ROOT::Internal::RDF::GraphCreatorHelper
50\ingroup dataframe
51\brief Helper class that provides the operation graph nodes.
52
53 This class is the single point from which graph nodes can be retrieved. Every time an object is created,
54 it clears the static members and starts again.
55 By asking this class to create a node, it will return an existing node if already created, otherwise a new one.
56*/
57// clang-format on
59private:
60 ////////////////////////////////////////////////////////////////////////////
61 /// \brief Map to keep track of visited nodes when constructing the computation graph (SaveGraph)
62 std::unordered_map<void *, std::shared_ptr<GraphNode>> fVisitedMap;
63
64 ////////////////////////////////////////////////////////////////////////////
65 /// \brief Starting from any leaf (Action, Filter, Range) it draws the dot representation of the branch.
66 std::string FromGraphLeafToDot(const GraphNode &leaf) const;
67
68 ////////////////////////////////////////////////////////////////////////////
69 /// \brief Starting by an array of leaves, it draws the entire graph.
70 std::string FromGraphActionsToDot(std::vector<std::shared_ptr<GraphNode>> leaves) const;
71
72public:
73 ////////////////////////////////////////////////////////////////////////////
74 /// \brief Starting from the root node, prints the entire graph.
76
77 ////////////////////////////////////////////////////////////////////////////
78 /// \brief Starting from the root node, prints the entire graph.
80
81 ////////////////////////////////////////////////////////////////////////////
82 /// \brief Starting from a Filter or Range, prints the branch it belongs to
83 template <typename Proxied, typename DataSource>
85 {
86 auto loopManager = rInterface.GetLoopManager();
87 loopManager->Jit();
88
89 return FromGraphLeafToDot(*rInterface.GetProxiedPtr()->GetGraph(fVisitedMap));
90 }
91
92 ////////////////////////////////////////////////////////////////////////////
93 /// \brief Starting from an action, prints the branch it belongs to
94 template <typename T>
96 {
97 auto loopManager = resultPtr.fLoopManager;
98
99 loopManager->Jit();
100
101 auto actionPtr = resultPtr.fActionPtr;
102 return FromGraphLeafToDot(*actionPtr->GetGraph(fVisitedMap));
103 }
104};
105
106} // namespace GraphDrawing
107} // namespace RDF
108} // namespace Internal
109} // namespace ROOT
110
111#endif
The head node of a RDF 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 RepresentGraph(ROOT::RDF::RInterface< Proxied, DataSource > &rInterface)
Starting from a Filter or Range, prints the branch it belongs to.
std::string RepresentGraph(const ROOT::RDF::RResultPtr< T > &resultPtr)
Starting from an action, prints the branch it belongs to.
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.
Definition GraphNode.hxx:47
The public interface to the RDataFrame federation of classes.
Smart pointer for the return type of actions.
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 > CreateDefineNode(const std::string &columnName, const ROOT::Detail::RDF::RDefineBase *columnPtr, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...