Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Detail::RDF::RMergeableValue< T > Class Template Referenceabstract

template<typename T>
class ROOT::Detail::RDF::RMergeableValue< T >

A result of an RDataFrame execution, that knows how to merge with other results of the same type.

Template Parameters
TType of the action result.

Results of the execution of an RDataFrame computation graph do not natively know how to merge with other results of the same type. In a distributed environment it is often needed to have a merging mechanism for partial results coming from the execution of an analysis on different chunks of the same dataset that has happened on different executors. In order to achieve this, RMergeableValue stores the result of the RDataFrame action and has a Merge method to allow the aggregation of information coming from another similar result into the current.

A mergeable value can be retrieved from an RResultPtr through the [GetMergeableValue] (namespaceROOT_1_1Detail_1_1RDF.html::a8b3a9c7b416826acc952d78a56d14ecb) free function and a sequence of mergeables can be merged together with the helper function [MergeValues] (namespaceROOT_1_1Detail_1_1RDF.html::af16fefbe2d120983123ddf8a1e137277). All the classes and functions involved are inside the ROOT::Detail::RDF namespace.

In a nutshell:

using namespace ROOT::Detail::RDF;
ROOT::RDataFrame d("myTree", "file_*.root");
auto h1 = d.Histo1D("Branch_A");
auto h2 = d.Histo1D("Branch_A");
// Retrieve mergeables from the `RResultPtr`s
auto mergeableh1 = GetMergeableValue(h1);
auto mergeableh2 = GetMergeableValue(h2);
// Merge the values and get another mergeable back
auto mergedptr = MergeValues(std::move(mergeableh1), std::move(mergeableh2));
// Retrieve the merged TH1D object
const auto &mergedhisto = mergedptr->GetValue();
#define d(i)
Definition RSha256.hxx:102
friend std::unique_ptr< RMergeableValue< T1 > > MergeValues(std::unique_ptr< RMergeableValue< T1 > > OutputMergeable, std::unique_ptr< RMergeableValue< Ts > >... InputMergeables)
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
TH1F * h1
Definition legend1.C:5
std::unique_ptr< RMergeableValue< T > > GetMergeableValue(RResultPtr< T > &rptr)
Retrieve a mergeable value from an RDataFrame action.

Though this snippet can run on a single thread of a single machine, it is straightforward to generalize it to a distributed case, e.g. where mergeableh1 and mergeableh2 are created on separate machines and sent to a reduce process where the MergeValues function is called. The final user would then just be given the final merged result coming from mergedptr->GetValue.

RMergeableValue is the base class for all the different specializations that may be needed according to the peculiarities of the result types. The following subclasses, their names hinting at the action operation of the result, are currently available:

Definition at line 129 of file RMergeableValue.hxx.

Public Member Functions

 RMergeableValue ()=default
 Default constructor.
 
 RMergeableValue (const T &value)
 Constructor taking the action result by const reference.
 
const T & GetValue () const
 Retrieve the result wrapped by this mergeable.
 
- Public Member Functions inherited from ROOT::Detail::RDF::RMergeableValueBase
 RMergeableValueBase ()=default
 Default constructor.
 
virtual ~RMergeableValueBase ()=default
 

Protected Attributes

fValue
 

Private Member Functions

virtual void Merge (const RMergeableValue< T > &)=0
 Aggregate the information contained in another RMergeableValue into this.
 

Friends

template<typename T1 , typename... Ts>
void MergeValues (RMergeableValue< T1 > &OutputMergeable, const RMergeableValue< Ts > &... InputMergeables)
 
template<typename T1 , typename... Ts>
std::unique_ptr< RMergeableValue< T1 > > MergeValues (std::unique_ptr< RMergeableValue< T1 > > OutputMergeable, std::unique_ptr< RMergeableValue< Ts > >... InputMergeables)
 

#include <ROOT/RDF/RMergeableValue.hxx>

Inheritance diagram for ROOT::Detail::RDF::RMergeableValue< T >:
[legend]

Constructor & Destructor Documentation

◆ RMergeableValue() [1/2]

template<typename T >
ROOT::Detail::RDF::RMergeableValue< T >::RMergeableValue ( const T &  value)
inline

Constructor taking the action result by const reference.

This involves a copy of the result into the data member, but gives full ownership of data to the mergeable.

Definition at line 157 of file RMergeableValue.hxx.

◆ RMergeableValue() [2/2]

template<typename T >
ROOT::Detail::RDF::RMergeableValue< T >::RMergeableValue ( )
default

Default constructor.

Needed to allow serialization of ROOT objects. See [TBufferFile::WriteObjectClass] (classTBufferFile.html::a209078a4cb58373b627390790bf0c9c1)

Member Function Documentation

◆ GetValue()

template<typename T >
const T & ROOT::Detail::RDF::RMergeableValue< T >::GetValue ( ) const
inline

Retrieve the result wrapped by this mergeable.

Definition at line 166 of file RMergeableValue.hxx.

◆ Merge()

template<typename T >
virtual void ROOT::Detail::RDF::RMergeableValue< T >::Merge ( const RMergeableValue< T > &  )
privatepure virtual

Aggregate the information contained in another RMergeableValue into this.

Virtual function reimplemented in all the subclasses.

Note
All the Merge methods in the RMergeableValue family are private. To merge multiple RMergeableValue objects please use [MergeValues] (namespaceROOT_1_1Detail_1_1RDF.html::af16fefbe2d120983123ddf8a1e137277).

Implemented in ROOT::Detail::RDF::RMergeableMean, ROOT::Detail::RDF::RMergeableStdDev, ROOT::Detail::RDF::RMergeableFill< T >, ROOT::Detail::RDF::RMergeableMax< T >, ROOT::Detail::RDF::RMergeableMin< T >, ROOT::Detail::RDF::RMergeableSum< T >, and ROOT::Detail::RDF::RMergeableCount.

Friends And Related Symbol Documentation

◆ MergeValues [1/2]

template<typename T >
template<typename T1 , typename... Ts>
void MergeValues ( RMergeableValue< T1 > &  OutputMergeable,
const RMergeableValue< Ts > &...  InputMergeables 
)
friend

◆ MergeValues [2/2]

template<typename T >
template<typename T1 , typename... Ts>
std::unique_ptr< RMergeableValue< T1 > > MergeValues ( std::unique_ptr< RMergeableValue< T1 > >  OutputMergeable,
std::unique_ptr< RMergeableValue< Ts > >...  InputMergeables 
)
friend

Member Data Documentation

◆ fValue

template<typename T >
T ROOT::Detail::RDF::RMergeableValue< T >::fValue
protected

Definition at line 149 of file RMergeableValue.hxx.

  • tree/dataframe/inc/ROOT/RDF/RMergeableValue.hxx