Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RJittedDefine.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 09/2018
2
3/*************************************************************************
4 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RJITTEDCUSTOMCOLUMN
12#define ROOT_RJITTEDCUSTOMCOLUMN
13
16#include "ROOT/RDF/Utils.hxx" // TypeName2TypeID
17#include "ROOT/RStringView.hxx"
18#include "RtypesCore.h"
19
20#include <memory>
21#include <type_traits>
22
23class TTreeReader;
24
25namespace ROOT {
26namespace Detail {
27namespace RDF {
28
29/// A wrapper around a concrete RDefine, which forwards all calls to it
30/// RJittedDefine is a placeholder that is put in the collection of custom columns in place of a RDefine
31/// that will be just-in-time compiled. Jitted code will assign the concrete RDefine to this RJittedDefine
32/// before the event-loop starts.
33class RJittedDefine : public RDefineBase {
34 std::unique_ptr<RDefineBase> fConcreteDefine = nullptr;
35 /// Type info obtained through TypeName2TypeID based on the column type name.
36 /// The expectation is that this always compares equal to fConcreteDefine->GetTypeId() (which however is only
37 /// available after jitting). It can be null if TypeName2TypeID failed to figure out this type.
38 const std::type_info *fTypeId = nullptr;
39
40public:
41 RJittedDefine(std::string_view name, std::string_view type, RLoopManager &lm,
42 const RDFInternal::RColumnRegister &colRegister, const ColumnNames_t &columns)
43 : RDefineBase(name, type, colRegister, lm, columns)
44 {
45 // try recovering the type_info of this type, no problem if we fail (as long as no one calls GetTypeId)
46 try {
48 } catch (const std::runtime_error &) {
49 }
50 }
52
53 void SetDefine(std::unique_ptr<RDefineBase> c) { fConcreteDefine = std::move(c); }
54
55 void InitSlot(TTreeReader *r, unsigned int slot) final;
56 void *GetValuePtr(unsigned int slot) final;
57 const std::type_info &GetTypeId() const final;
58 void Update(unsigned int slot, Long64_t entry) final;
59 void Update(unsigned int slot, const ROOT::RDF::RSampleInfo &id) final;
60 void FinaliseSlot(unsigned int slot) final;
61 void MakeVariations(const std::vector<std::string> &variations) final;
62 RDefineBase &GetVariedDefine(const std::string &variationName) final;
63};
64
65} // ns RDF
66} // ns Detail
67} // ns ROOT
68
69#endif // ROOT_RJITTEDCUSTOMCOLUMN
ROOT::R::TRInterface & r
Definition Object.C:4
#define c(i)
Definition RSha256.hxx:101
long long Long64_t
Definition RtypesCore.h:80
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
A wrapper around a concrete RDefine, which forwards all calls to it RJittedDefine is a placeholder th...
void InitSlot(TTreeReader *r, unsigned int slot) final
void FinaliseSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
RJittedDefine(std::string_view name, std::string_view type, RLoopManager &lm, const RDFInternal::RColumnRegister &colRegister, const ColumnNames_t &columns)
RDefineBase & GetVariedDefine(const std::string &variationName) final
Return a clone of this Define that works with values in the variationName "universe".
const std::type_info * fTypeId
Type info obtained through TypeName2TypeID based on the column type name.
std::unique_ptr< RDefineBase > fConcreteDefine
void MakeVariations(const std::vector< std::string > &variations) final
Create clones of this Define that work with values in varied "universes".
void SetDefine(std::unique_ptr< RDefineBase > c)
const std::type_info & GetTypeId() const final
void * GetValuePtr(unsigned int slot) final
Return the (type-erased) address of the Define'd value for the given processing slot.
The head node of a RDF computation graph.
A binder for user-defined columns and aliases.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition TTreeReader.h:44
const std::type_info & TypeName2TypeID(const std::string &name)
Return the type_info associated to a name.
Definition RDFUtils.cxx:51
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...