Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Internal::RDF::RColumnRegister Class Reference

A binder for user-defined columns, variations and aliases.

The storage is copy-on-write and shared between all instances of the class that have the same values.

Several components of an RDF computation graph make use of a column register. It keeps track of which columns have been defined, varied or aliased at each point of the computation graph. In many cases, the contents of the different column register instances are the same or only differ by a single extra defined/varied/aliased column. For this reason, in order to avoid unnecessary data duplication, fDefines, fAliases, fVariations and fColumnNames are all shared_ptr<const T> that (whenever possible) are shared across RColumnRegister instances that are part of the same computation graph. If a new column, alias or variation is added between one node and the next, then the new node contains a new instance of a RColumnRegister that shares all data members with the previous instance except for the one data member that needed updating, which is replaced with a new updated instance.

The contents of the collections that keep track of other objects of the computation graph are not owned by the RColumnRegister object. They are registered centrally by the RLoopManager and only accessed via reference in the RColumnRegister.

Definition at line 68 of file RColumnRegister.hxx.

Public Member Functions

 RColumnRegister (ROOT::Detail::RDF::RLoopManager *lm)
 
void AddAlias (std::string_view alias, std::string_view colName)
 Add a new alias to the ledger.
 
void AddDefine (std::shared_ptr< RDFDetail::RDefineBase > column)
 Add a new defined column.
 
void AddVariation (std::shared_ptr< RVariationBase > variation)
 Register a new systematic variation.
 
std::vector< std::string_view > BuildDefineNames () const
 Return the list of the names of defined columns (no aliases).
 
ROOT::RDF::RVariationsDescription BuildVariationsDescription () const
 
std::vector< std::string_view > GenerateColumnNames () const
 Return the list of the names of the defined columns (Defines + Aliases).
 
RDFDetail::RDefineBaseGetDefine (std::string_view colName) const
 Return the RDefine for the requested column name, or nullptr.
 
RDFDetail::RColumnReaderBaseGetReader (unsigned int slot, const std::string &colName, const std::string &variationName, const std::type_info &tid)
 Return a RDefineReader or a RVariationReader, or nullptr if not available.
 
RDFDetail::RColumnReaderBaseGetReaderUnchecked (unsigned int slot, const std::string &colName, const std::string &variationName)
 Return a RDefineReader or a RVariationReader, or nullptr if not available.
 
std::vector< std::string > GetVariationDeps (const std::string &column) const
 Get the names of all variations that directly or indirectly affect a given column.
 
std::vector< std::string > GetVariationDeps (const std::vector< std::string > &columns) const
 Get the names of all variations that directly or indirectly affect the specified columns.
 
std::vector< std::string > GetVariationsFor (const std::string &column) const
 Get the names of the variations that directly provide alternative values for this column.
 
bool IsAlias (std::string_view name) const
 Return true if the given column name is an existing alias.
 
bool IsDefine (std::string_view name) const
 Return true if the given column name is an existing defined column.
 
bool IsDefineOrAlias (std::string_view name) const
 Check if the provided name is tracked in the names list.
 
std::string_view ResolveAlias (std::string_view alias) const
 Return the actual column name that the alias resolves to.
 

Private Types

using AliasesMap_t = std::vector< std::pair< std::string_view, std::string_view > >
 
using DefinesMap_t = std::vector< std::pair< std::string_view, ROOT::Internal::RDF::RDefinesWithReaders * > >
 
using VariationsMap_t = std::unordered_multimap< std::string_view, ROOT::Internal::RDF::RVariationsWithReaders * >
 

Private Member Functions

RVariationsWithReadersFindVariationAndReaders (const std::string &colName, const std::string &variationName)
 Return the RVariationsWithReaders object that handles the specified variation of the specified column, or null.
 

Private Attributes

std::shared_ptr< const AliasesMap_tfAliases
 Immutable map of Aliases, can be shared among several nodes.
 
std::shared_ptr< const DefinesMap_tfDefines
 Immutable collection of Defines, can be shared among several nodes.
 
ROOT::Detail::RDF::RLoopManagerfLoopManager
 The head node of the computation graph this register belongs to. Never null.
 
std::shared_ptr< const VariationsMap_tfVariations
 Immutable multimap of Variations, can be shared among several nodes.
 

#include <ROOT/RDF/RColumnRegister.hxx>

Member Typedef Documentation

◆ AliasesMap_t

using ROOT::Internal::RDF::RColumnRegister::AliasesMap_t = std::vector<std::pair<std::string_view, std::string_view> >
private

Definition at line 71 of file RColumnRegister.hxx.

◆ DefinesMap_t

using ROOT::Internal::RDF::RColumnRegister::DefinesMap_t = std::vector<std::pair<std::string_view, ROOT::Internal::RDF::RDefinesWithReaders *> >
private

Definition at line 70 of file RColumnRegister.hxx.

◆ VariationsMap_t

using ROOT::Internal::RDF::RColumnRegister::VariationsMap_t = std::unordered_multimap<std::string_view, ROOT::Internal::RDF::RVariationsWithReaders *>
private

Definition at line 69 of file RColumnRegister.hxx.

Constructor & Destructor Documentation

◆ RColumnRegister()

ROOT::Internal::RDF::RColumnRegister::RColumnRegister ( ROOT::Detail::RDF::RLoopManager lm)
explicit

Definition at line 25 of file RDFColumnRegister.cxx.

Member Function Documentation

◆ AddAlias()

void ROOT::Internal::RDF::RColumnRegister::AddAlias ( std::string_view  alias,
std::string_view  colName 
)

Add a new alias to the ledger.

Registers the strings alias, colName with the current RDataFrame, then uses references to those string to create the new pair for the collection of aliases of this node.

Definition at line 194 of file RDFColumnRegister.cxx.

◆ AddDefine()

void ROOT::Internal::RDF::RColumnRegister::AddDefine ( std::shared_ptr< RDFDetail::RDefineBase define)

Add a new defined column.

Registers the pair (columnName, columnReader) with the current RDataFrame, then keeps a reference to the inserted objects to keep track of the available columns for this node. Internally it recreates the collection with the new column, and swaps it with the old one.

Definition at line 71 of file RDFColumnRegister.cxx.

◆ AddVariation()

void ROOT::Internal::RDF::RColumnRegister::AddVariation ( std::shared_ptr< RVariationBase variation)

Register a new systematic variation.

Definition at line 96 of file RDFColumnRegister.cxx.

◆ BuildDefineNames()

std::vector< std::string_view > ROOT::Internal::RDF::RColumnRegister::BuildDefineNames ( ) const

Return the list of the names of defined columns (no aliases).

Definition at line 39 of file RDFColumnRegister.cxx.

◆ BuildVariationsDescription()

ROOT::RDF::RVariationsDescription ROOT::Internal::RDF::RColumnRegister::BuildVariationsDescription ( ) const

Definition at line 179 of file RDFColumnRegister.cxx.

◆ FindVariationAndReaders()

RVariationsWithReaders * ROOT::Internal::RDF::RColumnRegister::FindVariationAndReaders ( const std::string &  colName,
const std::string &  variationName 
)
private

Return the RVariationsWithReaders object that handles the specified variation of the specified column, or null.

Definition at line 166 of file RDFColumnRegister.cxx.

◆ GenerateColumnNames()

std::vector< std::string_view > ROOT::Internal::RDF::RColumnRegister::GenerateColumnNames ( ) const

Return the list of the names of the defined columns (Defines + Aliases).

Definition at line 310 of file RDFColumnRegister.cxx.

◆ GetDefine()

RDFDetail::RDefineBase * ROOT::Internal::RDF::RColumnRegister::GetDefine ( std::string_view  colName) const

Return the RDefine for the requested column name, or nullptr.

Definition at line 51 of file RDFColumnRegister.cxx.

◆ GetReader()

RDFDetail::RColumnReaderBase * ROOT::Internal::RDF::RColumnRegister::GetReader ( unsigned int  slot,
const std::string &  colName,
const std::string &  variationName,
const std::type_info &  requestedType 
)

Return a RDefineReader or a RVariationReader, or nullptr if not available.

If requestedType does not match the actual type of the Define or Variation, an exception is thrown.

Definition at line 258 of file RDFColumnRegister.cxx.

◆ GetReaderUnchecked()

RDFDetail::RColumnReaderBase * ROOT::Internal::RDF::RColumnRegister::GetReaderUnchecked ( unsigned int  slot,
const std::string &  colName,
const std::string &  variationName 
)

Return a RDefineReader or a RVariationReader, or nullptr if not available.

No type checking is done on the requested reader.

Definition at line 287 of file RDFColumnRegister.cxx.

◆ GetVariationDeps() [1/2]

std::vector< std::string > ROOT::Internal::RDF::RColumnRegister::GetVariationDeps ( const std::string &  column) const

Get the names of all variations that directly or indirectly affect a given column.

This list includes variations applied to the column as well as variations applied to other columns on which the value of this column depends (typically via a Define expression).

Definition at line 130 of file RDFColumnRegister.cxx.

◆ GetVariationDeps() [2/2]

std::vector< std::string > ROOT::Internal::RDF::RColumnRegister::GetVariationDeps ( const std::vector< std::string > &  columns) const

Get the names of all variations that directly or indirectly affect the specified columns.

This list includes variations applied to the columns as well as variations applied to other columns on which the value of any of these columns depend (typically via Define expressions).

Definition at line 140 of file RDFColumnRegister.cxx.

◆ GetVariationsFor()

std::vector< std::string > ROOT::Internal::RDF::RColumnRegister::GetVariationsFor ( const std::string &  column) const

Get the names of the variations that directly provide alternative values for this column.

Definition at line 114 of file RDFColumnRegister.cxx.

◆ IsAlias()

bool ROOT::Internal::RDF::RColumnRegister::IsAlias ( std::string_view  name) const

Return true if the given column name is an existing alias.

Definition at line 218 of file RDFColumnRegister.cxx.

◆ IsDefine()

bool ROOT::Internal::RDF::RColumnRegister::IsDefine ( std::string_view  name) const

Return true if the given column name is an existing defined column.

Definition at line 226 of file RDFColumnRegister.cxx.

◆ IsDefineOrAlias()

bool ROOT::Internal::RDF::RColumnRegister::IsDefineOrAlias ( std::string_view  name) const

Check if the provided name is tracked in the names list.

Definition at line 60 of file RDFColumnRegister.cxx.

◆ ResolveAlias()

std::string_view ROOT::Internal::RDF::RColumnRegister::ResolveAlias ( std::string_view  alias) const

Return the actual column name that the alias resolves to.

Drills through multiple levels of aliasing if needed. Returns the input in case it's not an alias. Expands #var to R_rdf_sizeof_var (the #var columns are implicitly-defined aliases).

Definition at line 237 of file RDFColumnRegister.cxx.

Member Data Documentation

◆ fAliases

std::shared_ptr<const AliasesMap_t> ROOT::Internal::RDF::RColumnRegister::fAliases
private

Immutable map of Aliases, can be shared among several nodes.

The pointee changes if a new Alias node is added to the RColumnRegister. It is a vector because we rely on insertion order to recreate the branch of the computation graph where necessary.

Definition at line 91 of file RColumnRegister.hxx.

◆ fDefines

std::shared_ptr<const DefinesMap_t> ROOT::Internal::RDF::RColumnRegister::fDefines
private

Immutable collection of Defines, can be shared among several nodes.

The pointee changes if a new Define node is added to the RColumnRegister. It is a vector because we rely on insertion order to recreate the branch of the computation graph where necessary.

Definition at line 86 of file RColumnRegister.hxx.

◆ fLoopManager

ROOT::Detail::RDF::RLoopManager* ROOT::Internal::RDF::RColumnRegister::fLoopManager
private

The head node of the computation graph this register belongs to. Never null.

Definition at line 74 of file RColumnRegister.hxx.

◆ fVariations

std::shared_ptr<const VariationsMap_t> ROOT::Internal::RDF::RColumnRegister::fVariations
private

Immutable multimap of Variations, can be shared among several nodes.

The key is the name of an existing column, the values are all variations that affect that column. Variations that affect multiple columns are inserted in the map multiple times, once per column, and conversely each column (i.e. each key) can have several associated variations.

Definition at line 81 of file RColumnRegister.hxx.

Libraries for ROOT::Internal::RDF::RColumnRegister:

The documentation for this class was generated from the following files: