@@ -32,6 +32,14 @@ namespace Internal {
3232
3333namespace RDF {
3434
35+ class R__CLING_PTRCHECK (off) RVecDSColumnReader final : public ROOT::Detail::RDF::RColumnReaderBase {
36+ TPointerHolder *fPtrHolder ;
37+ void *GetImpl (Long64_t) final { return fPtrHolder ->GetPointer (); }
38+
39+ public:
40+ RVecDSColumnReader (TPointerHolder *ptrHolder) : fPtrHolder (ptrHolder) {}
41+ };
42+
3543// //////////////////////////////////////////////////////////////////////////////////////////////
3644// / \brief A RDataSource implementation which takes a collection of RVecs, which
3745// / are able to adopt data from Numpy arrays
@@ -46,46 +54,18 @@ class RVecDS final : public ROOT::RDF::RDataSource {
4654 using PointerHolderPtrs_t = std::vector<ROOT::Internal::RDF::TPointerHolder *>;
4755
4856 std::tuple<ROOT::RVec<ColumnTypes>...> fColumns ;
49- const std::vector<std::string> fColNames ;
50- const std::map <std::string, std::string> fColTypesMap ;
57+ std::vector<std::string> fColNames ;
58+ std::unordered_map <std::string, std::string> fColTypesMap ;
5159 // The role of the fPointerHoldersModels is to be initialised with the pack
5260 // of arguments in the constrcutor signature at construction time
5361 // Once the number of slots is known, the fPointerHolders are initialised
5462 // according to the models.
55- const PointerHolderPtrs_t fPointerHoldersModels ;
63+ PointerHolderPtrs_t fPointerHoldersModels ;
5664 std::vector<PointerHolderPtrs_t> fPointerHolders ;
5765 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges {};
5866 std::function<void ()> fDeleteRVecs ;
5967
60- Record_t GetColumnReadersImpl (std::string_view colName, const std::type_info &id)
61- {
62- auto colNameStr = std::string (colName);
63- // This could be optimised and done statically
64- const auto idName = ROOT::Internal::RDF::TypeID2TypeName (id);
65- auto it = fColTypesMap .find (colNameStr);
66- if (fColTypesMap .end () == it) {
67- std::string err = " The specified column name, \" " + colNameStr + " \" is not known to the data source." ;
68- throw std::runtime_error (err);
69- }
70-
71- const auto colIdName = it->second ;
72- if (colIdName != idName) {
73- std::string err = " Column " + colNameStr + " has type " + colIdName +
74- " while the id specified is associated to type " + idName;
75- throw std::runtime_error (err);
76- }
77-
78- const auto colBegin = fColNames .begin ();
79- const auto colEnd = fColNames .end ();
80- const auto namesIt = std::find (colBegin, colEnd, colName);
81- const auto index = std::distance (colBegin, namesIt);
82-
83- Record_t ret (fNSlots );
84- for (auto slot : ROOT::TSeqU (fNSlots )) {
85- ret[slot] = fPointerHolders [index][slot]->GetPointerAddr ();
86- }
87- return ret;
88- }
68+ Record_t GetColumnReadersImpl (std::string_view, const std::type_info &) { return {}; }
8969
9070 size_t GetEntriesNumber () { return std::get<0 >(fColumns ).size (); }
9171 template <std::size_t ... S>
@@ -146,6 +126,33 @@ public:
146126 fDeleteRVecs ();
147127 }
148128
129+ std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>
130+ GetColumnReaders (unsigned int slot, std::string_view colName, const std::type_info &id) final
131+ {
132+ auto colNameStr = std::string (colName);
133+
134+ auto it = fColTypesMap .find (colNameStr);
135+ if (fColTypesMap .end () == it) {
136+ std::string err = " The specified column name, \" " + colNameStr + " \" is not known to the data source." ;
137+ throw std::runtime_error (err);
138+ }
139+
140+ const auto &colIdName = it->second ;
141+ const auto idName = ROOT::Internal::RDF::TypeID2TypeName (id);
142+ if (colIdName != idName) {
143+ std::string err = " Column " + colNameStr + " has type " + colIdName +
144+ " while the id specified is associated to type " + idName;
145+ throw std::runtime_error (err);
146+ }
147+
148+ if (auto colNameIt = std::find (fColNames .begin (), fColNames .end (), colNameStr); colNameIt != fColNames .end ()) {
149+ const auto index = std::distance (fColNames .begin (), colNameIt);
150+ return std::make_unique<ROOT::Internal::RDF::RVecDSColumnReader>(fPointerHolders [index][slot]);
151+ }
152+
153+ throw std::runtime_error (" Could not find column name \" " + colNameStr + " \" in available column names." );
154+ }
155+
149156 const std::vector<std::string> &GetColumnNames () const { return fColNames ; }
150157
151158 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges ()
0 commit comments