11 #ifndef ROOT_RLAZYDSIMPL 12 #define ROOT_RLAZYDSIMPL 40 template <
typename... ColumnTypes>
44 std::tuple<RResultPtr<std::vector<ColumnTypes>>...>
fColumns;
58 auto colNameStr = std::string(colName);
61 auto it = fColTypesMap.find(colNameStr);
62 if (fColTypesMap.end() == it) {
63 std::string err =
"The specified column name, \"" + colNameStr +
"\" is not known to the data source.";
64 throw std::runtime_error(err);
67 const auto colIdName = it->second;
68 if (colIdName != idName) {
69 std::string err =
"Column " + colNameStr +
" has type " + colIdName +
70 " while the id specified is associated to type " + idName;
71 throw std::runtime_error(err);
74 const auto colBegin = fColNames.begin();
75 const auto colEnd = fColNames.end();
76 const auto namesIt = std::find(colBegin, colEnd, colName);
77 const auto index = std::distance(colBegin, namesIt);
81 ret[slot] = fPointerHolders[index][slot]->GetPointerAddr();
87 template <std::size_t...
S>
90 std::initializer_list<int> expander{
91 (*
static_cast<ColumnTypes *
>(fPointerHolders[
S][slot]->GetPointer()) = (*std::get<S>(
fColumns))[entry], 0)...};
95 template <std::size_t...
S>
101 const std::vector<size_t> colLengths{std::get<S>(
fColumns)->size()...};
102 const auto expectedLen = colLengths[0];
104 for (
auto i :
TSeqI(1, colLengths.size())) {
105 if (expectedLen != colLengths[i]) {
106 err +=
"Column \"" + fColNames[i] +
"\" and column \"" + fColNames[0] +
107 "\" have different lengths: " + std::to_string(expectedLen) +
" and " +
108 std::to_string(colLengths[i]);
112 throw std::runtime_error(err);
119 fColNames({colsNameVals.first...}),
127 for (
auto &&ptrHolderv : fPointerHolders) {
128 for (
auto &&ptrHolder : ptrHolderv) {
144 const auto key = std::string(colName);
145 return fColTypesMap.at(key);
150 const auto key = std::string(colName);
151 const auto endIt = fColTypesMap.end();
152 return endIt != fColTypesMap.find(key);
164 const auto nCols = fColNames.size();
165 fPointerHolders.resize(nCols);
167 for (
auto &&ptrHolderv : fPointerHolders) {
169 auto ptrHolder = fPointerHoldersModels[colIndex]->GetDeepCopy();
170 ptrHolderv.emplace_back(ptrHolder);
175 for (
auto &&ptrHolder : fPointerHoldersModels)
183 const auto nEntriesInRange = nEntries /
fNSlots;
189 end =
init + nEntriesInRange;
void SetNSlots(unsigned int nSlots)
Inform RDataSource of the number of processing slots (i.e.
Smart pointer for the return type of actions.
std::vector< PointerHolderPtrs_t > fPointerHolders
Namespace for new ROOT classes and functions.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges()
Return ranges of entries to distribute to tasks.
std::vector< ROOT::Internal::TDS::TPointerHolder * > PointerHolderPtrs_t
void SetEntryHelper(unsigned int slot, ULong64_t entry, std::index_sequence< S... >)
std::string GetTypeName(std::string_view colName) const
Type of a column as a string, e.g.
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset's column names.
Record_t GetColumnReadersImpl(std::string_view colName, const std::type_info &id)
type-erased vector of pointers to pointers to column values - one per slot
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
std::string TypeID2TypeName(const std::type_info &id)
Returns the name of a type starting from its type_info An empty string is returned in case of failure...
static constexpr double second
const PointerHolderPtrs_t fPointerHoldersModels
bool SetEntry(unsigned int slot, ULong64_t entry)
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot...
RooArgSet S(const RooAbsArg &v1)
const std::vector< std::string > fColNames
A RDataSource implementation which is built on top of result proxies.
RLazyDS(std::pair< std::string, RResultPtr< std::vector< ColumnTypes >>>... colsNameVals)
std::vector< void * > Record_t
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
void ColLenghtChecker(std::index_sequence< S... >)
A pseudo container class which is a generator of indices.
unsigned long long ULong64_t
basic_string_view< char > string_view
make_index_sequence< sizeof...(_Tp)> index_sequence_for
Class to wrap a pointer and delete the memory associated to it correctly.
typedef void((*Func_t)())
const std::map< std::string, std::string > fColTypesMap
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
size_t GetEntriesNumber()
std::tuple< RResultPtr< std::vector< ColumnTypes > >... > fColumns
void Initialise()
Convenience method called before starting an event-loop.