11#ifndef ROOT_RACTIONSNAPSHOT
12#define ROOT_RACTIONSNAPSHOT
26namespace GraphDrawing {
29 std::unordered_map<
void *, std::shared_ptr<GraphNode>> &
visitedMap);
32class SnapshotHelperWithVariations;
34template <
typename Helper,
typename PrevNode>
44 std::vector<std::vector<RColumnReaderBase *>>
fValues;
56 const std::vector<const std::type_info *> &
colTypeIDs, std::shared_ptr<PrevNode>
pd,
59 fHelper(std::
move(
h)),
64 fLoopManager->Register(
this);
71 if constexpr (std::is_same_v<Helper, SnapshotHelperWithVariations>) {
72 if (
const auto &variations = GetVariations(); !variations.empty()) {
74 fPrevNodes.reserve(1 + variations.size());
82 for (
const auto &
variation : variations) {
84 fPrevNodes.emplace_back(
108 return fHelper.GetMergeableValue();
116 RActionBase::GetColumnNames(), fColTypeIDs);
118 if constexpr (std::is_same_v<Helper, SnapshotHelperWithVariations>) {
121 auto const &variations = GetVariations();
125 RActionBase::GetColumnNames(), fColTypeIDs, variations[
variationIndex]);
126 for (
unsigned int i = 0; i <
readers.size(); ++i) {
131 fHelper.RegisterVariedColumn(
slot, i, i, 0,
140 fHelper.InitTask(
r,
slot);
150 throw std::out_of_range{
"RDataFrame: Action (" + fHelper.GetActionName() +
151 ") could not retrieve value for column '" + fColumnNames[
readerIdx] +
"' for entry " +
152 std::to_string(
entry) +
153 ". You can use the DefaultValueFor operation to provide a default value, or "
154 "FilterAvailable/FilterMissing to discard/keep entries with missing values instead."};
170 if constexpr (std::is_same_v<Helper, SnapshotHelperWithVariations>) {
172 std::vector<bool>
filterPassed(fPrevNodes.size(),
false);
190 if (fPrevNodes.front()->CheckFilters(
slot,
entry))
197 for (
auto const &node : fPrevNodes)
198 node->IncrChildrenCount();
204 fValues[
slot].clear();
205 fHelper.CallFinalizeTask(
slot);
216 std::shared_ptr<GraphDrawing::GraphNode>
220 const auto nodeType = HasRun() ? GraphDrawing::ENodeType::kUsedAction : GraphDrawing::ENodeType::kAction;
224 for (
auto const &node : fPrevNodes) {
226 const auto &
prevColumns = prevNode->GetDefinedColumns();
229 thisNode->AddDefinedColumns(GetColRegister().GenerateColumnNames());
241 throw std::logic_error(
"RDataFrame::Snapshot: The snapshot action cannot be varied. Instead, switch on "
242 "variations in RSnapshotOptions.");
253 return std::make_unique<RActionSnapshot>(fHelper.CallMakeNew(
newResult), GetColumnNames(), fColTypeIDs,
254 fPrevNodes.front(), GetColRegister());
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long long Long64_t
Portable signed long integer 8 bytes.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
Base class for non-leaf nodes of the computational graph.
RActionSnapshot & operator=(const RActionSnapshot &)=delete
void CallExec(unsigned int slot, Long64_t entry)
ROOT::RDF::SampleCallback_t GetSampleCallback() final
void TriggerChildrenCount() final
std::vector< std::shared_ptr< PrevNode > > fPrevNodes
Pointer to the previous node in this branch of the computation graph.
std::unique_ptr< RActionBase > MakeVariedAction(std::vector< void * > &&) final
Will throw, since varied actions are unsupported. Instead, set a flag in RSnapshotOptions.
std::vector< bool > fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
std::vector< std::vector< RColumnReaderBase * > > fValues
Column readers per slot and per input column.
void InitSlot(TTreeReader *r, unsigned int slot) final
void * PartialUpdate(unsigned int slot) final
Forwards to the action helpers; will throw since PartialUpdate not supported for most snapshot helper...
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
std::unique_ptr< RActionBase > CloneAction(void *newResult) final
Returns a new action with a cloned helper.
RActionSnapshot(Helper &&h, const std::vector< std::string > &columns, const std::vector< const std::type_info * > &colTypeIDs, std::shared_ptr< PrevNode > pd, const RColumnRegister &colRegister)
void * GetValue(unsigned int slot, std::size_t readerIdx, Long64_t entry)
RActionSnapshot(RActionSnapshot &&)=delete
std::vector< const std::type_info * > fColTypeIDs
Types of the columns to Snapshot.
void Finalize() final
Clean-up and finalize the action result (e.g.
std::unique_ptr< ROOT::Detail::RDF::RMergeableValueBase > GetMergeableValue() const final
Retrieve a wrapper to the result of the action that knows how to merge with others of the same type.
std::shared_ptr< GraphDrawing::GraphNode > GetGraph(std::unordered_map< void *, std::shared_ptr< GraphDrawing::GraphNode > > &visitedMap) final
RActionSnapshot(const RActionSnapshot &)=delete
RActionSnapshot & operator=(RActionSnapshot &&)=delete
void Run(unsigned int slot, Long64_t entry) final
A binder for user-defined columns, variations and aliases.
const_iterator begin() const
const_iterator end() const
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::vector< RDFDetail::RColumnReaderBase * > GetUntypedColumnReaders(unsigned int slot, TTreeReader *treeReader, ROOT::Internal::RDF::RColumnRegister &colRegister, ROOT::Detail::RDF::RLoopManager &lm, const std::vector< std::string > &colNames, const std::vector< const std::type_info * > &colTypeIDs, const std::string &variationName="nominal")
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....