Logo ROOT  
Reference Guide
RDefineBase.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 09/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_RCUSTOMCOLUMNBASE
12 #define ROOT_RCUSTOMCOLUMNBASE
13 
14 #include "ROOT/RDF/GraphNode.hxx"
16 
17 #include <deque>
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 class TTreeReader;
24 
25 namespace ROOT {
26 namespace RDF {
27 class RDataSource;
28 }
29 namespace Detail {
30 namespace RDF {
31 
33 
34 class RDefineBase {
35 protected:
36  const std::string fName; ///< The name of the custom column
37  const std::string fType; ///< The type of the custom column as a text string
38  unsigned int fNChildren{0}; ///< number of nodes of the functional graph hanging from this object
39  unsigned int fNStopsReceived{0}; ///< number of times that a children node signaled to stop processing entries.
40  const unsigned int fNSlots; ///< number of thread slots used by this node, inherited from parent node.
41  std::vector<Long64_t> fLastCheckedEntry;
42  /// A unique ID that identifies this custom column.
43  /// Used e.g. to distinguish custom columns with the same name in different branches of the computation graph.
44  const unsigned int fID = GetNextID();
46  std::deque<bool> fIsInitialized; // because vector<bool> is not thread-safe
47  const std::map<std::string, std::vector<void *>> &fDSValuePtrs; // reference to RLoopManager's data member
48  ROOT::RDF::RDataSource *fDataSource; ///< non-owning ptr to the RDataSource, if any. Used to retrieve column readers.
49 
50  static unsigned int GetNextID();
51 
52 public:
54  const RDFInternal::RBookedDefines &defines,
55  const std::map<std::string, std::vector<void *>> &DSValuePtrs, ROOT::RDF::RDataSource *ds);
56 
57  RDefineBase &operator=(const RDefineBase &) = delete;
59  virtual ~RDefineBase();
60  virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
61  /// Return the (type-erased) address of the Define'd value for the given processing slot.
62  virtual void *GetValuePtr(unsigned int slot) = 0;
63  virtual const std::type_info &GetTypeId() const = 0;
64  std::string GetName() const;
65  std::string GetTypeName() const;
66  /// Update the value at the address returned by GetValuePtr with the content corresponding to the given entry
67  virtual void Update(unsigned int slot, Long64_t entry) = 0;
68  /// Clean-up operations to be performed at the end of a task.
69  virtual void FinaliseSlot(unsigned int slot) = 0;
70  /// Return the unique identifier of this RDefineBase.
71  unsigned int GetID() const { return fID; }
72 };
73 
74 } // ns RDF
75 } // ns Detail
76 } // ns ROOT
77 
78 #endif // ROOT_RCUSTOMCOLUMNBASE
ROOT::Detail::RDF::RDefineBase::RDefineBase
RDefineBase(std::string_view name, std::string_view type, unsigned int nSlots, const RDFInternal::RBookedDefines &defines, const std::map< std::string, std::vector< void * >> &DSValuePtrs, ROOT::RDF::RDataSource *ds)
Definition: RDefineBase.cxx:28
ROOT::Detail::RDF::RDefineBase::GetName
std::string GetName() const
Definition: RDefineBase.cxx:39
ROOT::Detail::RDF::RDefineBase::GetTypeName
std::string GetTypeName() const
Definition: RDefineBase.cxx:44
ROOT::Detail::RDF::RDefineBase::~RDefineBase
virtual ~RDefineBase()
Definition: RDefineBase.cxx:37
ROOT::Detail::RDF::RDefineBase::fNSlots
const unsigned int fNSlots
number of thread slots used by this node, inherited from parent node.
Definition: RDefineBase.hxx:40
RBookedDefines.hxx
ROOT::Detail::RDF::RDefineBase::GetID
unsigned int GetID() const
Return the unique identifier of this RDefineBase.
Definition: RDefineBase.hxx:71
r
ROOT::R::TRInterface & r
Definition: Object.C:4
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
string_view
basic_string_view< char > string_view
Definition: libcpp_string_view.h:785
extract_docstrings.ds
ds
Definition: extract_docstrings.py:40
ROOT::Internal::RDF::RBookedDefines
Encapsulates the columns defined by the user.
Definition: RBookedDefines.hxx:39
ROOT::Detail::RDF::RDefineBase::fName
const std::string fName
The name of the custom column.
Definition: RDefineBase.hxx:36
ROOT::Detail::RDF::RDefineBase::FinaliseSlot
virtual void FinaliseSlot(unsigned int slot)=0
Clean-up operations to be performed at the end of a task.
ROOT::RDF::RDataSource
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
Definition: RDataSource.hxx:106
ROOT::Detail::RDF::RDefineBase::fLastCheckedEntry
std::vector< Long64_t > fLastCheckedEntry
Definition: RDefineBase.hxx:41
ROOT::Detail::RDF::RDefineBase::GetValuePtr
virtual void * GetValuePtr(unsigned int slot)=0
Return the (type-erased) address of the Define'd value for the given processing slot.
ROOT::Detail::RDF::RDefineBase::fNChildren
unsigned int fNChildren
number of nodes of the functional graph hanging from this object
Definition: RDefineBase.hxx:38
ROOT::Detail::RDF::RDefineBase::fType
const std::string fType
The type of the custom column as a text string.
Definition: RDefineBase.hxx:37
ROOT::Detail::RDF::RDefineBase
Definition: RDefineBase.hxx:34
ROOT::Detail::RDF::RDefineBase::fDSValuePtrs
const std::map< std::string, std::vector< void * > > & fDSValuePtrs
Definition: RDefineBase.hxx:47
ROOT::Detail::RDF::RDefineBase::fDefines
RDFInternal::RBookedDefines fDefines
Definition: RDefineBase.hxx:45
ROOT::Detail::RDF::RDefineBase::fDataSource
ROOT::RDF::RDataSource * fDataSource
non-owning ptr to the RDataSource, if any. Used to retrieve column readers.
Definition: RDefineBase.hxx:48
ROOT::Detail::RDF::RDefineBase::InitSlot
virtual void InitSlot(TTreeReader *r, unsigned int slot)=0
TTreeReader
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition: TTreeReader.h:44
ROOT::Detail::RDF::RDefineBase::fIsInitialized
std::deque< bool > fIsInitialized
Definition: RDefineBase.hxx:46
ROOT::Detail::RDF::RDefineBase::GetTypeId
virtual const std::type_info & GetTypeId() const =0
ROOT::Detail::RDF::RDefineBase::GetNextID
static unsigned int GetNextID()
Definition: RDefineBase.cxx:22
ROOT::Detail::RDF::RDefineBase::fNStopsReceived
unsigned int fNStopsReceived
number of times that a children node signaled to stop processing entries.
Definition: RDefineBase.hxx:39
ROOT::Internal::RDF
Definition: RArrowDS.hxx:15
ROOT::Detail::RDF::RDefineBase::operator=
RDefineBase & operator=(const RDefineBase &)=delete
ROOT::Detail::RDF::RDefineBase::Update
virtual void Update(unsigned int slot, Long64_t entry)=0
Update the value at the address returned by GetValuePtr with the content corresponding to the given e...
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Detail::RDF::RDefineBase::fID
const unsigned int fID
A unique ID that identifies this custom column.
Definition: RDefineBase.hxx:44
type
int type
Definition: TGX11.cxx:121
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Detail::RDF::RDefineBase::operator=
RDefineBase & operator=(RDefineBase &&)=delete
GraphNode.hxx