49namespace Experimental {
61 std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
CloneImpl(std::string_view )
const final
63 return std::make_unique<RRDFCardinalityField>();
67 static std::string
TypeName() {
return "std::size_t"; }
75 void GenerateColumnsImpl() final { assert(
false &&
"Cardinality fields must only be used for reading"); }
80 fColumns.emplace_back(std::unique_ptr<ROOT::Experimental::Detail::RColumn>(
81 ROOT::Experimental::Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(model, 0)));
134 std::unique_ptr<RNTupleColumnReader>
Clone()
136 return std::make_unique<RNTupleColumnReader>(
fField->Clone(
fField->GetName()));
142 fField->ConnectPageSource(source);
144 f.ConnectPageSource(source);
162 std::vector<DescriptorId_t> skeinIDs)
202 skeinIDs.emplace_back(fieldId);
204 if (fieldDesc.GetTypeName().empty()) {
206 auto cardinalityField = std::make_unique<ROOT::Experimental::Internal::RRDFCardinalityField>();
207 cardinalityField->SetOnDiskId(fieldId);
208 fColumnNames.emplace_back(
"R_rdf_sizeof_" + std::string(colName));
210 auto cardColReader = std::make_unique<ROOT::Experimental::Internal::RNTupleColumnReader>(
211 std::move(cardinalityField));
215 AddField(desc, std::string(colName) +
"." +
f.GetFieldName(),
f.GetId(), skeinIDs);
220 AddField(desc, colName,
f.GetId(), skeinIDs);
228 auto innerName = colName.empty() ?
f.GetFieldName() : (std::string(colName) +
"." +
f.GetFieldName());
229 AddField(desc, innerName,
f.GetId(), skeinIDs);
236 if (!fieldOrException)
238 auto valueField = fieldOrException.Unwrap();
239 valueField->SetOnDiskId(fieldId);
240 std::unique_ptr<Detail::RFieldBase> cardinalityField;
242 if (!skeinIDs.empty()) {
243 cardinalityField = std::make_unique<ROOT::Experimental::Internal::RRDFCardinalityField>();
244 cardinalityField->SetOnDiskId(skeinIDs.back());
247 for (
auto i = skeinIDs.rbegin(); i != skeinIDs.rend(); ++i) {
248 valueField = std::make_unique<ROOT::Experimental::RRVecField>(
"", std::move(valueField));
249 valueField->SetOnDiskId(*i);
251 if (i != skeinIDs.rbegin()) {
252 cardinalityField = std::make_unique<ROOT::Experimental::RRVecField>(
"", std::move(cardinalityField));
253 cardinalityField->SetOnDiskId(*i);
257 if (cardinalityField) {
258 fColumnNames.emplace_back(
"R_rdf_sizeof_" + std::string(colName));
260 auto cardColReader = std::make_unique<ROOT::Experimental::Internal::RNTupleColumnReader>(
261 std::move(cardinalityField));
265 skeinIDs.emplace_back(fieldId);
268 auto valColReader = std::make_unique<ROOT::Experimental::Internal::RNTupleColumnReader>(std::move(valueField));
274 pageSource->Attach();
275 auto descriptorGuard = pageSource->GetSharedDescriptorGuard();
276 fSources.emplace_back(std::move(pageSource));
278 AddField(descriptorGuard.GetRef(),
"", descriptorGuard->GetFieldZeroId(), std::vector<DescriptorId_t>());
287std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>
306 std::vector<std::pair<ULong64_t, ULong64_t>> ranges;
310 auto nEntries =
fSources[0]->GetNEntries();
311 const auto chunkSize = nEntries /
fNSlots;
318 ranges.emplace_back(start, end);
321 ranges.back().second += reminder;
350 for (
unsigned int i = 1; i <
fNSlots; ++i) {
362 ROOT::RDataFrame rdf(std::make_unique<ROOT::Experimental::RNTupleDS>(std::move(pageSource)));
372ROOT::RDataFrame ROOT::Experimental::MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
void GetCollectionInfo(const NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *collectionSize)
For offset columns only, look at the two adjacent values that define a collection's coordinates.
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName)
Factory method to resurrect a field from the stored on-disk type information.
std::vector< std::unique_ptr< RColumn > > fColumns
The columns are connected either to a sink or to a source (not to both); they are owned by the field.
RColumn * fPrincipalColumn
Points into fColumns.
Abstract interface to read data from an ntuple.
static std::unique_ptr< RPageSource > Create(std::string_view ntupleName, std::string_view location, const RNTupleReadOptions &options=RNTupleReadOptions())
Guess the concrete derived page source from the file name (location)
Every RDF column is represented by exactly one RNTuple field.
std::unique_ptr< RFieldBase > fField
The field backing the RDF column.
Long64_t fLastEntry
Last entry number that was read.
std::unique_ptr< RNTupleColumnReader > Clone()
Column readers are created as prototype and then cloned for every slot.
RNTupleColumnReader(std::unique_ptr< RFieldBase > f)
void * GetImpl(Long64_t entry) final
RFieldValue fValue
The memory location used to read from fField.
void Connect(RPageSource &source)
Connect the field and its subfields to the page source.
An artificial field that transforms an RNTuple column that contains the offset of collections into co...
ROOT::Experimental::Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
RRDFCardinalityField(RRDFCardinalityField &&other)=default
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
void ReadGlobalImpl(ROOT::Experimental::NTupleSize_t globalIndex, ROOT::Experimental::Detail::RFieldValue *value) final
Get the number of elements of the collection identified by globalIndex.
static std::string TypeName()
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
RRDFCardinalityField & operator=(RRDFCardinalityField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void ReadInClusterImpl(const ROOT::Experimental::RClusterIndex &clusterIndex, ROOT::Experimental::Detail::RFieldValue *value) final
Get the number of elements of the collection identified by clusterIndex.
std::unique_ptr< ROOT::Experimental::Detail::RFieldBase > CloneImpl(std::string_view) const final
Called by Clone(), which additionally copies the on-disk ID.
~RRDFCardinalityField()=default
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Holds the static meta-data of a column in a tree.
A field translates read and write calls from/to underlying columns to/from tree values.
std::unique_ptr< ROOT::Detail::RDF::RColumnReaderBase > GetColumnReaders(unsigned int, std::string_view, const std::type_info &) final
If the other GetColumnReaders overload returns an empty vector, this overload will be called instead.
void AddField(const RNTupleDescriptor &desc, std::string_view colName, DescriptorId_t fieldId, std::vector< DescriptorId_t > skeinIDs)
Provides the RDF column "colName" given the field identified by fieldID.
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
bool SetEntry(unsigned int slot, ULong64_t entry) final
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
std::vector< std::unique_ptr< ROOT::Experimental::Internal::RNTupleColumnReader > > fColumnReaderPrototypes
We prepare a column reader prototype for every column.
std::vector< std::unique_ptr< ROOT::Experimental::Detail::RPageSource > > fSources
Clones of the first source, one for each slot.
Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final
type-erased vector of pointers to pointers to column values - one per slot
void Initialize() final
Convenience method called before starting an event-loop.
std::vector< std::string > fColumnNames
void Finalize() final
Convenience method called after concluding an event-loop.
std::string GetTypeName(std::string_view colName) const final
Type of a column as a string, e.g.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
RNTupleDS(std::unique_ptr< ROOT::Experimental::Detail::RPageSource > pageSource)
bool HasColumn(std::string_view colName) const final
Checks if the dataset has a certain column.
std::vector< std::string > fColumnTypes
The on-storage meta-data of an ntuple.
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
const RFieldDescriptor & GetFieldDescriptor(DescriptorId_t fieldId) const
Representation of an RNTuple data set in a ROOT file.
std::unique_ptr< Detail::RPageSource > MakePageSource(const RNTupleReadOptions &options=RNTupleReadOptions())
Create a page source from the RNTuple object.
std::vector< void * > Record_t
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
RDataFrame FromRNTuple(std::string_view ntupleName, std::string_view fileName)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
TSeq< unsigned int > TSeqU
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...