An RNTuple that is used to read data from storage.
An input ntuple provides data from storage as C++ objects. The ntuple model can be created from the data on storage or it can be imposed by the user. The latter case allows users to read into a specialized ntuple model that covers only a subset of the fields in the ntuple. The ntuple model is used when reading complete entries. Individual fields can be read as well by instantiating a tree view.
#include <iostream>
std::cout <<
"myNTuple has " <<
ntuple->GetNEntries() <<
" entries\n";
An RNTuple that is used to read data from storage.
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const RNTupleReadOptions &options=RNTupleReadOptions())
Open an RNTuple for reading.
Definition at line 71 of file RNTupleReader.hxx.
|
| ~RNTupleReader () |
|
RIterator | begin () |
|
std::unique_ptr< RNTupleReader > | Clone () |
|
std::unique_ptr< REntry > | CreateEntry () |
|
void | EnableMetrics () |
| Enable performance measurements (decompression time, bytes read from storage, etc.)
|
|
RIterator | end () |
|
RNTupleCollectionView | GetCollectionView (DescriptorId_t fieldId) |
|
RNTupleCollectionView | GetCollectionView (std::string_view fieldName) |
| Raises an exception if:
|
|
const RNTupleDescriptor & | GetDescriptor () |
| Returns a cached copy of the page source descriptor.
|
|
template<typename T > |
RNTupleDirectAccessView< T > | GetDirectAccessView (DescriptorId_t fieldId) |
|
template<typename T > |
RNTupleDirectAccessView< T > | GetDirectAccessView (std::string_view fieldName) |
|
RNTupleGlobalRange | GetEntryRange () |
| Returns an iterator over the entry indices of the RNTuple.
|
|
const Detail::RNTupleMetrics & | GetMetrics () const |
|
const RNTupleModel & | GetModel () |
|
NTupleSize_t | GetNEntries () const |
|
template<typename T > |
RNTupleView< T > | GetView (DescriptorId_t fieldId) |
|
template<typename T > |
RNTupleView< T > | GetView (DescriptorId_t fieldId, std::shared_ptr< T > objPtr) |
|
template<typename T > |
RNTupleView< T > | GetView (DescriptorId_t fieldId, T *rawPtr) |
|
template<typename T > |
RNTupleView< T > | GetView (std::string_view fieldName) |
| Provides access to an individual field that can contain either a scalar value or a collection, e.g.
|
|
template<typename T > |
RNTupleView< T > | GetView (std::string_view fieldName, std::shared_ptr< T > objPtr) |
|
template<typename T > |
RNTupleView< T > | GetView (std::string_view fieldName, T *rawPtr) |
|
void | LoadEntry (NTupleSize_t index) |
| Analogous to Fill(), fills the default entry of the model.
|
|
void | LoadEntry (NTupleSize_t index, REntry &entry) |
| Fills a user provided entry after checking that the entry has been instantiated from the ntuple model.
|
|
void | PrintInfo (const ENTupleInfo what=ENTupleInfo::kSummary, std::ostream &output=std::cout) const |
| Prints a detailed summary of the ntuple, including a list of fields.
|
|
void | Show (NTupleSize_t index, std::ostream &output=std::cout) |
| Shows the values of the i-th entry/row, starting with 0 for the first entry.
|
|
|
static std::unique_ptr< RNTupleReader > | Open (const RNTuple &ntuple, const RNTupleReadOptions &options=RNTupleReadOptions()) |
|
static std::unique_ptr< RNTupleReader > | Open (const RNTupleDescriptor::RCreateModelOptions &createModelOpts, const RNTuple &ntuple, const RNTupleReadOptions &options=RNTupleReadOptions()) |
|
static std::unique_ptr< RNTupleReader > | Open (const RNTupleDescriptor::RCreateModelOptions &createModelOpts, std::string_view ntupleName, std::string_view storage, const RNTupleReadOptions &options=RNTupleReadOptions()) |
| The caller imposes the way the model is reconstructed.
|
|
static std::unique_ptr< RNTupleReader > | Open (std::string_view ntupleName, std::string_view storage, const RNTupleReadOptions &options=RNTupleReadOptions()) |
| Open an RNTuple for reading.
|
|
static std::unique_ptr< RNTupleReader > | Open (std::unique_ptr< RNTupleModel > model, const RNTuple &ntuple, const RNTupleReadOptions &options=RNTupleReadOptions()) |
|
static std::unique_ptr< RNTupleReader > | Open (std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const RNTupleReadOptions &options=RNTupleReadOptions()) |
| The caller imposes a model, which must be compatible with the model found in the data on storage.
|
|
RNTupleView< T > ROOT::Experimental::RNTupleReader::GetView |
( |
std::string_view | fieldName | ) |
|
|
inline |
Provides access to an individual field that can contain either a scalar value or a collection, e.g.
GetView<double>("particles.pt") or GetView<std::vector<double>>("particle"). It can as well be the index field of a collection itself, like GetView<NTupleSize_t>("particle").
Raises an exception if there is no field with the given name.
Example: iterate over a field named "pt" of type float
#include <iostream>
std::cout << i <<
": " <<
pt(i) <<
"\n";
}
Definition at line 283 of file RNTupleReader.hxx.
std::optional<RNTupleDescriptor> ROOT::Experimental::RNTupleReader::fCachedDescriptor |
|
private |
The ntuple descriptor in the page source is protected by a read-write lock.
We don't expose that to the users of RNTupleReader::GetDescriptor(). Instead, if descriptor information is needed, we clone the descriptor. Using the descriptor's generation number, we know if the cached descriptor is stale. Retrieving descriptor data from an RNTupleReader is supposed to be for testing and information purposes, not on a hot code path.
Definition at line 89 of file RNTupleReader.hxx.