Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTuple.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTuple.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-04
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RNTuple
17#define ROOT7_RNTuple
18
19#include <ROOT/RConfig.hxx> // for R__unlikely
20#include <ROOT/RError.hxx>
21#include <ROOT/RMiniFile.hxx>
23#include <ROOT/RNTupleModel.hxx>
25#include <ROOT/RNTupleUtil.hxx>
26#include <ROOT/RNTupleView.hxx>
27#include <ROOT/RPageStorage.hxx>
28#include <ROOT/RSpan.hxx>
29#include <memory>
30#include <string_view>
31
32#include <TClassRef.h>
33
34#include <iterator>
35#include <memory>
36#include <sstream>
37#include <utility>
38
39class TFile;
40
41namespace ROOT {
42namespace Experimental {
43
44class REntry;
45class RNTuple;
46class RNTupleModel;
47
48namespace Detail {
49class RPageSink;
50class RPageSource;
51}
52
53namespace Internal {
54struct RNTupleTester; // friend of RNTuple
55}
56
57/**
58 * Listing of the different options that can be printed by RNTupleReader::GetInfo()
59 */
60enum class ENTupleInfo {
61 kSummary, // The ntuple name, description, number of entries
62 kStorageDetails, // size on storage, page sizes, compression factor, etc.
63 kMetrics, // internals performance counters, requires that EnableMetrics() was called
64};
65
66#ifdef R__USE_IMT
67class TTaskGroup;
69private:
70 std::unique_ptr<TTaskGroup> fTaskGroup;
71public:
73 ~RNTupleImtTaskScheduler() override = default;
74 void Reset() final;
75 void AddTask(const std::function<void(void)> &taskFunc) final;
76 void Wait() final;
77};
78#endif
79
80// clang-format off
81/**
82\class ROOT::Experimental::RNTupleReader
83\ingroup NTuple
84\brief An RNTuple that is used to read data from storage
85
86An input ntuple provides data from storage as C++ objects. The ntuple model can be created from the data on storage
87or it can be imposed by the user. The latter case allows users to read into a specialized ntuple model that covers
88only a subset of the fields in the ntuple. The ntuple model is used when reading complete entries.
89Individual fields can be read as well by instantiating a tree view.
90
91~~~ {.cpp}
92#include <ROOT/RNTuple.hxx>
93using ROOT::Experimental::RNTupleReader;
94
95#include <iostream>
96
97auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
98std::cout << "myNTuple has " << ntuple->GetNEntries() << " entries\n";
99~~~
100*/
101// clang-format on
103private:
104 /// Set as the page source's scheduler for parallel page decompression if IMT is on
105 /// Needs to be destructed after the pages source is destructed (an thus be declared before)
106 std::unique_ptr<Detail::RPageStorage::RTaskScheduler> fUnzipTasks;
107
108 std::unique_ptr<Detail::RPageSource> fSource;
109 /// Needs to be destructed before fSource
110 std::unique_ptr<RNTupleModel> fModel;
111 /// We use a dedicated on-demand reader for Show() and Scan(). Printing data uses all the fields
112 /// from the full model even if the analysis code uses only a subset of fields. The display reader
113 /// is a clone of the original reader.
114 std::unique_ptr<RNTupleReader> fDisplayReader;
115 /// The ntuple descriptor in the page source is protected by a read-write lock. We don't expose that to the
116 /// users of RNTupleReader::GetDescriptor(). Instead, if descriptor information is needed, we clone the
117 /// descriptor. Using the descriptor's generation number, we know if the cached descriptor is stale.
118 /// Retrieving descriptor data from an RNTupleReader is supposed to be for testing and information purposes,
119 /// not on a hot code path.
120 std::unique_ptr<RNTupleDescriptor> fCachedDescriptor;
122
123 void ConnectModel(const RNTupleModel &model);
124 RNTupleReader *GetDisplayReader();
125 void InitPageSource();
126
127public:
128 // Browse through the entries
129 class RIterator {
130 private:
132 public:
134 using iterator_category = std::forward_iterator_tag;
139
140 RIterator() = default;
141 explicit RIterator(NTupleSize_t index) : fIndex(index) {}
142 ~RIterator() = default;
143
144 iterator operator++(int) /* postfix */ { auto r = *this; fIndex++; return r; }
145 iterator& operator++() /* prefix */ { ++fIndex; return *this; }
146 reference operator* () { return fIndex; }
147 pointer operator->() { return &fIndex; }
148 bool operator==(const iterator& rh) const { return fIndex == rh.fIndex; }
149 bool operator!=(const iterator& rh) const { return fIndex != rh.fIndex; }
150 };
151
152 /// Used to specify the underlying RNTuples in OpenFriends()
153 struct ROpenSpec {
154 std::string fNTupleName;
155 std::string fStorage;
157
158 ROpenSpec() = default;
159 ROpenSpec(std::string_view n, std::string_view s) : fNTupleName(n), fStorage(s) {}
160 };
161
162 /// Throws an exception if the model is null.
163 static std::unique_ptr<RNTupleReader> Open(std::unique_ptr<RNTupleModel> model,
164 std::string_view ntupleName,
165 std::string_view storage,
166 const RNTupleReadOptions &options = RNTupleReadOptions());
167 /// Open an RNTuple for reading.
168 ///
169 /// Throws an RException if there is no RNTuple with the given name.
170 ///
171 /// **Example: open an RNTuple and print the number of entries**
172 /// ~~~ {.cpp}
173 /// #include <ROOT/RNTuple.hxx>
174 /// using ROOT::Experimental::RNTupleReader;
175 ///
176 /// #include <iostream>
177 ///
178 /// auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
179 /// std::cout << "myNTuple has " << ntuple->GetNEntries() << " entries\n";
180 /// ~~~
181 static std::unique_ptr<RNTupleReader> Open(std::string_view ntupleName,
182 std::string_view storage,
183 const RNTupleReadOptions &options = RNTupleReadOptions());
184 static std::unique_ptr<RNTupleReader>
185 Open(RNTuple *ntuple, const RNTupleReadOptions &options = RNTupleReadOptions());
186 /// Open RNTuples as one virtual, horizontally combined ntuple. The underlying RNTuples must
187 /// have an identical number of entries. Fields in the combined RNTuple are named with the ntuple name
188 /// as a prefix, e.g. myNTuple1.px and myNTuple2.pt (see tutorial ntpl006_friends)
189 static std::unique_ptr<RNTupleReader> OpenFriends(std::span<ROpenSpec> ntuples);
190
191 /// The user imposes an ntuple model, which must be compatible with the model found in the data on
192 /// storage.
193 ///
194 /// Throws an exception if the model or the source is null.
195 RNTupleReader(std::unique_ptr<RNTupleModel> model, std::unique_ptr<Detail::RPageSource> source);
196 /// The model is generated from the ntuple metadata on storage
197 ///
198 /// Throws an exception if the source is null.
199 explicit RNTupleReader(std::unique_ptr<Detail::RPageSource> source);
200 std::unique_ptr<RNTupleReader> Clone() { return std::make_unique<RNTupleReader>(fSource->Clone()); }
202
203 RNTupleModel *GetModel();
204 NTupleSize_t GetNEntries() const { return fSource->GetNEntries(); }
205
206 /// Returns a cached copy of the page source descriptor. The returned pointer remains valid until the next call
207 /// to LoadEntry or to any of the views returned from the reader.
208 const RNTupleDescriptor *GetDescriptor();
209
210 /// Prints a detailed summary of the ntuple, including a list of fields.
211 ///
212 /// **Example: print summary information to stdout**
213 /// ~~~ {.cpp}
214 /// #include <ROOT/RNTuple.hxx>
215 /// using ROOT::Experimental::ENTupleInfo;
216 /// using ROOT::Experimental::RNTupleReader;
217 ///
218 /// #include <iostream>
219 ///
220 /// auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
221 /// ntuple->PrintInfo();
222 /// // or, equivalently:
223 /// ntuple->PrintInfo(ENTupleInfo::kSummary, std::cout);
224 /// ~~~
225 /// **Example: print detailed column storage data to stderr**
226 /// ~~~ {.cpp}
227 /// #include <ROOT/RNTuple.hxx>
228 /// using ROOT::Experimental::ENTupleInfo;
229 /// using ROOT::Experimental::RNTupleReader;
230 ///
231 /// #include <iostream>
232 ///
233 /// auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
234 /// ntuple->PrintInfo(ENTupleInfo::kStorageDetails, std::cerr);
235 /// ~~~
236 ///
237 /// For use of ENTupleInfo::kMetrics, see #EnableMetrics.
238 void PrintInfo(const ENTupleInfo what = ENTupleInfo::kSummary, std::ostream &output = std::cout);
239
240 /// Shows the values of the i-th entry/row, starting with 0 for the first entry. By default,
241 /// prints the output in JSON format.
242 /// Uses the visitor pattern to traverse through each field of the given entry.
243 void Show(NTupleSize_t index, std::ostream &output = std::cout);
244
245 /// Analogous to Fill(), fills the default entry of the model. Returns false at the end of the ntuple.
246 /// On I/O errors, raises an exception.
248 // TODO(jblomer): can be templated depending on the factory method / constructor
249 if (R__unlikely(!fModel)) {
250 fModel = fSource->GetSharedDescriptorGuard()->GenerateModel();
251 ConnectModel(*fModel);
252 }
253 LoadEntry(index, *fModel->GetDefaultEntry());
254 }
255 /// Fills a user provided entry after checking that the entry has been instantiated from the ntuple model
257 for (auto& value : entry) {
258 value.Read(index);
259 }
260 }
261
262 /// Returns an iterator over the entry indices of the RNTuple.
263 ///
264 /// **Example: iterate over all entries and print each entry in JSON format**
265 /// ~~~ {.cpp}
266 /// #include <ROOT/RNTuple.hxx>
267 /// using ROOT::Experimental::ENTupleShowFormat;
268 /// using ROOT::Experimental::RNTupleReader;
269 ///
270 /// #include <iostream>
271 ///
272 /// auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
273 /// for (auto i : ntuple->GetEntryRange()) {
274 /// ntuple->Show(i);
275 /// }
276 /// ~~~
278
279 /// Provides access to an individual field that can contain either a scalar value or a collection, e.g.
280 /// GetView<double>("particles.pt") or GetView<std::vector<double>>("particle"). It can as well be the index
281 /// field of a collection itself, like GetView<NTupleSize_t>("particle").
282 ///
283 /// Raises an exception if there is no field with the given name.
284 ///
285 /// **Example: iterate over a field named "pt" of type `float`**
286 /// ~~~ {.cpp}
287 /// #include <ROOT/RNTuple.hxx>
288 /// using ROOT::Experimental::RNTupleReader;
289 ///
290 /// #include <iostream>
291 ///
292 /// auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
293 /// auto pt = ntuple->GetView<float>("pt");
294 ///
295 /// for (auto i : ntuple->GetEntryRange()) {
296 /// std::cout << i << ": " << pt(i) << "\n";
297 /// }
298 /// ~~~
299 template <typename T>
300 RNTupleView<T> GetView(std::string_view fieldName) {
301 auto fieldId = fSource->GetSharedDescriptorGuard()->FindFieldId(fieldName);
302 if (fieldId == kInvalidDescriptorId) {
303 throw RException(R__FAIL("no field named '" + std::string(fieldName) + "' in RNTuple '" +
304 fSource->GetSharedDescriptorGuard()->GetName() + "'"));
305 }
306 return RNTupleView<T>(fieldId, fSource.get());
307 }
308
309 /// Raises an exception if:
310 /// * there is no field with the given name or,
311 /// * the field is not a collection
312 RNTupleViewCollection GetViewCollection(std::string_view fieldName) {
313 auto fieldId = fSource->GetSharedDescriptorGuard()->FindFieldId(fieldName);
314 if (fieldId == kInvalidDescriptorId) {
315 throw RException(R__FAIL("no field named '" + std::string(fieldName) + "' in RNTuple '" +
316 fSource->GetSharedDescriptorGuard()->GetName() + "'"));
317 }
318 return RNTupleViewCollection(fieldId, fSource.get());
319 }
320
321 RIterator begin() { return RIterator(0); }
322 RIterator end() { return RIterator(GetNEntries()); }
323
324 /// Enable performance measurements (decompression time, bytes read from storage, etc.)
325 ///
326 /// **Example: inspect the reader metrics after loading every entry**
327 /// ~~~ {.cpp}
328 /// #include <ROOT/RNTuple.hxx>
329 /// using ROOT::Experimental::ENTupleInfo;
330 /// using ROOT::Experimental::RNTupleReader;
331 ///
332 /// #include <iostream>
333 ///
334 /// auto ntuple = RNTupleReader::Open("myNTuple", "some/file.root");
335 /// // metrics must be turned on beforehand
336 /// ntuple->EnableMetrics();
337 ///
338 /// for (auto i : ntuple->GetEntryRange()) {
339 /// ntuple->LoadEntry(i);
340 /// }
341 /// ntuple->PrintInfo(ENTupleInfo::kMetrics);
342 /// ~~~
343 void EnableMetrics() { fMetrics.Enable(); }
344 const Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
345};
346
347// clang-format off
348/**
349\class ROOT::Experimental::RNTupleWriter
350\ingroup NTuple
351\brief An RNTuple that gets filled with entries (data) and writes them to storage
352
353An output ntuple can be filled with entries. The caller has to make sure that the data that gets filled into an ntuple
354is not modified for the time of the Fill() call. The fill call serializes the C++ object into the column format and
355writes data into the corresponding column page buffers. Writing of the buffers to storage is deferred and can be
356triggered by Flush() or by destructing the ntuple. On I/O errors, an exception is thrown.
357*/
358// clang-format on
361
362private:
363 /// The page sink's parallel page compression scheduler if IMT is on.
364 /// Needs to be destructed after the page sink is destructed and so declared before.
365 std::unique_ptr<Detail::RPageStorage::RTaskScheduler> fZipTasks;
366 std::unique_ptr<Detail::RPageSink> fSink;
367 /// Needs to be destructed before fSink
368 std::unique_ptr<RNTupleModel> fModel;
370 NTupleSize_t fLastCommitted = 0;
371 NTupleSize_t fLastCommittedClusterGroup = 0;
372 NTupleSize_t fNEntries = 0;
373 /// Keeps track of the number of bytes written into the current cluster
374 std::size_t fUnzippedClusterSize = 0;
375 /// The total number of bytes written to storage (i.e., after compression)
376 std::uint64_t fNBytesCommitted = 0;
377 /// The total number of bytes filled into all the so far committed clusters,
378 /// i.e. the uncompressed size of the written clusters
379 std::uint64_t fNBytesFilled = 0;
380 /// Limit for committing cluster no matter the other tunables
382 /// Estimator of uncompressed cluster size, taking into account the estimated compression ratio
384
385 // Helper function that is called from CommitCluster() when necessary
386 void CommitClusterGroup();
387
388public:
389 /// Throws an exception if the model is null.
390 static std::unique_ptr<RNTupleWriter> Recreate(std::unique_ptr<RNTupleModel> model,
391 std::string_view ntupleName,
392 std::string_view storage,
393 const RNTupleWriteOptions &options = RNTupleWriteOptions());
394 /// Throws an exception if the model is null.
395 static std::unique_ptr<RNTupleWriter> Append(std::unique_ptr<RNTupleModel> model,
396 std::string_view ntupleName,
397 TFile &file,
398 const RNTupleWriteOptions &options = RNTupleWriteOptions());
399 /// Throws an exception if the model or the sink is null.
400 RNTupleWriter(std::unique_ptr<RNTupleModel> model, std::unique_ptr<Detail::RPageSink> sink);
401 RNTupleWriter(const RNTupleWriter&) = delete;
404
405 /// The simplest user interface if the default entry that comes with the ntuple model is used.
406 /// \return The number of uncompressed bytes written.
407 std::size_t Fill() { return Fill(*fModel->GetDefaultEntry()); }
408 /// Multiple entries can have been instantiated from the ntuple model. This method will perform
409 /// a light check whether the entry comes from the ntuple's own model.
410 /// \return The number of uncompressed bytes written.
411 std::size_t Fill(REntry &entry) {
412 if (R__unlikely(entry.GetModelId() != fModel->GetModelId()))
413 throw RException(R__FAIL("mismatch between entry and model"));
414
415 std::size_t bytesWritten = 0;
416 for (auto& value : entry) {
417 bytesWritten += value.Append();
418 }
419 fUnzippedClusterSize += bytesWritten;
420 fNEntries++;
421 if ((fUnzippedClusterSize >= fMaxUnzippedClusterSize) || (fUnzippedClusterSize >= fUnzippedClusterSizeEst))
422 CommitCluster();
423 return bytesWritten;
424 }
425 /// Ensure that the data from the so far seen Fill calls has been written to storage
426 void CommitCluster(bool commitClusterGroup = false);
427
428 std::unique_ptr<REntry> CreateEntry() { return fModel->CreateEntry(); }
429
430 /// Return the entry number that was last committed in a cluster.
431 NTupleSize_t GetLastCommitted() const { return fLastCommitted; }
432 /// Return the entry number that was last committed in a cluster group.
433 NTupleSize_t GetLastCommittedClusterGroup() const { return fLastCommittedClusterGroup; }
434 /// Return the number of entries filled so far.
435 NTupleSize_t GetNEntries() const { return fNEntries; }
436
437 void EnableMetrics() { fMetrics.Enable(); }
438 const Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
439
440 const RNTupleModel *GetModel() const { return fModel.get(); }
441
442 /// Get a `RNTupleModel::RUpdater` that provides limited support for incremental updates to the underlying
443 /// model, e.g. addition of new fields.
444 ///
445 /// **Example: add a new field after the model has been used to construct a `RNTupleWriter` object**
446 /// ~~~ {.cpp}
447 /// #include <ROOT/RNTuple.hxx>
448 /// using ROOT::Experimental::RNTupleModel;
449 /// using ROOT::Experimental::RNTupleWriter;
450 ///
451 /// auto model = RNTupleModel::Create();
452 /// auto fldFloat = model->MakeField<float>("fldFloat");
453 /// auto writer = RNTupleWriter::Recreate(std::move(model), "myNTuple", "some/file.root");
454 /// auto updater = writer->CreateModelUpdater();
455 /// updater->BeginUpdate();
456 /// updater->AddField(std::make_unique<RField<float>>("pt"));
457 /// updater->CommitUpdate();
458 ///
459 /// // ...
460 /// ~~~
461 std::unique_ptr<RNTupleModel::RUpdater> CreateModelUpdater()
462 {
463 return std::make_unique<RNTupleModel::RUpdater>(*this);
464 }
465};
466
467// clang-format off
468/**
469\class ROOT::Experimental::RCollectionNTuple
470\ingroup NTuple
471\brief A virtual ntuple used for writing untyped collections that can be used to some extent like an RNTupleWriter
472*
473* This class is between a field and a ntuple. It carries the offset column for the collection and the default entry
474* taken from the collection model. It does not, however, own an ntuple model because the collection model has been
475* merged into the larger ntuple model.
476*/
477// clang-format on
479private:
481 std::unique_ptr<REntry> fDefaultEntry;
482public:
483 explicit RCollectionNTupleWriter(std::unique_ptr<REntry> defaultEntry);
487
488 void Fill() { Fill(fDefaultEntry.get()); }
489 void Fill(REntry *entry) {
490 for (auto &value : *entry) {
491 value.Append();
492 }
493 fOffset++;
494 }
495
496 ClusterSize_t *GetOffsetPtr() { return &fOffset; }
497};
498
499// clang-format off
500/**
501\class ROOT::Experimental::RNTuple
502\ingroup NTuple
503\brief Representation of an RNTuple data set in a ROOT file
504
505This class provides an API entry point to an RNTuple stored in a ROOT file. Its main purpose is to
506construct a page source for an RNTuple, which in turn can be used to read an RNTuple with an RDF or
507an RNTupleReader.
508
509For instance, for an RNTuple called "Events" in a ROOT file, usage can be
510~~~ {.cpp}
511auto f = TFile::Open("data.root");
512auto ntpl = f->Get<ROOT::Experimental::RNTuple>("Events");
513
514auto reader = RNTupleReader::Open(ntpl);
515or
516auto pageSource = ntpl->MakePageSource();
517~~~
518*/
519// clang-format on
522 friend struct ROOT::Experimental::Internal::RNTupleTester;
523
524private:
525 // Only add transient members. The on-disk layout must be identical to RFileNTupleAnchor
526
527 TFile *fFile = nullptr; ///<! The file from which the ntuple was streamed, registered in the custom streamer
528
529 // Conversion between low-level anchor and RNTuple UI class
530 explicit RNTuple(const Internal::RFileNTupleAnchor &a) : Internal::RFileNTupleAnchor(a) {}
531 Internal::RFileNTupleAnchor GetAnchor() const { return *this; }
532
533public:
534 RNTuple() = default;
535 ~RNTuple() = default;
536
537 /// Create a page source from the RNTuple object. Requires the RNTuple object to be streamed from a file.
538 /// If fFile is not set, an exception is thrown.
539 std::unique_ptr<Detail::RPageSource> MakePageSource(const RNTupleReadOptions &options = RNTupleReadOptions());
540
541 /// RNTuple implements the hadd MergeFile interface
542 /// Merge this NTuple with the input list entries
543 Long64_t Merge(TCollection *input, TFileMergeInfo *mergeInfo);
544
545 // The version must match the RFileNTupleAnchor version in the LinkDef.h
547};
548
549} // namespace Experimental
550} // namespace ROOT
551
552#endif
#define R__unlikely(expr)
Definition RConfig.hxx:611
#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:303
#define a(i)
Definition RSha256.hxx:99
long long Long64_t
Definition RtypesCore.h:80
#define ClassDefNV(name, id)
Definition Rtypes.h:345
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
TTime operator*(const TTime &t1, const TTime &t2)
Definition TTime.h:85
A collection of Counter objects with a name, a unit, and a description.
The interface of a task scheduler to schedule page (de)compression tasks.
Write RNTuple data blocks in a TFile or a bare file container.
RCollectionNTupleWriter(const RCollectionNTupleWriter &)=delete
RCollectionNTupleWriter & operator=(const RCollectionNTupleWriter &)=delete
std::unique_ptr< REntry > fDefaultEntry
Definition RNTuple.hxx:481
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Definition REntry.hxx:42
std::uint64_t GetModelId() const
Definition REntry.hxx:102
Base class for all ROOT issued exceptions.
Definition RError.hxx:78
The on-storage meta-data of an ntuple.
Used to loop over indexes (entries or collections) between start and end.
void Reset() final
Start a new set of tasks.
Definition RNTuple.cxx:49
std::unique_ptr< TTaskGroup > fTaskGroup
Definition RNTuple.hxx:70
void AddTask(const std::function< void(void)> &taskFunc) final
Take a callable that represents a task.
Definition RNTuple.cxx:54
void Wait() final
Blocks until all scheduled tasks finished.
Definition RNTuple.cxx:59
A model is usually immutable after passing it to an RNTupleWriter.
The RNTupleModel encapulates the schema of an ntuple.
Common user-tunable settings for reading ntuples.
bool operator!=(const iterator &rh) const
Definition RNTuple.hxx:149
bool operator==(const iterator &rh) const
Definition RNTuple.hxx:148
std::forward_iterator_tag iterator_category
Definition RNTuple.hxx:134
An RNTuple that is used to read data from storage.
Definition RNTuple.hxx:102
std::unique_ptr< RNTupleReader > Clone()
Definition RNTuple.hxx:200
Detail::RNTupleMetrics fMetrics
Definition RNTuple.hxx:121
std::unique_ptr< Detail::RPageStorage::RTaskScheduler > fUnzipTasks
Set as the page source's scheduler for parallel page decompression if IMT is on Needs to be destructe...
Definition RNTuple.hxx:106
std::unique_ptr< RNTupleReader > fDisplayReader
We use a dedicated on-demand reader for Show() and Scan().
Definition RNTuple.hxx:114
void EnableMetrics()
Enable performance measurements (decompression time, bytes read from storage, etc....
Definition RNTuple.hxx:343
const Detail::RNTupleMetrics & GetMetrics() const
Definition RNTuple.hxx:344
RNTupleView< T > GetView(std::string_view fieldName)
Provides access to an individual field that can contain either a scalar value or a collection,...
Definition RNTuple.hxx:300
NTupleSize_t GetNEntries() const
Definition RNTuple.hxx:204
std::unique_ptr< RNTupleDescriptor > fCachedDescriptor
The ntuple descriptor in the page source is protected by a read-write lock.
Definition RNTuple.hxx:120
std::unique_ptr< Detail::RPageSource > fSource
Definition RNTuple.hxx:108
RNTupleGlobalRange GetEntryRange()
Returns an iterator over the entry indices of the RNTuple.
Definition RNTuple.hxx:277
RNTupleViewCollection GetViewCollection(std::string_view fieldName)
Raises an exception if:
Definition RNTuple.hxx:312
void LoadEntry(NTupleSize_t index)
Analogous to Fill(), fills the default entry of the model.
Definition RNTuple.hxx:247
std::unique_ptr< RNTupleModel > fModel
Needs to be destructed before fSource.
Definition RNTuple.hxx:110
void LoadEntry(NTupleSize_t index, REntry &entry)
Fills a user provided entry after checking that the entry has been instantiated from the ntuple model...
Definition RNTuple.hxx:256
A view for a collection, that can itself generate new ntuple views for its nested fields.
An RNTupleView provides read-only access to a single field of the ntuple.
Common user-tunable settings for storing ntuples.
An RNTuple that gets filled with entries (data) and writes them to storage.
Definition RNTuple.hxx:359
std::size_t fMaxUnzippedClusterSize
Limit for committing cluster no matter the other tunables.
Definition RNTuple.hxx:381
std::unique_ptr< RNTupleModel::RUpdater > CreateModelUpdater()
Get a RNTupleModel::RUpdater that provides limited support for incremental updates to the underlying ...
Definition RNTuple.hxx:461
const Detail::RNTupleMetrics & GetMetrics() const
Definition RNTuple.hxx:438
NTupleSize_t GetLastCommittedClusterGroup() const
Return the entry number that was last committed in a cluster group.
Definition RNTuple.hxx:433
std::size_t Fill()
The simplest user interface if the default entry that comes with the ntuple model is used.
Definition RNTuple.hxx:407
std::unique_ptr< REntry > CreateEntry()
Definition RNTuple.hxx:428
NTupleSize_t GetLastCommitted() const
Return the entry number that was last committed in a cluster.
Definition RNTuple.hxx:431
std::size_t fUnzippedClusterSizeEst
Estimator of uncompressed cluster size, taking into account the estimated compression ratio.
Definition RNTuple.hxx:383
std::unique_ptr< RNTupleModel > fModel
Needs to be destructed before fSink.
Definition RNTuple.hxx:368
RNTupleWriter(const RNTupleWriter &)=delete
Detail::RNTupleMetrics fMetrics
Definition RNTuple.hxx:369
std::size_t Fill(REntry &entry)
Multiple entries can have been instantiated from the ntuple model.
Definition RNTuple.hxx:411
RNTupleWriter & operator=(const RNTupleWriter &)=delete
std::unique_ptr< Detail::RPageSink > fSink
Definition RNTuple.hxx:366
NTupleSize_t GetNEntries() const
Return the number of entries filled so far.
Definition RNTuple.hxx:435
const RNTupleModel * GetModel() const
Definition RNTuple.hxx:440
std::unique_ptr< Detail::RPageStorage::RTaskScheduler > fZipTasks
The page sink's parallel page compression scheduler if IMT is on.
Definition RNTuple.hxx:365
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:520
Internal::RFileNTupleAnchor GetAnchor() const
Definition RNTuple.hxx:531
RNTuple(const Internal::RFileNTupleAnchor &a)
Definition RNTuple.hxx:530
Collection abstract base class.
Definition TCollection.h:65
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
Definition TFile.h:53
const Int_t n
Definition legend1.C:16
ENTupleInfo
Listing of the different options that can be printed by RNTupleReader::GetInfo()
Definition RNTuple.hxx:60
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr NTupleSize_t kInvalidNTupleIndex
constexpr DescriptorId_t kInvalidDescriptorId
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Definition file.py:1
static const char * what
Definition stlLoader.cc:6
Entry point for an RNTuple in a ROOT file.
Definition RMiniFile.hxx:65
Wrap the integer in a struct in order to avoid template specialization clash with std::uint32_t.
Used to specify the underlying RNTuples in OpenFriends()
Definition RNTuple.hxx:153
ROpenSpec(std::string_view n, std::string_view s)
Definition RNTuple.hxx:159
static void output()