48template <
typename... ColumnTypes>
52 std::tuple<ROOT::RVec<ColumnTypes>...>
fColumns;
67 template <std::size_t... S>
70 std::initializer_list<int> expander{
75 template <std::size_t... S>
81 const std::vector<size_t> colLengths{std::get<S>(
fColumns).size()...};
82 const auto expectedLen = colLengths[0];
84 for (
auto i :
TSeqI(1, colLengths.size())) {
85 if (expectedLen != colLengths[i]) {
87 "\" have different lengths: " + std::to_string(expectedLen) +
" and " +
88 std::to_string(colLengths[i]);
92 throw std::runtime_error(
err);
97 std::string
AsString() {
return "Numpy data source"; };
105 fLifeline{std::move(lifeline)}
117 for (
auto &&ptrHolder : ptrHolderv) {
123 std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>
124 GetColumnReaders(
unsigned int slot, std::string_view colName,
const std::type_info &
id)
final
126 auto colNameStr = std::string(colName);
130 std::string
err =
"The specified column name, \"" + colNameStr +
"\" is not known to the data source.";
131 throw std::runtime_error(
err);
134 const auto &colIdName = it->second;
136 if (colIdName != idName) {
137 std::string
err =
"Column " + colNameStr +
" has type " + colIdName +
138 " while the id specified is associated to type " + idName;
139 throw std::runtime_error(
err);
143 const auto index = std::distance(
fColNames.begin(), colNameIt);
144 return std::make_unique<ROOT::Internal::RDF::RVecDSColumnReader>(
fPointerHolders[index][slot]);
147 throw std::runtime_error(
"Could not find column name \"" + colNameStr +
"\" in available column names.");
160 const auto key = std::string(colName);
166 const auto key = std::string(colName);
173 SetEntryHelper(slot, entry, std::index_sequence_for<ColumnTypes...>());
186 ptrHolderv.emplace_back(ptrHolder);
199 const auto nEntriesInRange = nEntries /
fNSlots;
205 end = init + nEntriesInRange;
223template <
typename... ColumnTypes>
224std::unique_ptr<RDataFrame>
227 return std::make_unique<RDataFrame>(
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
TPointerHolder * fPtrHolder
RVecDSColumnReader(TPointerHolder *ptrHolder)
void * GetImpl(Long64_t) final
A RDataSource implementation which takes a collection of RVecs, which are able to adopt data from Num...
size_t GetEntriesNumber()
std::vector< PointerHolderPtrs_t > fPointerHolders
void Initialize()
Convenience method called before starting an event-loop.
RVecDS & operator=(const RVecDS &)=delete
std::string GetTypeName(std::string_view colName) const
Type of a column as a string, e.g.
std::unordered_map< std::string, std::string > fColTypesMap
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset's column names.
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
std::string GetLabel()
Return a string representation of the datasource type.
RVecDS & operator=(RVecDS &&)=delete
std::vector< std::string > fColNames
RVecDS(const RVecDS &)=delete
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
void SetEntryHelper(unsigned int slot, ULong64_t entry, std::index_sequence< S... >)
PointerHolderPtrs_t fPointerHoldersModels
void ColLengthChecker(std::index_sequence< S... >)
std::unique_ptr< ROOT::Detail::RDF::RColumnReaderBase > GetColumnReaders(unsigned int slot, std::string_view colName, const std::type_info &id) final
If the other GetColumnReaders overload returns an empty vector, this overload will be called instead.
Record_t GetColumnReadersImpl(std::string_view, const std::type_info &)
type-erased vector of pointers to pointers to column values - one per slot
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges()
Return ranges of entries to distribute to tasks.
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
RVecDS(std::any lifeline, std::pair< std::string, ROOT::RVec< ColumnTypes > > const &...colsNameVals)
std::vector< ROOT::Internal::RDF::TPointerHolder * > PointerHolderPtrs_t
Mother class of TTypedPointerHolder.
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
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...
std::unique_ptr< RDataFrame > MakeRVecDataFrame(std::any lifeline, std::pair< std::string, ROOT::RVec< ColumnTypes > > const &...colNameProxyPairs)