11#ifndef ROOT_RCUSTOMCOLUMN
12#define ROOT_RCUSTOMCOLUMN
37namespace CustomColExtraArgs {
44template <
typename F,
typename ExtraArgsTag = CustomColExtraArgs::None>
53 RDFInternal::RemoveFirstParameterIf_t<std::is_same<ExtraArgsTag, SlotTag>::value,
FunParamTypes_t>;
55 RDFInternal::RemoveFirstTwoParametersIf_t<std::is_same<ExtraArgsTag, SlotAndEntryTag>::value,
ColumnTypesTmp_t>;
56 using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
60 typename std::conditional<std::is_same<ret_type, bool>::value, std::deque<ret_type>, std::vector<ret_type>>
::type;
67 std::vector<std::array<std::unique_ptr<RColumnReaderBase>, ColumnTypes_t::list_size>>
fValues;
70 std::array<bool, ColumnTypes_t::list_size>
fIsDefine;
72 template <
typename... ColTypes, std::size_t... S>
75 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
76 fExpression(fValues[slot][S]->
template Get<ColTypes>(entry)...);
82 template <
typename... ColTypes, std::size_t... S>
85 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
86 fExpression(slot, fValues[slot][S]->
template Get<ColTypes>(entry)...);
92 template <
typename... ColTypes, std::size_t... S>
96 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
97 fExpression(slot, entry, fValues[slot][S]->
template Get<ColTypes>(entry)...);
107 :
RDefineBase(
name,
type, nSlots, defines, DSValuePtrs, ds), fExpression(std::move(expression)),
108 fColumnNames(columns), fLastResults(fNSlots *
RDFInternal::CacheLineStep<
ret_type>()), fValues(fNSlots),
111 const auto nColumns = fColumnNames.size();
112 for (
auto i = 0u; i < nColumns; ++i)
113 fIsDefine[i] = fDefines.HasName(fColumnNames[i]);
121 if (!fIsInitialized[slot]) {
122 fIsInitialized[slot] =
true;
125 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = -1;
132 return static_cast<void *
>(&fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()]);
138 if (entry != fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()]) {
141 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = entry;
150 if (fIsInitialized[slot]) {
151 for (
auto &
v : fValues[slot])
153 fIsInitialized[slot] =
false;
typedef void((*Func_t)())
RDFInternal::RemoveFirstParameterIf_t< std::is_same< ExtraArgsTag, SlotTag >::value, FunParamTypes_t > ColumnTypesTmp_t
RDefine(const RDefine &)=delete
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >, SlotAndEntryTag)
void * GetValuePtr(unsigned int slot) final
Return the (type-erased) address of the Define'd value for the given processing slot.
std::vector< std::array< std::unique_ptr< RColumnReaderBase >, ColumnTypes_t::list_size > > fValues
Column readers per slot and per input column.
void InitSlot(TTreeReader *r, unsigned int slot) final
const std::type_info & GetTypeId() const
ValuesPerSlot_t fLastResults
typename CallableTraits< F >::ret_type ret_type
typename std::conditional< std::is_same< ret_type, bool >::value, std::deque< ret_type >, std::vector< ret_type > >::type ValuesPerSlot_t
RDefine(std::string_view name, std::string_view type, F expression, const ColumnNames_t &columns, unsigned int nSlots, const RDFInternal::RBookedDefines &defines, const std::map< std::string, std::vector< void * > > &DSValuePtrs, ROOT::RDF::RDataSource *ds)
std::make_index_sequence< ColumnTypes_t::list_size > TypeInd_t
RDefine & operator=(const RDefine &)=delete
typename CallableTraits< F >::arg_types FunParamTypes_t
const ColumnNames_t fColumnNames
void FinaliseSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >, SlotTag)
void Update(unsigned int slot, Long64_t entry) final
Update the value at the address returned by GetValuePtr with the content corresponding to the given e...
RDFInternal::RemoveFirstTwoParametersIf_t< std::is_same< ExtraArgsTag, SlotAndEntryTag >::value, ColumnTypesTmp_t > ColumnTypes_t
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >, NoneTag)
std::array< bool, ColumnTypes_t::list_size > fIsDefine
The nth flag signals whether the nth input column is a custom column or not.
Encapsulates the columns defined by the user.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
std::vector< std::string > ColumnNames_t
std::array< std::unique_ptr< RDFDetail::RColumnReaderBase >, sizeof...(ColTypes)> MakeColumnReaders(unsigned int slot, TTreeReader *r, TypeList< ColTypes... >, const RColumnReadersInfo &colInfo)
Create a group of column readers, one per type in the parameter pack.
ROOT type_traits extensions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Extract types from the signature of a callable object. See CallableTraits.
This type aggregates some of the arguments passed to InitColumnReaders.
Lightweight storage for a collection of types.