11#ifndef ROOT_RRESULTPTR
12#define ROOT_RRESULTPTR
29template <
typename Proxied,
typename DataSource>
48 Warning(
"Snapshot",
"A lazy Snapshot action was booked but never triggered.");
59RResultPtr<T>
MakeResultPtr(
const std::shared_ptr<T> &
r, RLoopManager &df,
60 std::shared_ptr<ROOT::Internal::RDF::RActionBase> actionPtr);
97 using SPT_t = std::shared_ptr<T>;
100 template <
typename T1>
103 template <
typename T1>
105 std::shared_ptr<RDFInternal::RActionBase>);
106 template <
class T1,
class T2>
108 template <
class T1,
class T2>
118 friend std::unique_ptr<RDFDetail::RMergeableValue<T>> RDFDetail::GetMergeableValue<T>(
RResultPtr<T> &rptr);
125 template <typename V, bool hasBeginEnd = TTraits::HasBeginAndEnd<V>::value>
126 struct RIterationHelper {
127 using Iterator_t =
void;
128 void GetBegin(
const V &) {
static_assert(
sizeof(V) == 0,
"It does not make sense to ask begin for this class."); }
129 void GetEnd(
const V &) {
static_assert(
sizeof(V) == 0,
"It does not make sense to ask end for this class."); }
132 template <
typename V>
133 struct RIterationHelper<V, true> {
134 using Iterator_t =
decltype(std::begin(std::declval<V>()));
135 static Iterator_t GetBegin(
const V &
v) {
return std::begin(
v); };
136 static Iterator_t GetEnd(
const V &
v) {
return std::end(
v); };
164 throw std::runtime_error(
"Trying to access the contents of a null RResultPtr.");
168 std::shared_ptr<RDFInternal::RActionBase> actionPtr)
189 template <
typename T2,
typename std::enable_if<std::is_constructible<std::shared_ptr<T>, std::shared_ptr<T2>>::value,
226 typename RIterationHelper<T>::Iterator_t
begin()
231 return RIterationHelper<T>::GetBegin(*
fObjPtr);
236 typename RIterationHelper<T>::Iterator_t
end()
241 return RIterationHelper<T>::GetEnd(*
fObjPtr);
292 auto c = [nSlots, actionPtr, callback](
unsigned int slot) {
293 if (slot != nSlots - 1)
295 auto partialResult =
static_cast<Value_t *
>(actionPtr->PartialUpdate(slot));
296 callback(*partialResult);
337 auto c = [actionPtr, callback](
unsigned int slot) {
338 auto partialResult =
static_cast<Value_t *
>(actionPtr->PartialUpdate(slot));
339 callback(slot, *partialResult);
369template <
class T1,
class T2>
375template <
class T1,
class T2>
444 return std::unique_ptr<RMergeableValue<T>>{
unsigned long long ULong64_t
Bool_t operator!=(const TDatime &d1, const TDatime &d2)
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
typedef void((*Func_t)())
The head node of a RDF computation graph.
void Run()
Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source.
unsigned int GetNSlots() const
void RegisterCallback(ULong64_t everyNEvents, std::function< void(unsigned int)> &&f)
A result of an RDataFrame execution, that knows how to merge with other results of the same type.
Helper class that provides the operation graph nodes.
The public interface to the RDataFrame federation of classes.
Smart pointer for the return type of actions.
bool IsReady() const
Check whether the result has already been computed.
void TriggerRun()
Triggers the event loop in the RLoopManager.
RResultPtr(RResultPtr &&)=default
T * GetPtr()
Get the pointer to the encapsulated object.
RResultPtr< T > & OnPartialResult(ULong64_t everyNEvents, std::function< void(T &)> callback)
Register a callback that RDataFrame will execute "everyNEvents" on a partial result.
RDFDetail::RLoopManager * fLoopManager
Non-owning pointer to the RLoopManager at the root of this computation graph.
friend bool operator!=(const RResultPtr< T1 > &lhs, const RResultPtr< T2 > &rhs)
RIterationHelper< T >::Iterator_t begin()
Return an iterator to the beginning of the contained object if this makes sense, throw a compilation ...
T Value_t
Convenience alias to simplify access to proxied type.
T * Get()
Get the pointer to the encapsulated result.
const T & GetValue()
Get a const reference to the encapsulated object.
RResultPtr(const RResultPtr &)=default
T & operator*()
Get a pointer to the encapsulated object.
RResultPtr & operator=(const RResultPtr &)=default
RResultPtr< T > & OnPartialResultSlot(ULong64_t everyNEvents, std::function< void(unsigned int, T &)> callback)
Register a callback that RDataFrame will execute in each worker thread concurrently on that thread's ...
RResultPtr & operator=(RResultPtr &&)=default
friend bool operator==(const RResultPtr< T1 > &lhs, const RResultPtr< T2 > &rhs)
RResultPtr(const RResultPtr< T2 > &r)
Convert a RResultPtr<T2> to a RResultPtr<T>.
std::shared_ptr< RDFInternal::RActionBase > fActionPtr
Owning pointer to the action that will produce this result.
std::shared_ptr< T > SPT_t
T * operator->()
Get a pointer to the encapsulated object.
SPT_t fObjPtr
Shared pointer encapsulating the wrapped result.
static constexpr ULong64_t kOnce
Convenience definition to express a callback must be executed once.
RResultPtr(std::shared_ptr< T > objPtr, RDFDetail::RLoopManager *lm, std::shared_ptr< RDFInternal::RActionBase > actionPtr)
RIterationHelper< T >::Iterator_t end()
Return an iterator to the end of the contained object if this makes sense, throw a compilation error ...
std::unique_ptr< RMergeableValue< T > > GetMergeableValue(RResultPtr< T > &rptr)
Retrieve a mergeable value from an RDataFrame action.
RResultPtr< T > MakeResultPtr(const std::shared_ptr< T > &r, RLoopManager &df, std::shared_ptr< ROOT::Internal::RDF::RActionBase > actionPtr)
Create a RResultPtr and set its pointer to the corresponding RAction This overload is invoked by non-...
void WarnOnLazySnapshotNotTriggered(const ROOT::RDF::RResultPtr< T > &)
bool operator==(const RConcurrentHashColl::HashValue &lhs, const RConcurrentHashColl::HashValue &rhs)
ROOT type_traits extensions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...