Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleReader.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleReader.hxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2024-02-20
5
6/*************************************************************************
7 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#ifndef ROOT_RNTupleReader
15#define ROOT_RNTupleReader
16
17#include <ROOT/RConfig.hxx> // for R__unlikely
18#include <ROOT/REntry.hxx>
19#include <ROOT/RError.hxx>
22#include <ROOT/RNTupleModel.hxx>
24#include <ROOT/RNTupleTypes.hxx>
25#include <ROOT/RNTupleView.hxx>
26#include <ROOT/RPageStorage.hxx>
27#include <ROOT/RSpan.hxx>
28
29#include <iostream>
30#include <iterator>
31#include <memory>
32#include <mutex>
33#include <string>
34#include <string_view>
35#include <unordered_map>
36
37namespace ROOT {
38class RNTuple;
39
40/// Listing of the different options that can be printed by RNTupleReader::GetInfo()
41enum class ENTupleInfo {
42 kSummary, // The RNTuple name, description, number of entries
43 kStorageDetails, // size on storage, page sizes, compression factor, etc.
44 kMetrics, // internals performance counters, requires that EnableMetrics() was called
45};
46
47// clang-format off
48/**
49\class ROOT::RNTupleReader
50\ingroup NTuple
51\brief Reads RNTuple data from storage
52
53The RNTupleReader provides access to data stored in the RNTuple binary format as C++ objects, using an RNTupleModel.
54It infers this model from the RNTuple's on-disk metadata, or uses a model imposed by the user.
55The latter case allows users to read into a specialized RNTuple model that covers
56only a subset of the fields in the RNTuple. The RNTuple model is used when reading complete entries through LoadEntry().
57Individual fields can be read as well by instantiating a tree view.
58
59~~~ {.cpp}
60#include <ROOT/RNTupleReader.hxx>
61#include <iostream>
62
63auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
64std::cout << "myNTuple has " << reader->GetNEntries() << " entries\n";
65~~~
66*/
67// clang-format on
69private:
70 /// Shared data structure between the reader and all the issued active entry tokens.
72 /// Points to the page source backing the associated RNTupleReader. When the reader is destructed, the
73 /// page source is reset to nullptr. At that point, operations on remaining active entry tokens become noops.
75 /// Reference counter of clusters pinned in the page source due to entries being marked as active.
76 std::unordered_map<ROOT::DescriptorId_t, std::uint64_t> fActiveClusters;
77 std::mutex fLock;
78
80 };
81
82 /// Set as the page source's scheduler for parallel page decompression if implicit multi-threading (IMT) is on.
83 /// Needs to be destructed after the page source is destructed (and thus be declared before)
84 std::unique_ptr<Internal::RPageStorage::RTaskScheduler> fUnzipTasks;
85
86 std::unique_ptr<Internal::RPageSource> fSource;
87 /// Needs to be destructed before fSource
88 std::unique_ptr<ROOT::RNTupleModel> fModel;
89 /// We use a dedicated on-demand reader for Show(). Printing data uses all the fields
90 /// from the full model even if the analysis code uses only a subset of fields. The display reader
91 /// is a clone of the original reader.
92 std::unique_ptr<RNTupleReader> fDisplayReader;
93 /// The RNTuple descriptor in the page source is protected by a read-write lock. We don't expose that to the
94 /// users of RNTupleReader::GetDescriptor(). Instead, if descriptor information is needed, we clone the
95 /// descriptor. Using the descriptor's generation number, we know if the cached descriptor is stale.
96 /// Retrieving descriptor data from an RNTupleReader is supposed to be for testing and information purposes,
97 /// not on a hot code path.
98 std::optional<ROOT::RNTupleDescriptor> fCachedDescriptor;
99 /// We know that the RNTupleReader is always reading a single RNTuple, so the number of entries is fixed.
102 /// If not nullopt, these will be used when creating the model
103 std::optional<ROOT::RNTupleDescriptor::RCreateModelOptions> fCreateModelOptions;
104 /// Initialized when the page source is connected. It is then shared between the reader instance and all
105 /// active entry tokens. When the reader destructs, it resets the page source pointer in the control block.
106 std::shared_ptr<RActiveEntriesControlBlock> fActiveEntriesControlBlock;
107
108 RNTupleReader(std::unique_ptr<ROOT::RNTupleModel> model, std::unique_ptr<Internal::RPageSource> source,
109 const ROOT::RNTupleReadOptions &options);
110 /// The model is generated from the RNTuple metadata on storage.
111 explicit RNTupleReader(std::unique_ptr<Internal::RPageSource> source, const ROOT::RNTupleReadOptions &options);
112
115 void InitPageSource(bool enableMetrics);
116
117 ROOT::DescriptorId_t RetrieveFieldId(std::string_view fieldName) const;
118
119public:
120 // Browse through the entries
121 class RIterator {
122 private:
124
125 public:
127 using iterator_category = std::input_iterator_tag;
129 using difference_type = std::ptrdiff_t;
132
133 RIterator() = default;
135 ~RIterator() = default;
136
137 iterator operator++(int) /* postfix */
138 {
139 auto r = *this;
140 fIndex++;
141 return r;
142 }
143 iterator &operator++() /* prefix */
144 {
145 ++fIndex;
146 return *this;
147 }
148 reference operator*() const { return fIndex; }
149 pointer operator->() const { return &fIndex; }
150 bool operator==(const iterator &rh) const { return fIndex == rh.fIndex; }
151 bool operator!=(const iterator &rh) const { return fIndex != rh.fIndex; }
152 };
153
154 /// An active entry token is a pledge for the data of a certain entry number not to be evicted from the
155 /// page cache or cluster cache. An active entry token is linked to a specific reader through a control block
156 /// shared by the reader and all tokens of that reader. Active entry tokens can be destructed before or after
157 /// their reader is destructed. Once the corresponding reader is destructed, changing the entry number has no
158 /// effect.
159 /// Only the RNTuple reader can create an active entry token.
161 friend class RNTupleReader;
162
163 std::shared_ptr<RActiveEntriesControlBlock> fPtrControlBlock;
165
168
169 explicit RActiveEntryToken(std::shared_ptr<RActiveEntriesControlBlock> ptrControlBlock)
171 {
172 }
173
174 public:
180
182 /// Set or replace the entry number. If the entry number is replaced, the cluster corresponding to the new
183 /// entry is pinned _before_ the cluster of the old entry number is unpinned.
184 /// SetEntryNumber() should be called before the corresponding entry is used (through LoadEntry() or views).
186 /// Release the entry number, i.e. allow the corresponding data to be evicted from caches.
187 /// Called implicitly on destruction.
188 void Reset();
189 };
190
191 /// Open an RNTuple for reading.
192 ///
193 /// Throws an RException if there is no RNTuple with the given name.
194 ///
195 /// **Example: open an RNTuple and print the number of entries**
196 /// ~~~ {.cpp}
197 /// #include <ROOT/RNTupleReader.hxx>
198 /// #include <iostream>
199 ///
200 /// auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
201 /// std::cout << "myNTuple has " << reader->GetNEntries() << " entries\n";
202 /// ~~~
203 static std::unique_ptr<RNTupleReader> Open(std::string_view ntupleName, std::string_view storage,
205 static std::unique_ptr<RNTupleReader>
207
208 /// The caller imposes a model, which must be compatible with the model found in the data on storage.
209 static std::unique_ptr<RNTupleReader> Open(std::unique_ptr<ROOT::RNTupleModel> model, std::string_view ntupleName,
210 std::string_view storage,
212 static std::unique_ptr<RNTupleReader> Open(std::unique_ptr<ROOT::RNTupleModel> model, const RNTuple &ntuple,
214
215 /// The caller imposes the way the model is reconstructed
216 static std::unique_ptr<RNTupleReader> Open(const ROOT::RNTupleDescriptor::RCreateModelOptions &createModelOpts,
217 std::string_view ntupleName, std::string_view storage,
219 static std::unique_ptr<RNTupleReader> Open(const ROOT::RNTupleDescriptor::RCreateModelOptions &createModelOpts,
220 const RNTuple &ntuple,
222 std::unique_ptr<RNTupleReader> Clone()
223 {
224 auto options = ROOT::RNTupleReadOptions{};
226 return std::unique_ptr<RNTupleReader>(new RNTupleReader(fSource->Clone(), options));
227 }
228
234
235 /// Returns the number of entries in this RNTuple.
236 /// Note that the recommended way to iterate the RNTuple is using
237 /// ~~~ {.cpp}
238 /// // RECOMMENDED way to iterate an ntuple
239 /// for (auto i : reader->GetEntryRange()) { ... }
240 /// ~~~
241 /// instead of
242 /// ~~~ {.cpp}
243 /// // DISCOURAGED way to iterate an ntuple
244 /// for (auto i = 0u; i < reader->GetNEntries(); ++i) { ... }
245 /// ~~~
246 /// The reason is that determining the number of entries, while currently cheap, may in the future be
247 /// an expensive operation.
250 std::unique_ptr<ROOT::REntry> CreateEntry();
251
252 /// Returns a cached copy of the page source descriptor. The returned pointer remains valid until the next call
253 /// to LoadEntry() or to any of the views returned from the reader.
255
256 /// Prints a detailed summary of the RNTuple, including a list of fields.
257 ///
258 /// **Example: print summary information to stdout**
259 /// ~~~ {.cpp}
260 /// #include <ROOT/RNTupleReader.hxx>
261 /// #include <iostream>
262 ///
263 /// auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
264 /// reader->PrintInfo();
265 /// // or, equivalently:
266 /// reader->PrintInfo(ROOT::ENTupleInfo::kSummary, std::cout);
267 /// ~~~
268 /// **Example: print detailed column storage data to stderr**
269 /// ~~~ {.cpp}
270 /// #include <ROOT/RNTupleReader.hxx>
271 /// #include <iostream>
272 ///
273 /// auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
274 /// reader->PrintInfo(ROOT::ENTupleInfo::kStorageDetails, std::cerr);
275 /// ~~~
276 ///
277 /// For use of ENTupleInfo::kMetrics, see #EnableMetrics.
278 void PrintInfo(const ENTupleInfo what = ENTupleInfo::kSummary, std::ostream &output = std::cout) const;
279
280 /// Shows the values of the i-th entry/row, starting with 0 for the first entry. By default,
281 /// prints the output in JSON format.
282 /// Uses the visitor pattern to traverse through each field of the given entry.
283 void Show(ROOT::NTupleSize_t index, std::ostream &output = std::cout);
284
285 /// Fills the default entry of the model.
286 /// Raises an exception when `index` is greater than the number of entries present in the RNTuple
288 {
289 // TODO(jblomer): can be templated depending on the factory method / constructor
290 if (R__unlikely(!fModel)) {
291 // Will create the fModel.
292 GetModel();
293 }
294 LoadEntry(index, fModel->GetDefaultEntry());
295 }
296 /// Fills a user provided entry after checking that the entry has been instantiated from the RNTuple model
298 {
299 if (R__unlikely(entry.GetModelId() != fModel->GetModelId()))
300 throw RException(R__FAIL("mismatch between entry and model"));
301
302 entry.Read(index);
303 }
304
305 /// Create a new active entry token, which will not be bound to any entry number initially.
306 /// In order to bind the new token, its `SetEntryNumber()` must be called subsequently.
308
309 /// Returns an iterator over the entry indices of the RNTuple.
310 ///
311 /// **Example: iterate over all entries and print each entry in JSON format**
312 /// ~~~ {.cpp}
313 /// #include <ROOT/RNTupleReader.hxx>
314 /// #include <iostream>
315 ///
316 /// auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
317 /// for (auto i : ntuple->GetEntryRange()) {
318 /// reader->Show(i);
319 /// }
320 /// ~~~
322
323 /// Provides access to an individual (sub)field,
324 /// e.g. `GetView<Particle>("particle")`, `GetView<double>("particle.pt")` or
325 /// `GetView<std::vector<Particle>>("particles")`. It is possible to directly get the size of a collection (without
326 /// reading the collection itself) using RNTupleCardinality:
327 /// `GetView<ROOT::RNTupleCardinality<std::uint64_t>>("particles")`.
328 ///
329 /// Raises an exception if there is no field with the given name.
330 ///
331 /// **Example: iterate over a field named "pt" of type `float`**
332 /// ~~~ {.cpp}
333 /// #include <ROOT/RNTupleReader.hxx>
334 /// #include <iostream>
335 ///
336 /// auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
337 /// auto pt = reader->GetView<float>("pt");
338 ///
339 /// for (auto i : reader->GetEntryRange()) {
340 /// std::cout << i << ": " << pt(i) << "\n";
341 /// }
342 /// ~~~
343 ///
344 /// **Note**: if `T = void`, type checks are disabled. This is not really useful for this overload because
345 /// RNTupleView<void> does not give access to the pointer. If required, it is possible to provide an `objPtr` of a
346 /// dynamic type, for example via GetView(std::string_view, void *, std::string_view).
347 template <typename T>
349 {
351 }
352
353 /// Provides access to an individual (sub)field, reading its values into `objPtr`.
354 ///
355 /// Raises an exception if there is no field with the given name.
356 ///
357 /// **Example: iterate over a field named "pt" of type `float`**
358 /// ~~~ {.cpp}
359 /// #include <ROOT/RNTupleReader.hxx>
360 /// #include <iostream>
361 ///
362 /// auto reader = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
363 /// auto pt = std::make_shared<float>();
364 /// auto ptView = reader->GetView("pt", pt);
365 ///
366 /// for (auto i : reader->GetEntryRange()) {
367 /// ptView(i);
368 /// std::cout << i << ": " << *pt << "\n";
369 /// }
370 /// ~~~
371 ///
372 /// **Note**: if `T = void`, type checks are disabled. It is the caller's responsibility to match the field and
373 /// object types. It is strongly recommended to use an overload that allows passing the `typeName`, such as
374 /// GetView(std::string_view, void *, std::string_view). This allows type checks with the on-disk metadata and
375 /// enables automatic schema evolution and conversion rules.
376 template <typename T>
377 ROOT::RNTupleView<T> GetView(std::string_view fieldName, std::shared_ptr<T> objPtr)
378 {
380 }
381
382 /// Provides access to an individual (sub)field, reading its values into `rawPtr`.
383 ///
384 /// \sa GetView(std::string_view, std::shared_ptr<T>)
385 template <typename T>
387 {
389 }
390
391 /// Provides access to an individual (sub)field, reading its values into `rawPtr` as the type provided by `typeName`.
392 ///
393 /// \sa GetView(std::string_view, std::shared_ptr<T>)
394 ROOT::RNTupleView<void> GetView(std::string_view fieldName, void *rawPtr, std::string_view typeName)
395 {
396 return GetView(RetrieveFieldId(fieldName), rawPtr, typeName);
397 }
398
399 /// Provides access to an individual (sub)field, reading its values into `rawPtr` as the type provided by `ti`.
400 ///
401 /// \sa GetView(std::string_view, std::shared_ptr<T>)
402 ROOT::RNTupleView<void> GetView(std::string_view fieldName, void *rawPtr, const std::type_info &ti)
403 {
405 }
406
407 /// Provides access to an individual (sub)field from its on-disk ID.
408 ///
409 /// \sa GetView(std::string_view)
410 template <typename T>
417
418 /// Provides access to an individual (sub)field from its on-disk ID, reading its values into `objPtr`.
419 ///
420 /// \sa GetView(std::string_view, std::shared_ptr<T>)
421 template <typename T>
428
429 /// Provides access to an individual (sub)field from its on-disk ID, reading its values into `rawPtr`.
430 ///
431 /// \sa GetView(std::string_view, std::shared_ptr<T>)
432 template <typename T>
439
440 /// Provides access to an individual (sub)field from its on-disk ID, reading its values into `rawPtr` as the type
441 /// provided by `typeName`.
442 ///
443 /// \sa GetView(std::string_view, std::shared_ptr<T>)
445 {
448 return RNTupleView<void>(std::move(field), range, rawPtr);
449 }
450
451 /// Provides access to an individual (sub)field from its on-disk ID, reading its values into `objPtr` as the type
452 /// provided by `ti`.
453 ///
454 /// \sa GetView(std::string_view, std::shared_ptr<T>)
459
460 /// Provides direct access to the I/O buffers of a **mappable** (sub)field.
461 ///
462 /// Raises an exception if there is no field with the given name.
463 /// Attempting to access the values of a direct-access view for non-mappable fields will yield compilation errors.
464 ///
465 /// \sa GetView(std::string_view)
466 template <typename T>
471
472 /// Provides direct access to the I/O buffers of a **mappable** (sub)field from its on-disk ID.
473 ///
474 /// \sa GetDirectAccessView(std::string_view)
475 template <typename T>
482
483 /// Provides access to a collection field, that can itself generate new RNTupleViews for its nested fields.
484 ///
485 /// Raises an exception if:
486 /// * there is no field with the given name or,
487 /// * the field is not a collection
488 ///
489 /// \sa GetView(std::string_view)
491 {
492 auto fieldId = fSource->GetSharedDescriptorGuard()->FindFieldId(fieldName);
494 throw RException(R__FAIL("no field named '" + std::string(fieldName) + "' in RNTuple '" +
495 fSource->GetSharedDescriptorGuard()->GetName() + "'"));
496 }
498 }
499
500 /// Provides access to a collection field from its on-disk ID, that can itself generate new RNTupleViews for its
501 /// nested fields.
502 ///
503 /// \sa GetCollectionView(std::string_view)
508
509 RIterator begin() { return RIterator(0); }
511
512 /// Enable performance measurements (decompression time, bytes read from storage, etc.)
513 ///
514 /// **Example: inspect the reader metrics after loading every entry**
515 /// ~~~ {.cpp}
516 /// #include <ROOT/RNTupleReader.hxx>
517 /// #include <iostream>
518 ///
519 /// auto ntuple = ROOT::RNTupleReader::Open("myNTuple", "some/file.root");
520 /// // metrics must be turned on beforehand
521 /// reader->EnableMetrics();
522 ///
523 /// for (auto i : ntuple->GetEntryRange()) {
524 /// reader->LoadEntry(i);
525 /// }
526 /// reader->PrintInfo(ROOT::ENTupleInfo::kMetrics);
527 /// ~~~
530}; // class RNTupleReader
531
532} // namespace ROOT
533
534#endif // ROOT_RNTupleReader
#define R__unlikely(expr)
Definition RConfig.hxx:596
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:300
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
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
A collection of Counter objects with a name, a unit, and a description.
Abstract interface to read data from an ntuple.
The REntry is a collection of values in an RNTuple corresponding to a complete row in the data set.
Definition REntry.hxx:47
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
A view for a collection, that can itself generate new ntuple views for its nested fields.
static RNTupleCollectionView Create(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource *source)
The on-storage metadata of an RNTuple.
A view variant that provides direct access to the I/O buffers.
static ROOT::RField< T > CreateField(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource &pageSource)
Used to loop over indexes (entries or collections) between start and end.
The RNTupleModel encapulates the schema of an RNTuple.
Common user-tunable settings for reading RNTuples.
An active entry token is a pledge for the data of a certain entry number not to be evicted from the p...
std::shared_ptr< RActiveEntriesControlBlock > fPtrControlBlock
RActiveEntryToken & operator=(const RActiveEntryToken &other)
void ActivateEntry(NTupleSize_t entryNumber)
void Reset()
Release the entry number, i.e.
RActiveEntryToken(std::shared_ptr< RActiveEntriesControlBlock > ptrControlBlock)
void DeactivateEntry(NTupleSize_t entryNumber)
void SetEntryNumber(NTupleSize_t entryNumber)
Set or replace the entry number.
bool operator!=(const iterator &rh) const
RIterator(ROOT::NTupleSize_t index)
const ROOT::NTupleSize_t * pointer
std::input_iterator_tag iterator_category
const ROOT::NTupleSize_t & reference
bool operator==(const iterator &rh) const
Reads RNTuple data from storage.
ROOT::RNTupleGlobalRange GetEntryRange()
Returns an iterator over the entry indices of the RNTuple.
ROOT::RNTupleView< T > GetView(ROOT::DescriptorId_t fieldId, T *rawPtr)
Provides access to an individual (sub)field from its on-disk ID, reading its values into rawPtr.
ROOT::RNTupleView< T > GetView(std::string_view fieldName, std::shared_ptr< T > objPtr)
Provides access to an individual (sub)field, reading its values into objPtr.
std::unique_ptr< RNTupleReader > fDisplayReader
We use a dedicated on-demand reader for Show().
ROOT::RNTupleView< T > GetView(ROOT::DescriptorId_t fieldId)
Provides access to an individual (sub)field from its on-disk ID.
std::unique_ptr< ROOT::REntry > CreateEntry()
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.
RNTupleReader & operator=(const ROOT::RNTupleReader &)=delete
void InitPageSource(bool enableMetrics)
ROOT::RNTupleDirectAccessView< T > GetDirectAccessView(ROOT::DescriptorId_t fieldId)
Provides direct access to the I/O buffers of a mappable (sub)field from its on-disk ID.
std::unique_ptr< Internal::RPageStorage::RTaskScheduler > fUnzipTasks
Set as the page source's scheduler for parallel page decompression if implicit multi-threading (IMT) ...
RNTupleReader(const ROOT::RNTupleReader &)=delete
ROOT::RNTupleView< T > GetView(std::string_view fieldName)
Provides access to an individual (sub)field, e.g.
ROOT::NTupleSize_t fNEntries
We know that the RNTupleReader is always reading a single RNTuple, so the number of entries is fixed.
std::unique_ptr< ROOT::RNTupleModel > fModel
Needs to be destructed before fSource.
const Experimental::Detail::RNTupleMetrics & GetMetrics() const
ROOT::RNTupleCollectionView GetCollectionView(std::string_view fieldName)
Provides access to a collection field, that can itself generate new RNTupleViews for its nested field...
ROOT::RNTupleDirectAccessView< T > GetDirectAccessView(std::string_view fieldName)
Provides direct access to the I/O buffers of a mappable (sub)field.
const ROOT::RNTupleDescriptor & GetDescriptor()
Returns a cached copy of the page source descriptor.
ROOT::RNTupleView< void > GetView(std::string_view fieldName, void *rawPtr, std::string_view typeName)
Provides access to an individual (sub)field, reading its values into rawPtr as the type provided by t...
std::optional< ROOT::RNTupleDescriptor::RCreateModelOptions > fCreateModelOptions
If not nullopt, these will be used when creating the 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.
std::unique_ptr< Internal::RPageSource > fSource
RNTupleReader(std::unique_ptr< ROOT::RNTupleModel > model, std::unique_ptr< Internal::RPageSource > source, const ROOT::RNTupleReadOptions &options)
const ROOT::RNTupleModel & GetModel()
ROOT::RNTupleView< void > GetView(ROOT::DescriptorId_t fieldId, void *rawPtr, std::string_view typeName)
Provides access to an individual (sub)field from its on-disk ID, reading its values into rawPtr as th...
std::optional< ROOT::RNTupleDescriptor > fCachedDescriptor
The RNTuple descriptor in the page source is protected by a read-write lock.
RNTupleReader(ROOT::RNTupleReader &&)=delete
ROOT::RNTupleCollectionView GetCollectionView(ROOT::DescriptorId_t fieldId)
Provides access to a collection field from its on-disk ID, that can itself generate new RNTupleViews ...
std::unique_ptr< RNTupleReader > Clone()
RNTupleReader & operator=(ROOT::RNTupleReader &&)=delete
std::shared_ptr< RActiveEntriesControlBlock > fActiveEntriesControlBlock
Initialized when the page source is connected.
void ConnectModel(ROOT::RNTupleModel &model, bool allowFieldSubstitutions)
ROOT::NTupleSize_t GetNEntries() const
Returns the number of entries in this RNTuple.
ROOT::RNTupleView< void > GetView(std::string_view fieldName, void *rawPtr, const std::type_info &ti)
Provides access to an individual (sub)field, reading its values into rawPtr as the type provided by t...
ROOT::DescriptorId_t RetrieveFieldId(std::string_view fieldName) const
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.
ROOT::RNTupleView< T > GetView(std::string_view fieldName, T *rawPtr)
Provides access to an individual (sub)field, reading its values into rawPtr.
RActiveEntryToken CreateActiveEntryToken()
Create a new active entry token, which will not be bound to any entry number initially.
RNTupleReader * GetDisplayReader()
Experimental::Detail::RNTupleMetrics fMetrics
void EnableMetrics()
Enable performance measurements (decompression time, bytes read from storage, etc....
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 mode...
ROOT::RNTupleView< void > GetView(ROOT::DescriptorId_t fieldId, void *rawPtr, const std::type_info &ti)
Provides access to an individual (sub)field from its on-disk ID, reading its values into objPtr as th...
ROOT::RNTupleView< T > GetView(ROOT::DescriptorId_t fieldId, std::shared_ptr< T > objPtr)
Provides access to an individual (sub)field from its on-disk ID, reading its values into objPtr.
void LoadEntry(ROOT::NTupleSize_t index)
Fills the default entry of the model.
static std::unique_ptr< ROOT::RFieldBase > CreateField(ROOT::DescriptorId_t fieldId, Internal::RPageSource &pageSource, std::string_view typeName="")
An RNTupleView for a known type.
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:67
ROOT::RNTupleGlobalRange GetFieldRange(const ROOT::RFieldBase &field, const ROOT::Internal::RPageSource &pageSource)
Helper to get the iteration space of the given field that needs to be connected to the given page sou...
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
ENTupleInfo
Listing of the different options that can be printed by RNTupleReader::GetInfo()
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
static const char * what
Definition stlLoader.cc:5
Shared data structure between the reader and all the issued active entry tokens.
RActiveEntriesControlBlock(Internal::RPageSource *pageSource)
Internal::RPageSource * fPageSource
Points to the page source backing the associated RNTupleReader.
std::unordered_map< ROOT::DescriptorId_t, std::uint64_t > fActiveClusters
Reference counter of clusters pinned in the page source due to entries being marked as active.
static void output()