File indexing completed on 2025-01-18 10:10:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT_GRAPHUTILS
0012 #define ROOT_GRAPHUTILS
0013
0014 #include <string>
0015 #include <vector>
0016 #include <unordered_map>
0017 #include <memory>
0018 #include <ROOT/RDataFrame.hxx>
0019 #include <ROOT/RDF/RInterface.hxx>
0020 #include <ROOT/RDF/GraphNode.hxx>
0021
0022 namespace ROOT {
0023 namespace Detail {
0024 namespace RDF {
0025 class RDefineBase;
0026 class RFilterBase;
0027 class RRangeBase;
0028 }
0029 }
0030
0031 namespace Internal {
0032 namespace RDF {
0033 class RColumnRegister;
0034 namespace GraphDrawing {
0035
0036 std::shared_ptr<GraphNode> CreateDefineNode(const std::string &columnName,
0037 const ROOT::Detail::RDF::RDefineBase *columnPtr,
0038 std::unordered_map<void *, std::shared_ptr<GraphNode>> &visitedMap);
0039
0040 std::shared_ptr<GraphNode> CreateFilterNode(const ROOT::Detail::RDF::RFilterBase *filterPtr,
0041 std::unordered_map<void *, std::shared_ptr<GraphNode>> &visitedMap);
0042
0043 std::shared_ptr<GraphNode> CreateRangeNode(const ROOT::Detail::RDF::RRangeBase *rangePtr,
0044 std::unordered_map<void *, std::shared_ptr<GraphNode>> &visitedMap);
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 class GraphCreatorHelper {
0058 private:
0059
0060
0061 std::unordered_map<void *, std::shared_ptr<GraphNode>> fVisitedMap;
0062
0063
0064
0065 std::string FromGraphLeafToDot(const GraphNode &leaf) const;
0066
0067
0068
0069 std::string FromGraphActionsToDot(std::vector<std::shared_ptr<GraphNode>> leaves) const;
0070
0071 public:
0072
0073
0074 std::string RepresentGraph(ROOT::RDataFrame &rDataFrame);
0075
0076
0077
0078 std::string RepresentGraph(RLoopManager *rLoopManager);
0079
0080
0081
0082 template <typename Proxied, typename DataSource>
0083 std::string RepresentGraph(RInterface<Proxied, DataSource> &rInterface)
0084 {
0085 auto loopManager = rInterface.GetLoopManager();
0086 loopManager->Jit();
0087
0088 return FromGraphLeafToDot(*rInterface.GetProxiedPtr()->GetGraph(fVisitedMap));
0089 }
0090
0091
0092
0093 template <typename T>
0094 std::string RepresentGraph(const RResultPtr<T> &resultPtr)
0095 {
0096 auto loopManager = resultPtr.fLoopManager;
0097
0098 loopManager->Jit();
0099
0100 auto actionPtr = resultPtr.fActionPtr;
0101 return FromGraphLeafToDot(*actionPtr->GetGraph(fVisitedMap));
0102 }
0103 };
0104
0105 }
0106 }
0107 }
0108 }
0109
0110 #endif