35namespace GraphDrawing {
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;
67 :
RActionBase(pd->GetLoopManagerUnchecked(), columns, colRegister, pd->GetVariations()),
68 fHelper(std::forward<Helper>(
h)), fPrevNodePtr(std::move(pd)), fPrevNode(*fPrevNodePtr), fValues(
GetNSlots())
70 fLoopManager->Register(
this);
72 const auto nColumns = columns.size();
73 for (
auto i = 0u; i < nColumns; ++i)
88 return fHelper.GetMergeableValue();
95 RColumnReadersInfo info{RActionBase::GetColumnNames(), RActionBase::GetColRegister(), fIsDefine.data(),
98 fHelper.InitTask(
r, slot);
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>
118 GetValueChecked<ColTypes>(slot, S, entry)...};
125 if (fPrevNode.CheckFilters(slot, entry))
126 CallExec(slot, entry, ColumnTypes_t{},
TypeInd_t{});
134 fValues[slot].fill(
nullptr);
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);
167 void *
PartialUpdate(
unsigned int slot)
final {
return fHelper.CallPartialUpdate(slot); }
171 const auto nVariations = GetVariations().size();
172 assert(results.size() == nVariations);
174 std::vector<Helper> helpers;
175 helpers.reserve(nVariations);
177 for (
auto &&res : results)
178 helpers.emplace_back(fHelper.CallMakeNew(res));
181 std::move(helpers), GetColumnNames(), fPrevNodePtr, GetColRegister()});
192 return std::make_unique<RAction>(fHelper.CallMakeNew(newResult), GetColumnNames(), fPrevNodePtr,
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
A RDataFrame node that produces a result.
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 *r, TypeList< ColTypes... >, const RColumnReadersInfo &colInfo, const std::string &variationName="nominal")
Create a group of column readers, one per type in the parameter pack.
std::vector< std::string > ColumnNames_t
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....
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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.