Reads RNTuple data from storage.
The RNTupleReader provides access to data stored in the RNTuple binary format as C++ objects, using an RNTupleModel. It infers this model from the RNTuple's on-disk metadata, or uses a model imposed by the user. The latter case allows users to read into a specialized RNTuple model that covers only a subset of the fields in the RNTuple. The RNTuple model is used when reading complete entries through LoadEntry(). Individual fields can be read as well by instantiating a tree view.
#include <iostream>
std::cout <<
"myNTuple has " <<
reader->GetNEntries() <<
" entries\n";
Reads RNTuple data from storage.
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
Definition at line 72 of file RNTupleReader.hxx.
|
| ~RNTupleReader () |
|
RIterator | begin () |
|
std::unique_ptr< RNTupleReader > | Clone () |
|
std::unique_ptr< ROOT::REntry > | CreateEntry () |
|
void | EnableMetrics () |
| Enable performance measurements (decompression time, bytes read from storage, etc.)
|
|
RIterator | end () |
|
ROOT::RNTupleCollectionView | GetCollectionView (ROOT::DescriptorId_t fieldId) |
|
ROOT::RNTupleCollectionView | GetCollectionView (std::string_view fieldName) |
| Raises an exception if:
|
|
const ROOT::RNTupleDescriptor & | GetDescriptor () |
| Returns a cached copy of the page source descriptor.
|
|
template<typename T > |
ROOT::RNTupleDirectAccessView< T > | GetDirectAccessView (ROOT::DescriptorId_t fieldId) |
|
template<typename T > |
ROOT::RNTupleDirectAccessView< T > | GetDirectAccessView (std::string_view fieldName) |
|
ROOT::RNTupleGlobalRange | GetEntryRange () |
| Returns an iterator over the entry indices of the RNTuple.
|
|
const Detail::RNTupleMetrics & | GetMetrics () const |
|
const ROOT::RNTupleModel & | GetModel () |
|
ROOT::NTupleSize_t | GetNEntries () const |
|
template<typename T > |
ROOT::RNTupleView< T > | GetView (ROOT::DescriptorId_t fieldId) |
|
template<typename T > |
ROOT::RNTupleView< T > | GetView (ROOT::DescriptorId_t fieldId, std::shared_ptr< T > objPtr) |
|
template<typename T > |
ROOT::RNTupleView< T > | GetView (ROOT::DescriptorId_t fieldId, T *rawPtr) |
|
template<typename T > |
ROOT::RNTupleView< T > | GetView (std::string_view fieldName) |
| Provides access to an individual (sub)field, e.g.
|
|
template<typename T > |
ROOT::RNTupleView< T > | GetView (std::string_view fieldName, std::shared_ptr< T > objPtr) |
|
template<typename T > |
ROOT::RNTupleView< T > | GetView (std::string_view fieldName, T *rawPtr) |
|
void | LoadEntry (ROOT::NTupleSize_t index) |
| Fills the default entry of the model.
|
|
void | LoadEntry (ROOT::NTupleSize_t index, ROOT::REntry &entry) |
| Fills a user provided entry after checking that the entry has been instantiated from the RNTuple model.
|
|
void | PrintInfo (const ENTupleInfo what=ENTupleInfo::kSummary, std::ostream &output=std::cout) const |
| Prints a detailed summary of the RNTuple, including a list of fields.
|
|
void | Show (ROOT::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 ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions()) |
|
static std::unique_ptr< RNTupleReader > | Open (const ROOT::RNTupleDescriptor::RCreateModelOptions &createModelOpts, const RNTuple &ntuple, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions()) |
|
static std::unique_ptr< RNTupleReader > | Open (const ROOT::RNTupleDescriptor::RCreateModelOptions &createModelOpts, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::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 ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions()) |
| Open an RNTuple for reading.
|
|
static std::unique_ptr< RNTupleReader > | Open (std::unique_ptr< ROOT::RNTupleModel > model, const RNTuple &ntuple, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions()) |
|
static std::unique_ptr< RNTupleReader > | Open (std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions()) |
| The caller imposes a model, which must be compatible with the model found in the data on storage.
|
|
ROOT::RNTupleView< T > ROOT::Experimental::RNTupleReader::GetView |
( |
std::string_view | fieldName | ) |
|
|
inline |
Provides access to an individual (sub)field, e.g.
GetView<Particle>("particle")
, GetView<double>("particle.pt")
or GetView<std::vector<Particle>>("particles")
. It is possible to directly get the size of a collection (without reading the collection itself) using RNTupleCardinality: GetView<ROOT::RNTupleCardinality<std::uint64_t>>("particles")
.
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 285 of file RNTupleReader.hxx.
The RNTuple 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 90 of file RNTupleReader.hxx.