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.
Definition at line 71 of file RNTupleReader.hxx.
Classes | |
class | RIterator |
Public Member Functions | |
~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 (ROOT::DescriptorId_t fieldId) |
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 > | |
RNTupleDirectAccessView< T > | GetDirectAccessView (ROOT::DescriptorId_t fieldId) |
template<typename T > | |
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 RNTupleModel & | GetModel () |
ROOT::NTupleSize_t | GetNEntries () const |
template<typename T > | |
RNTupleView< T > | GetView (ROOT::DescriptorId_t fieldId) |
template<typename T > | |
RNTupleView< T > | GetView (ROOT::DescriptorId_t fieldId, std::shared_ptr< T > objPtr) |
template<typename T > | |
RNTupleView< T > | GetView (ROOT::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 (ROOT::NTupleSize_t index) |
Analogous to Fill(), fills the default entry of the model. | |
void | LoadEntry (ROOT::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 (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. | |
Private Member Functions | |
RNTupleReader (std::unique_ptr< Internal::RPageSource > source, const ROOT::RNTupleReadOptions &options) | |
The model is generated from the ntuple metadata on storage. | |
RNTupleReader (std::unique_ptr< RNTupleModel > model, std::unique_ptr< Internal::RPageSource > source, const ROOT::RNTupleReadOptions &options) | |
void | ConnectModel (RNTupleModel &model) |
RNTupleReader * | GetDisplayReader () |
void | InitPageSource (bool enableMetrics) |
ROOT::DescriptorId_t | RetrieveFieldId (std::string_view fieldName) const |
Private Attributes | |
std::optional< ROOT::RNTupleDescriptor > | fCachedDescriptor |
The ntuple descriptor in the page source is protected by a read-write lock. | |
std::optional< ROOT::RNTupleDescriptor::RCreateModelOptions > | fCreateModelOptions |
If not nullopt, these will used when creating the model. | |
std::unique_ptr< RNTupleReader > | fDisplayReader |
We use a dedicated on-demand reader for Show() and Scan(). | |
Detail::RNTupleMetrics | fMetrics |
std::unique_ptr< RNTupleModel > | fModel |
Needs to be destructed before fSource. | |
std::unique_ptr< Internal::RPageSource > | fSource |
std::unique_ptr< Internal::RPageStorage::RTaskScheduler > | fUnzipTasks |
Set as the page source's scheduler for parallel page decompression if IMT is on Needs to be destructed after the pages source is destructed (an thus be declared before) | |
#include <ROOT/RNTupleReader.hxx>
|
private |
Definition at line 60 of file RNTupleReader.cxx.
|
explicitprivate |
The model is generated from the ntuple metadata on storage.
Definition at line 75 of file RNTupleReader.cxx.
|
default |
|
inline |
Definition at line 356 of file RNTupleReader.hxx.
|
inline |
Definition at line 173 of file RNTupleReader.hxx.
|
private |
Definition at line 27 of file RNTupleReader.cxx.
std::unique_ptr< ROOT::Experimental::REntry > ROOT::Experimental::RNTupleReader::CreateEntry | ( | ) |
Definition at line 146 of file RNTupleReader.cxx.
|
inline |
Enable performance measurements (decompression time, bytes read from storage, etc.)
Example: inspect the reader metrics after loading every entry
Definition at line 378 of file RNTupleReader.hxx.
|
inline |
Definition at line 357 of file RNTupleReader.hxx.
|
inline |
Definition at line 351 of file RNTupleReader.hxx.
|
inline |
Raises an exception if:
Definition at line 341 of file RNTupleReader.hxx.
const ROOT::RNTupleDescriptor & ROOT::Experimental::RNTupleReader::GetDescriptor | ( | ) |
Returns a cached copy of the page source descriptor.
The returned pointer remains valid until the next call to LoadEntry or to any of the views returned from the reader.
Definition at line 251 of file RNTupleReader.cxx.
|
inline |
Definition at line 331 of file RNTupleReader.hxx.
|
inline |
Definition at line 325 of file RNTupleReader.hxx.
|
private |
Definition at line 222 of file RNTupleReader.cxx.
|
inline |
Returns an iterator over the entry indices of the RNTuple.
Example: iterate over all entries and print each entry in JSON format
Definition at line 260 of file RNTupleReader.hxx.
|
inline |
Definition at line 379 of file RNTupleReader.hxx.
const ROOT::Experimental::RNTupleModel & ROOT::Experimental::RNTupleReader::GetModel | ( | ) |
Definition at line 136 of file RNTupleReader.cxx.
|
inline |
Definition at line 181 of file RNTupleReader.hxx.
|
inline |
Definition at line 301 of file RNTupleReader.hxx.
|
inline |
Definition at line 309 of file RNTupleReader.hxx.
|
inline |
Definition at line 317 of file RNTupleReader.hxx.
|
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<ROOT::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
Definition at line 283 of file RNTupleReader.hxx.
|
inline |
Definition at line 289 of file RNTupleReader.hxx.
|
inline |
Definition at line 295 of file RNTupleReader.hxx.
|
private |
Definition at line 45 of file RNTupleReader.cxx.
|
inline |
Analogous to Fill(), fills the default entry of the model.
Returns false at the end of the ntuple. On I/O errors, raises an exception.
Definition at line 226 of file RNTupleReader.hxx.
|
inline |
Fills a user provided entry after checking that the entry has been instantiated from the ntuple model.
Definition at line 237 of file RNTupleReader.hxx.
|
static |
Definition at line 101 of file RNTupleReader.cxx.
|
static |
Definition at line 127 of file RNTupleReader.cxx.
|
static |
The caller imposes the way the model is reconstructed.
Definition at line 116 of file RNTupleReader.cxx.
|
static |
Open an RNTuple for reading.
Throws an RException if there is no RNTuple with the given name.
Example: open an RNTuple and print the number of entries
Definition at line 93 of file RNTupleReader.cxx.
|
static |
Definition at line 108 of file RNTupleReader.cxx.
|
static |
The caller imposes a model, which must be compatible with the model found in the data on storage.
Definition at line 85 of file RNTupleReader.cxx.
void ROOT::Experimental::RNTupleReader::PrintInfo | ( | const ENTupleInfo | what = ENTupleInfo::kSummary, |
std::ostream & | output = std::cout ) const |
Prints a detailed summary of the ntuple, including a list of fields.
Example: print summary information to stdout
Example: print detailed column storage data to stderr
For use of ENTupleInfo::kMetrics, see EnableMetrics.
Definition at line 151 of file RNTupleReader.cxx.
|
private |
Definition at line 259 of file RNTupleReader.cxx.
void ROOT::Experimental::RNTupleReader::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.
By default, prints the output in JSON format. Uses the visitor pattern to traverse through each field of the given entry.
Definition at line 229 of file RNTupleReader.cxx.
|
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.
|
private |
If not nullopt, these will used when creating the model.
Definition at line 92 of file RNTupleReader.hxx.
|
private |
We use a dedicated on-demand reader for Show() and Scan().
Printing data uses all the fields from the full model even if the analysis code uses only a subset of fields. The display reader is a clone of the original reader.
Definition at line 83 of file RNTupleReader.hxx.
|
private |
Definition at line 90 of file RNTupleReader.hxx.
|
private |
Needs to be destructed before fSource.
Definition at line 79 of file RNTupleReader.hxx.
|
private |
Definition at line 77 of file RNTupleReader.hxx.
|
private |
Set as the page source's scheduler for parallel page decompression if IMT is on Needs to be destructed after the pages source is destructed (an thus be declared before)
Definition at line 75 of file RNTupleReader.hxx.