36std::shared_ptr<GraphNode>
AddDefinesToGraph(std::shared_ptr<GraphNode> node,
const RColumnRegister &colRegister,
37 const std::vector<std::string> &prevNodeDefines,
38 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &visitedMap);
52template <
typename Helper,
typename PrevNode,
typename ColumnTypes_t =
typename Helper::ColumnTypes_t>
54 using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
60 std::vector<std::array<RColumnReaderBase *, ColumnTypes_t::list_size>>
fValues;
63 std::array<bool, ColumnTypes_t::list_size>
fIsDefine;
72 const auto nColumns = columns.size();
73 for (
auto i = 0u; i < nColumns; ++i)
88 return fHelper.GetMergeableValue();
101 template <
typename ColType>
104 if (
auto *val =
fValues[slot][readerIdx]->
template TryGet<ColType>(entry))
107 throw std::out_of_range{
"RDataFrame: Action (" +
fHelper.GetActionName() +
108 ") could not retrieve value for column '" +
fColumnNames[readerIdx] +
"' for entry " +
109 std::to_string(entry) +
110 ". You can use the DefaultValueFor operation to provide a default value, or "
111 "FilterAvailable/FilterMissing to discard/keep entries with missing values instead."};
114 template <
typename... ColTypes, std::size_t... S>
135 fHelper.CallFinalizeTask(slot);
146 std::shared_ptr<RDFGraphDrawing::GraphNode>
147 GetGraph(std::unordered_map<
void *, std::shared_ptr<RDFGraphDrawing::GraphNode>> &visitedMap)
final
149 auto prevNode =
fPrevNode.GetGraph(visitedMap);
150 const auto &prevColumns = prevNode->GetDefinedColumns();
153 const auto nodeType =
HasRun() ? RDFGraphDrawing::ENodeType::kUsedAction : RDFGraphDrawing::ENodeType::kAction;
155 std::make_shared<RDFGraphDrawing::GraphNode>(
fHelper.GetActionName(), visitedMap.size(), nodeType);
156 visitedMap[(
void *)
this] = thisNode;
158 auto upmostNode = AddDefinesToGraph(thisNode,
GetColRegister(), prevColumns, visitedMap);
160 thisNode->AddDefinedColumns(
GetColRegister().GenerateColumnNames());
161 upmostNode->SetPrevNode(prevNode);
172 auto &&nVariations = variations.size();
173 assert(results.size() == nVariations);
175 std::vector<Helper> helpers;
176 helpers.reserve(nVariations);
178 for (
decltype(nVariations) i{}; i < nVariations; i++)
179 helpers.emplace_back(
fHelper.CallMakeNew(results[i], variations[i]));
long long Long64_t
Portable signed long integer 8 bytes.
const ColumnNames_t fColumnNames
RActionBase(RLoopManager *lm, const ColumnNames_t &colNames, const RColumnRegister &colRegister, const std::vector< std::string > &prevVariations)
unsigned int GetNSlots() const
const std::vector< std::string > & GetVariations() const
const ColumnNames_t & GetColumnNames() const
virtual bool HasRun() const
RLoopManager * fLoopManager
A raw pointer to the RLoopManager at the root of this functional graph.
RColumnRegister & GetColRegister()
std::shared_ptr< RDFGraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< RDFGraphDrawing::GraphNode > > &visitedMap) final
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
void Run(unsigned int slot, Long64_t entry) final
std::unique_ptr< RActionBase > CloneAction(void *newResult) final
Returns a new action with a cloned helper.
void InitSlot(TTreeReader *r, unsigned int slot) final
std::make_index_sequence< ColumnTypes_t::list_size > TypeInd_t
void Finalize() final
Clean-up and finalize the action result (e.g.
RAction & operator=(const RAction &)=delete
void TriggerChildrenCount() final
std::unique_ptr< RDFDetail::RMergeableValueBase > GetMergeableValue() const final
Retrieve a wrapper to the result of the action that knows how to merge with others of the same type.
RAction(const RAction &)=delete
void * PartialUpdate(unsigned int slot) final
This method is invoked to update a partial result during the event loop, right before passing the res...
void CallExec(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >)
RAction(Helper &&h, const ColumnNames_t &columns, std::shared_ptr< PrevNode > pd, const RColumnRegister &colRegister)
const std::shared_ptr< PrevNode > fPrevNodePtr
ROOT::RDF::SampleCallback_t GetSampleCallback() final
std::unique_ptr< RActionBase > MakeVariedAction(std::vector< void * > &&results) final
auto GetValueChecked(unsigned int slot, std::size_t readerIdx, Long64_t entry) -> ColType &
std::array< bool, ColumnTypes_t::list_size > fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
std::vector< std::array< RColumnReaderBase *, ColumnTypes_t::list_size > > fValues
Column readers per slot and per input column.
A binder for user-defined columns, variations and aliases.
bool IsDefineOrAlias(std::string_view name) const
Check if the provided name is tracked in the names list.
Just like an RAction, but it has N action helpers and N previous nodes (N is the number of variations...
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
std::shared_ptr< GraphNode > AddDefinesToGraph(std::shared_ptr< GraphNode > node, const RColumnRegister &colRegister, const std::vector< std::string > &prevNodeDefines, std::unordered_map< void *, std::shared_ptr< GraphNode > > &visitedMap)
std::array< RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> GetColumnReaders(unsigned int slot, TTreeReader *treeReader, TypeList< ColTypes... >, const RColumnReadersInfo &colInfo, const std::string &variationName="nominal")
Create a group of column readers, one per type in the parameter pack.
std::function< void(unsigned int, const ROOT::RDF::RSampleInfo &)> SampleCallback_t
The type of a data-block callback, registered with an RDataFrame computation graph via e....
std::vector< std::string > ColumnNames_t
Struct to wrap the call to a function with a guaranteed order of execution of its arguments.
This type aggregates some of the arguments passed to GetColumnReaders.
Lightweight storage for a collection of types.