|
ROOT
Reference Guide |
|
Go to the documentation of this file.
11 #ifndef ROOT_RRESULTPTR
12 #define ROOT_RRESULTPTR
22 #include <type_traits>
29 template <
typename Proxied,
typename DataSource>
43 template <
typename DS>
48 Warning(
"Snapshot",
"A lazy Snapshot action was booked but never triggered.");
59 RResultPtr<T>
MakeResultPtr(
const std::shared_ptr<T> &
r, RLoopManager &df,
60 std::shared_ptr<ROOT::Internal::RDF::RActionBase> actionPtr);
64 class RMergeableValue;
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);
363 template <
typename T>
369 template <
class T1,
class T2>
375 template <
class T1,
class T2>
411 template <
typename T>
438 template <
typename T>
444 return std::unique_ptr<RMergeableValue<T>>{
RResultPtr(const RResultPtr &)=default
void Run()
Start the event loop with a different mechanism depending on IMT/no IMT, data source/no data source.
Helper class that provides the operation graph nodes.
ROOT type_traits extensions.
static constexpr ULong64_t kOnce
Convenience definition to express a callback must be executed once.
void TriggerRun()
Triggers the event loop in the RLoopManager.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void WarnOnLazySnapshotNotTriggered(const ROOT::RDF::RResultPtr< T > &)
RDFDetail::RLoopManager * fLoopManager
Non-owning pointer to the RLoopManager at the root of this computation graph.
bool operator!=(const RResultPtr< T1 > &lhs, const RResultPtr< T2 > &rhs)
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 ...
std::shared_ptr< RDFInternal::RActionBase > fActionPtr
Owning pointer to the action that will produce this result.
std::unique_ptr< RMergeableValue< T > > GetMergeableValue(RResultPtr< T > &rptr)
Retrieve a mergeable value from an RDataFrame action.
Smart pointer for the return type of actions.
T * operator->()
Get a pointer to the encapsulated object.
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-...
SPT_t fObjPtr
Shared pointer encapsulating the wrapped result.
RResultPtr< T > & OnPartialResult(ULong64_t everyNEvents, std::function< void(T &)> callback)
Register a callback that RDataFrame will execute "everyNEvents" on a partial result.
bool IsReady() const
Check whether the result has already been computed.
A result of an RDataFrame execution, that knows how to merge with other results of the same type.
RIterationHelper< T >::Iterator_t end()
Return an iterator to the end of the contained object if this makes sense, throw a compilation error ...
T * GetPtr()
Get the pointer to the encapsulated object.
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
std::shared_ptr< T > SPT_t
T Value_t
Convenience alias to simplify access to proxied type.
RResultPtr(std::shared_ptr< T > objPtr, RDFDetail::RLoopManager *lm, std::shared_ptr< RDFInternal::RActionBase > actionPtr)
typedef void((*Func_t)())
The public interface to the RDataFrame federation of classes.
T & operator*()
Get a pointer to the encapsulated object.
RResultPtr(const RResultPtr< T2 > &r)
Convert a RResultPtr<T2> to a RResultPtr<T>.
RResultPtr & operator=(RResultPtr &&)=default
unsigned long long ULong64_t
friend bool operator!=(const RResultPtr< T1 > &lhs, const RResultPtr< T2 > &rhs)
const T & GetValue()
Get a const reference to the encapsulated object.
T * Get()
Get the pointer to the encapsulated result.
RResultPtr & operator=(const RResultPtr &)=default
void RegisterCallback(ULong64_t everyNEvents, std::function< void(unsigned int)> &&f)
RIterationHelper< T >::Iterator_t begin()
Return an iterator to the beginning of the contained object if this makes sense, throw a compilation ...
unsigned int GetNSlots() const
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
friend bool operator==(const RResultPtr< T1 > &lhs, const RResultPtr< T2 > &rhs)
RResultPtr(RResultPtr &&)=default
The head node of a RDF computation graph.
bool operator==(const RResultPtr< T1 > &lhs, const RResultPtr< T2 > &rhs)