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.
Definition at line 89 of file RColumnRegister.hxx.
Public Member Functions | |
RColumnRegister (const RColumnRegister &)=default | |
RColumnRegister (RColumnRegister &&)=default | |
RColumnRegister (std::shared_ptr< RDFDetail::RLoopManager > lm) | |
~RColumnRegister () | |
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. | |
ColumnNames_t | BuildDefineNames () const |
Return the list of the names of defined columns (no aliases). | |
ROOT::RDF::RVariationsDescription | BuildVariationsDescription () const |
RDFDetail::RDefineBase * | GetDefine (const std::string &colName) const |
Return the RDefine for the requested column name, or nullptr. | |
ColumnNames_t | GetNames () const |
Return the list of the names of the defined columns (Defines + Aliases). | |
RDFDetail::RColumnReaderBase * | GetReader (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. | |
std::vector< std::string > | GetVariationDeps (const ColumnNames_t &columns) const |
Get the names of all variations that directly or indirectly affect the specified columns. | |
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 > | GetVariationsFor (const std::string &column) const |
Get the names of the variations that directly provide alternative values for this column. | |
bool | IsAlias (const std::string &name) const |
Return true if the given column name is an existing alias. | |
bool | IsDefineOrAlias (std::string_view name) const |
Check if the provided name is tracked in the names list. | |
RColumnRegister & | operator= (const RColumnRegister &)=default |
std::string | ResolveAlias (std::string_view alias) const |
Return the actual column name that the alias resolves to. | |
Private Types | |
using | ColumnNames_t = std::vector< std::string > |
using | DefinesMap_t = std::unordered_map< std::string, std::shared_ptr< RDefinesWithReaders > > |
using | VariationsMap_t = std::unordered_multimap< std::string, std::shared_ptr< RVariationsWithReaders > > |
See fVariations for more information on this type. | |
Private Member Functions | |
void | AddName (std::string_view name) |
Add a new name to the list returned by GetNames without booking a new column. | |
RVariationsWithReaders * | FindVariationAndReaders (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 std::unordered_map< std::string, std::string > > | fAliases |
Immutable map of Aliases, can be shared among several nodes. | |
std::shared_ptr< const ColumnNames_t > | fColumnNames |
Names of Defines and Aliases registered so far. | |
std::shared_ptr< DefinesMap_t > | fDefines |
Immutable collection of Defines, can be shared among several nodes. | |
std::shared_ptr< RDFDetail::RLoopManager > | fLoopManager |
std::shared_ptr< VariationsMap_t > | fVariations |
Immutable multimap of Variations, can be shared among several nodes. | |
#include <ROOT/RDF/RColumnRegister.hxx>
|
private |
Definition at line 90 of file RColumnRegister.hxx.
|
private |
Definition at line 91 of file RColumnRegister.hxx.
|
private |
See fVariations for more information on this type.
Definition at line 93 of file RColumnRegister.hxx.
|
default |
|
default |
|
explicit |
Definition at line 88 of file RDFColumnRegister.cxx.
ROOT::Internal::RDF::RColumnRegister::~RColumnRegister | ( | ) |
Definition at line 95 of file RDFColumnRegister.cxx.
void ROOT::Internal::RDF::RColumnRegister::AddAlias | ( | std::string_view | alias, |
std::string_view | colName | ||
) |
Add a new alias to the ledger.
Definition at line 256 of file RDFColumnRegister.cxx.
void ROOT::Internal::RDF::RColumnRegister::AddDefine | ( | std::shared_ptr< RDFDetail::RDefineBase > | define | ) |
Add a new defined column.
Internally it recreates the map with the new column, and swaps it with the old one.
Definition at line 138 of file RDFColumnRegister.cxx.
|
private |
Add a new name to the list returned by GetNames
without booking a new column.
This is needed because we abuse fColumnNames to also keep track of the aliases defined in each branch of the computation graph. Internally it recreates the vector with the new name, and swaps it with the old one.
Definition at line 243 of file RDFColumnRegister.cxx.
void ROOT::Internal::RDF::RColumnRegister::AddVariation | ( | std::shared_ptr< RVariationBase > | variation | ) |
Register a new systematic variation.
Definition at line 152 of file RDFColumnRegister.cxx.
ColumnNames_t ROOT::Internal::RDF::RColumnRegister::BuildDefineNames | ( | ) | const |
Return the list of the names of defined columns (no aliases).
Definition at line 109 of file RDFColumnRegister.cxx.
ROOT::RDF::RVariationsDescription ROOT::Internal::RDF::RColumnRegister::BuildVariationsDescription | ( | ) | const |
Definition at line 227 of file RDFColumnRegister.cxx.
|
private |
Return the RVariationsWithReaders object that handles the specified variation of the specified column, or null.
Definition at line 214 of file RDFColumnRegister.cxx.
RDFDetail::RDefineBase * ROOT::Internal::RDF::RColumnRegister::GetDefine | ( | const std::string & | colName | ) | const |
Return the RDefine for the requested column name, or nullptr.
Definition at line 121 of file RDFColumnRegister.cxx.
|
inline |
Return the list of the names of the defined columns (Defines + Aliases).
Definition at line 123 of file RColumnRegister.hxx.
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 295 of file RDFColumnRegister.cxx.
std::vector< std::string > ROOT::Internal::RDF::RColumnRegister::GetVariationDeps | ( | const ColumnNames_t & | 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 189 of file RDFColumnRegister.cxx.
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 179 of file RDFColumnRegister.cxx.
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 163 of file RDFColumnRegister.cxx.
bool ROOT::Internal::RDF::RColumnRegister::IsAlias | ( | const std::string & | name | ) | const |
Return true if the given column name is an existing alias.
Definition at line 268 of file RDFColumnRegister.cxx.
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 129 of file RDFColumnRegister.cxx.
|
default |
std::string 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 278 of file RDFColumnRegister.cxx.
|
private |
Immutable map of Aliases, can be shared among several nodes.
Definition at line 101 of file RColumnRegister.hxx.
|
private |
Names of Defines and Aliases registered so far.
Definition at line 107 of file RColumnRegister.hxx.
|
private |
Immutable collection of Defines, can be shared among several nodes.
The pointee changes if a new Define node is added to the RColumnRegister.
Definition at line 99 of file RColumnRegister.hxx.
|
private |
Definition at line 95 of file RColumnRegister.hxx.
|
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 106 of file RColumnRegister.hxx.