45template <
typename... ColumnTypes>
49 std::tuple<ROOT::RVec<ColumnTypes>*...>
fColumns;
67 auto colNameStr = std::string(colName);
72 std::string err =
"The specified column name, \"" + colNameStr +
"\" is not known to the data source.";
73 throw std::runtime_error(err);
76 const auto colIdName = it->second;
77 if (colIdName != idName) {
78 std::string err =
"Column " + colNameStr +
" has type " + colIdName +
79 " while the id specified is associated to type " + idName;
80 throw std::runtime_error(err);
85 const auto namesIt = std::find(colBegin, colEnd, colName);
86 const auto index = std::distance(colBegin, namesIt);
96 template <std::size_t... S>
99 std::initializer_list<int> expander{
100 (*
static_cast<ColumnTypes *
>(
fPointerHolders[S][slot]->GetPointer()) = (*std::get<S>(
fColumns))[entry], 0)...};
104 template <std::size_t... S>
107 if (
sizeof...(S) < 2)
110 const std::vector<size_t> colLengths{std::get<S>(
fColumns)->size()...};
111 const auto expectedLen = colLengths[0];
113 for (
auto i :
TSeqI(1, colLengths.size())) {
114 if (expectedLen != colLengths[i]) {
116 "\" have different lengths: " + std::to_string(expectedLen) +
" and " +
117 std::to_string(colLengths[i]);
121 throw std::runtime_error(err);
126 std::string
AsString() {
return "Numpy data source"; };
131 :
fColumns(std::tuple<
ROOT::
RVec<ColumnTypes>*...>(colsNameVals.second...)),
144 for (
auto &&ptrHolder : ptrHolderv) {
162 const auto key = std::string(colName);
168 const auto key = std::string(colName);
175 SetEntryHelper(slot, entry, std::index_sequence_for<ColumnTypes...>());
188 ptrHolderv.emplace_back(ptrHolder);
201 const auto nEntriesInRange = nEntries /
fNSlots;
207 end = init + nEntriesInRange;
224template <
typename... ColumnTypes>
229 std::forward<PyObject*>(pyRVecs),
unsigned long long ULong64_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
A RDataSource implementation which takes a collection of RVecs, which are able to adopt data from Num...
const std::map< std::string, std::string > fColTypesMap
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
std::vector< PointerHolderPtrs_t > fPointerHolders
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
bool SetEntry(unsigned int slot, ULong64_t entry)
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
std::tuple< ROOT::RVec< ColumnTypes > *... > fColumns
void SetEntryHelper(unsigned int slot, ULong64_t entry, std::index_sequence< S... >)
size_t GetEntriesNumber()
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 ColLengthChecker(std::index_sequence< S... >)
const PointerHolderPtrs_t fPointerHoldersModels
const std::vector< std::string > fColNames
void Initialize()
Convenience method called before starting an event-loop.
RNumpyDS(PyObject *pyRVecs, std::pair< std::string, ROOT::RVec< ColumnTypes > * >... colsNameVals)
void SetNSlots(unsigned int nSlots)
Inform RDataSource of the number of processing slots (i.e.
std::string GetTypeName(std::string_view colName) const
Type of a column as a string, e.g.
std::string GetLabel()
Return a string representation of the datasource type.
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
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset's column names.
Class to wrap a pointer and delete the memory associated to it correctly.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
std::vector< void * > Record_t
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
A "std::vector"-like collection of values implementing handy operation to analyse them.
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...
RDataFrame * MakeNumpyDataFrame(PyObject *pyRVecs, std::pair< std::string, ROOT::RVec< ColumnTypes > * > &&... colNameProxyPairs)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
TSeq< unsigned int > TSeqU