Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RDefineReader.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud CERN 09/2020
2
3/*************************************************************************
4 * Copyright (C) 1995-2020, 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_RDF_RDEFINEREADER
12#define ROOT_RDF_RDEFINEREADER
13
14#include "RColumnReaderBase.hxx"
15#include "RDefineBase.hxx"
16#include <Rtypes.h> // Long64_t, R__CLING_PTRCHECK
17
18#include <limits>
19#include <type_traits>
20
21#include <memory>
22#include <string>
23#include <string_view>
24#include <unordered_map>
25#include <unordered_set>
26
27namespace ROOT {
28namespace Internal {
29namespace RDF {
30
32
33/// Column reader for defined columns.
34class R__CLING_PTRCHECK(off) RDefineReader final : public ROOT::Detail::RDF::RColumnReaderBase {
35 /// Non-owning reference to the node responsible for the defined column.
37
38 /// Non-owning ptr to the defined value.
39 void *fValuePtr = nullptr;
40
41 /// The slot this value belongs to.
42 unsigned int fSlot = std::numeric_limits<unsigned int>::max();
43
44 void *GetImpl(Long64_t entry) final
45 {
46 fDefine.Update(fSlot, entry);
47 return fValuePtr;
48 }
49
50public:
51 RDefineReader(unsigned int slot, RDFDetail::RDefineBase &define)
52 : fDefine(define), fValuePtr(define.GetValuePtr(slot)), fSlot(slot)
53 {
54 }
55};
56
57/// A helper type that keeps track of RDefine objects and their corresponding RDefineReaders.
59
60 // this is a shared_ptr only because we have to track its lifetime with a weak_ptr that we pass to jitted code
61 // (see BookDefineJit). it is never null.
62 std::shared_ptr<ROOT::Detail::RDF::RDefineBase> fDefine;
63 // Column readers per variation (in the map) per slot (in the vector).
64 std::vector<std::unordered_map<std::string_view, std::unique_ptr<RDefineReader>>> fReadersPerVariation;
65
66 // Strings that were already used to represent column names in this RDataFrame instance.
67 std::unordered_set<std::string> &fCachedColNames;
68
69public:
70 RDefinesWithReaders(std::shared_ptr<ROOT::Detail::RDF::RDefineBase> define, unsigned int nSlots,
71 std::unordered_set<std::string> &cachedColNames);
72 ROOT::Detail::RDF::RDefineBase &GetDefine() const { return *fDefine; }
73 ROOT::Internal::RDF::RDefineReader &GetReader(unsigned int slot, std::string_view variationName);
74};
75
76} // namespace RDF
77} // namespace Internal
78}
79
80#endif
long long Long64_t
Definition RtypesCore.h:80
virtual void Update(unsigned int slot, Long64_t entry)=0
Update the value at the address returned by GetValuePtr with the content corresponding to the given e...
Column reader for defined columns.
void * GetImpl(Long64_t entry) final
RDefineReader(unsigned int slot, RDFDetail::RDefineBase &define)
RDFDetail::RDefineBase & fDefine
Non-owning reference to the node responsible for the defined column.
A helper type that keeps track of RDefine objects and their corresponding RDefineReaders.
std::shared_ptr< ROOT::Detail::RDF::RDefineBase > fDefine
std::unordered_set< std::string > & fCachedColNames
std::vector< std::unordered_map< std::string_view, std::unique_ptr< RDefineReader > > > fReadersPerVariation
ROOT::Detail::RDF::RDefineBase & GetDefine() const
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...