Logo ROOT  
Reference Guide
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 free function and a sequence of mergeables can be merged together with the helper function MergeValues. 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();

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. More...
 
 RMergeableValue (const T &value)
 Constructor taking the action result by const reference. More...
 
const T & GetValue () const
 Retrieve the result wrapped by this mergeable. More...
 

Protected Attributes

fValue
 

Private Member Functions

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

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

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.

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

Friends And Related Function 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.


The documentation for this class was generated from the following file:
ROOT::Detail::RDF::GetMergeableValue
std::unique_ptr< RMergeableValue< T > > GetMergeableValue(RResultPtr< T > &rptr)
Retrieve a mergeable value from an RDataFrame action.
Definition: RResultPtr.hxx:397
ROOT::RDataFrame
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
Definition: RDataFrame.hxx:42
ROOT::Detail::RDF::RMergeableValue::MergeValues
friend std::unique_ptr< RMergeableValue< T1 > > MergeValues(std::unique_ptr< RMergeableValue< T1 >> OutputMergeable, std::unique_ptr< RMergeableValue< Ts >>... InputMergeables)
ROOT::Detail::RDF
Definition: GraphUtils.hxx:28
h1
TH1F * h1
Definition: legend1.C:5
d
#define d(i)
Definition: RSha256.hxx:102