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 "Utils.hxx"
17#include <Rtypes.h> // Long64_t, R__CLING_PTRCHECK
18
19#include <limits>
20#include <type_traits>
21
22#include <memory>
23#include <string>
24#include <string_view>
25#include <unordered_map>
26#include <unordered_set>
27
28namespace ROOT {
29namespace Internal {
30namespace RDF {
31
33
34/// Column reader for defined columns.
35class R__CLING_PTRCHECK(off) RDefineReader final : public ROOT::Detail::RDF::RColumnReaderBase {
36 /// Non-owning reference to the node responsible for the defined column.
38
39 /// Non-owning ptr to the defined value.
40 void *fValuePtr = nullptr;
41
42 /// The slot this value belongs to.
43 unsigned int fSlot = std::numeric_limits<unsigned int>::max();
44
45 void *GetImpl(Long64_t entry) final
46 {
47 fDefine.Update(fSlot, entry);
48 return fValuePtr;
49 }
50
51public:
52 RDefineReader(unsigned int slot, RDFDetail::RDefineBase &define)
53 : fDefine(define), fValuePtr(define.GetValuePtr(slot)), fSlot(slot)
54 {
55 }
56};
57
58/// A helper type that keeps track of RDefine objects and their corresponding RDefineReaders.
60
61 // this is a shared_ptr only because we have to track its lifetime with a weak_ptr that we pass to jitted code
62 // (see BookDefineJit). it is never null.
63 std::shared_ptr<ROOT::Detail::RDF::RDefineBase> fDefine;
64 // Column readers per variation (in the map) per slot (in the vector).
65 std::vector<std::unordered_map<std::string_view, std::unique_ptr<RDefineReader>>> fReadersPerVariation;
66
67 // Strings that were already used to represent column names in this RDataFrame instance.
69
70public:
71 RDefinesWithReaders(std::shared_ptr<ROOT::Detail::RDF::RDefineBase> define, unsigned int nSlots,
72 ROOT::Internal::RDF::RStringCache &cachedColNames);
73 ROOT::Detail::RDF::RDefineBase &GetDefine() const { return *fDefine; }
74 ROOT::Internal::RDF::RDefineReader &GetReader(unsigned int slot, std::string_view variationName);
75};
76
77} // namespace RDF
78} // namespace Internal
79}
80
81#endif
long long Long64_t
Definition RtypesCore.h:69
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::vector< std::unordered_map< std::string_view, std::unique_ptr< RDefineReader > > > fReadersPerVariation
ROOT::Detail::RDF::RDefineBase & GetDefine() const
ROOT::Internal::RDF::RStringCache & fCachedColNames
A Thread-safe cache for strings.
Definition Utils.hxx:285
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...