Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
RNTupleModel.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleModel.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_RNTupleModel
17#define ROOT7_RNTupleModel
18
19#include <ROOT/REntry.hxx>
20#include <ROOT/RError.hxx>
21#include <ROOT/RField.hxx>
22#include <ROOT/RFieldToken.hxx>
23#include <ROOT/RNTupleUtil.hxx>
24#include <string_view>
25
26#include <cstdint>
27#include <functional>
28#include <memory>
29#include <string>
30#include <unordered_map>
31#include <unordered_set>
32#include <utility>
33
34namespace ROOT {
35
36class RNTupleWriteOptions;
37class RNTupleModel;
38class RNTupleWriter;
39
40namespace Experimental {
41namespace Detail {
42class RRawPtrWriteEntry;
43} // namespace Detail
44} // namespace Experimental
45
46namespace Internal {
47class RProjectedFields;
48
49ROOT::RFieldZero &GetFieldZeroOfModel(RNTupleModel &model);
50RProjectedFields &GetProjectedFieldsOfModel(RNTupleModel &model);
51
52// clang-format off
53/**
54\class ROOT::Internal::RProjectedFields
55\ingroup NTuple
56\brief The projected fields of a `RNTupleModel`
57
58Projected fields are fields whose columns are reused from existing fields. Projected fields are not attached
59to the models zero field. Only the real source fields are written to, projected fields are stored as metadata
60(header) information only. Only top-level projected fields are supported because otherwise the layout of types
61could be altered in unexpected ways.
62All projected fields and the source fields used to back them are kept in this class.
63*/
64// clang-format on
66public:
67 /// The map keys are the projected target fields, the map values are the backing source fields
68 /// Note that sub fields are treated individually and indepently of their parent field
69 using FieldMap_t = std::unordered_map<const ROOT::RFieldBase *, const ROOT::RFieldBase *>;
70
71private:
72 explicit RProjectedFields(std::unique_ptr<ROOT::RFieldZero> fieldZero) : fFieldZero(std::move(fieldZero)) {}
73 /// The projected fields are attached to this zero field
74 std::unique_ptr<ROOT::RFieldZero> fFieldZero;
75 /// Maps the source fields from fModel to the target projected fields attached to fFieldZero
77 /// The model this set of projected fields belongs to
79
80 /// Asserts that the passed field is a valid target of the source field provided in the field map.
81 /// Checks the field without looking into sub fields.
83
84public:
85 explicit RProjectedFields(const RNTupleModel &model)
86 : fFieldZero(std::make_unique<ROOT::RFieldZero>()), fModel(&model)
87 {
88 }
93 ~RProjectedFields() = default;
94
95 /// The new model needs to be a clone of fModel
96 std::unique_ptr<RProjectedFields> Clone(const RNTupleModel &newModel) const;
97
100 /// Adds a new projected field. The field map needs to provide valid source fields of fModel for 'field'
101 /// and each of its sub fields.
102 RResult<void> Add(std::unique_ptr<ROOT::RFieldBase> field, const FieldMap_t &fieldMap);
103 bool IsEmpty() const { return fFieldZero->begin() == fFieldZero->end(); }
104};
105
106} // namespace Internal
107
108// clang-format off
109/**
110\class ROOT::RNTupleModel
111\ingroup NTuple
112\brief The RNTupleModel encapulates the schema of an ntuple.
113
114The ntuple model comprises a collection of hierarchically organized fields. From a model, "entries"
115can be extracted. For convenience, the model provides a default entry unless it is created as a "bare model".
116Models have a unique model identifier that faciliates checking whether entries are compatible with it
117(i.e.: have been extracted from that model).
118
119A model is subject to a state transition during its lifetime: it starts in a building state, in which fields can be
120added and modified. Once the schema is finalized, the model gets frozen. Only frozen models can create entries.
121From frozen, models move into a expired state. In this state, the model is only partially usable: it can be cloned
122and queried, but it can't be unfrozen anymore and no new entries can be created. This state is used for models
123that were used for writing and are no longer connected to a page sink.
124*/
125// clang-format on
129
130public:
131 /// User provided function that describes the mapping of existing source fields to projected fields in terms
132 /// of fully qualified field names. The mapping function is called with the qualified field names of the provided
133 /// field and the subfields. It should return the qualified field names used as a mapping source.
134 using FieldMappingFunc_t = std::function<std::string(const std::string &)>;
135
136 class RUpdater;
137
138private:
139 // The states a model can be in. Possible transitions are between kBuilding and kFrozen
140 // and from kFrozen to kExpired.
141 enum class EState {
142 kBuilding,
143 kFrozen,
145 };
146
147 /// Hierarchy of fields consisting of simple types and collections (sub trees)
148 std::unique_ptr<ROOT::RFieldZero> fFieldZero;
149 /// Contains field values corresponding to the created top-level fields, as well as registered subfields
150 std::unique_ptr<ROOT::REntry> fDefaultEntry;
151 /// Keeps track of which field names are taken, including projected field names.
152 std::unordered_set<std::string> fFieldNames;
153 /// Free text set by the user
154 std::string fDescription;
155 /// The set of projected top-level fields
156 std::unique_ptr<Internal::RProjectedFields> fProjectedFields;
157 /// Keeps track of which subfields have been registered to be included in entries belonging to this model.
158 std::unordered_set<std::string> fRegisteredSubfields;
159 /// Every model has a unique ID to distinguish it from other models. Entries are linked to models via the ID.
160 /// Cloned models get a new model ID. Expired models are cloned into frozen models.
161 std::uint64_t fModelId = 0;
162 /// Models have a separate schema ID to remember that the clone of a frozen model still has the same schema.
163 std::uint64_t fSchemaId = 0;
164 /// Changed by Freeze() / Unfreeze() and by the RUpdater.
166
167 /// Checks that user-provided field names are valid in the context of this RNTuple model.
168 /// Throws an RException for invalid names, empty names (which is reserved for the zero field) and duplicate field
169 /// names.
170 void EnsureValidFieldName(std::string_view fieldName);
171
172 /// Throws an RException if fFrozen is true
173 void EnsureNotFrozen() const;
174
175 /// Throws an RException if fDefaultEntry is nullptr
176 void EnsureNotBare() const;
177
178 /// The field name can be a top-level field or a nested field. Returns nullptr if the field is not in the model.
179 ROOT::RFieldBase *FindField(std::string_view fieldName) const;
180
181 /// Add a subfield to the provided entry. If `initializeValue` is false, a nullptr will be bound to the entry value
182 /// (used in bare models).
183 void AddSubfield(std::string_view fieldName, ROOT::REntry &entry, bool initializeValue = true) const;
184
185 RNTupleModel(std::unique_ptr<ROOT::RFieldZero> fieldZero);
186
187public:
188 RNTupleModel(const RNTupleModel &) = delete;
190 ~RNTupleModel() = default;
191
192 std::unique_ptr<RNTupleModel> Clone() const;
193 static std::unique_ptr<RNTupleModel> Create();
194 static std::unique_ptr<RNTupleModel> Create(std::unique_ptr<ROOT::RFieldZero> fieldZero);
195 /// A bare model has no default entry
196 static std::unique_ptr<RNTupleModel> CreateBare();
197 static std::unique_ptr<RNTupleModel> CreateBare(std::unique_ptr<ROOT::RFieldZero> fieldZero);
198
199 /// Creates a new field given a `name` or `{name, description}` pair and a
200 /// corresponding, default-constructed value that is managed by a shared pointer.
201 ///
202 /// **Example: create some fields and fill an %RNTuple**
203 /// ~~~ {.cpp}
204 /// #include <ROOT/RNTupleModel.hxx>
205 /// #include <ROOT/RNTupleWriter.hxx>
206 /// using ROOT::RNTupleWriter;
207 ///
208 /// #include <vector>
209 ///
210 /// auto model = ROOT::RNTupleModel::Create();
211 /// auto pt = model->MakeField<float>("pt");
212 /// auto vec = model->MakeField<std::vector<int>>("vec");
213 ///
214 /// // The RNTuple is written to disk when the RNTupleWriter goes out of scope
215 /// {
216 /// auto writer = RNTupleWriter::Recreate(std::move(model), "myNTuple", "myFile.root");
217 /// for (int i = 0; i < 100; i++) {
218 /// *pt = static_cast<float>(i);
219 /// *vec = {i, i+1, i+2};
220 /// writer->Fill();
221 /// }
222 /// }
223 /// ~~~
224 ///
225 /// **Example: create a field with a description**
226 /// ~~~ {.cpp}
227 /// #include <ROOT/RNTupleModel.hxx>
228 ///
229 /// auto model = ROOT::RNTupleModel::Create();
230 /// auto hadronFlavour = model->MakeField<float>(
231 /// "hadronFlavour", "flavour from hadron ghost clustering"
232 /// );
233 /// ~~~
234 template <typename T>
235 std::shared_ptr<T> MakeField(std::string_view name, std::string_view description = "")
236 {
239 auto field = std::make_unique<ROOT::RField<T>>(name);
240 field->SetDescription(description);
241 std::shared_ptr<T> ptr;
242 if (fDefaultEntry)
243 ptr = fDefaultEntry->AddValue<T>(*field);
244 fFieldNames.insert(field->GetFieldName());
245 fFieldZero->Attach(std::move(field));
246 return ptr;
247 }
248
249 /// Adds a field whose type is not known at compile time. Thus there is no shared pointer returned.
250 ///
251 /// Throws an exception if the field is null.
252 void AddField(std::unique_ptr<ROOT::RFieldBase> field);
253
254 /// Register a subfield so it can be accessed directly from entries belonging to the model. Because registering a
255 /// subfield does not fundamentally change the model, previously created entries will not be invalidated, nor
256 /// modified in any way; a registered subfield is merely an accessor added to the default entry (if present) and any
257 /// entries created afterwards.
258 ///
259 /// Using models with registered subfields for writing is not allowed. Attempting to do so will result in an
260 /// exception.
261 ///
262 /// Throws an exception if the provided subfield could not be found in the model.
263 void RegisterSubfield(std::string_view qualifiedFieldName);
264
265 /// Adds a top-level field based on existing fields.
266 ///
267 /// The mapping function takes one argument, which is a string containing the name of the projected field. The return
268 /// value of the mapping function should be the name of the (existing) field onto which the projection is made.
269 /// **Example**
270 /// ~~~ {.cpp}
271 /// auto model = RNTupleModel::Create();
272 /// model->MakeField<float>("met");
273 /// auto metProjection = ROOT::RFieldBase::Create("missingE", "float").Unwrap();
274 /// model->AddProjectedField(std::move(metProjection), [](const std::string &) { return "met"; });
275 /// ~~~
276 ///
277 /// Adding projections for collection fields is also possible, as long as they follow the same schema structure. For
278 /// example, a projection of a collection of structs onto a collection of scalars is possible, but a projection of a
279 /// collection of a collection of scalars onto a collection of scalars is not.
280 ///
281 /// In the case of projections for nested fields, the mapping function must provide a mapping for every nesting
282 /// level.
283 /// **Example**
284 /// ~~~ {.cpp}
285 /// struct P { int x, y; };
286 ///
287 /// auto model = RNTupleModel::Create();
288 /// model->MakeField<std::vector<P>>("points");
289 /// auto pxProjection = ROOT::RFieldBase::Create("pxs", "std::vector<int>").Unwrap();
290 /// model->AddProjectedField(std::move(pxProjection), [](const std::string &fieldName) {
291 /// if (fieldName == "pxs")
292 /// return "points";
293 /// else
294 /// return "points._0.x";
295 /// });
296 /// ~~~
297 ///
298 /// Creating projections for fields containing `std::variant` or fixed-size arrays is unsupported.
299 RResult<void> AddProjectedField(std::unique_ptr<ROOT::RFieldBase> field, FieldMappingFunc_t mapping);
300
301 void Freeze();
302 void Unfreeze();
303 void Expire();
304 bool IsExpired() const { return fModelState == EState::kExpired; }
306 bool IsBare() const { return !fDefaultEntry; }
307 std::uint64_t GetModelId() const { return fModelId; }
308 std::uint64_t GetSchemaId() const { return fSchemaId; }
309
310 std::unique_ptr<ROOT::REntry> CreateEntry() const;
311 /// In a bare entry, all values point to nullptr. The resulting entry shall use BindValue() in order
312 /// set memory addresses to be serialized / deserialized
313 std::unique_ptr<ROOT::REntry> CreateBareEntry() const;
314 std::unique_ptr<Experimental::Detail::RRawPtrWriteEntry> CreateRawPtrWriteEntry() const;
315
316 /// Creates a token to be used in REntry methods to address a field present in the entry
317 ROOT::RFieldToken GetToken(std::string_view fieldName) const;
318 /// Calls the given field's CreateBulk() method. Throws an exception if no field with the given name exists.
319 ROOT::RFieldBase::RBulk CreateBulk(std::string_view fieldName) const;
320
322 const ROOT::REntry &GetDefaultEntry() const;
323
324 /// Mutable access to the root field is used to make adjustments to the fields.
327 ROOT::RFieldBase &GetMutableField(std::string_view fieldName);
328 const ROOT::RFieldBase &GetConstField(std::string_view fieldName) const;
329
330 const std::string &GetDescription() const { return fDescription; }
331 void SetDescription(std::string_view description);
332
333 /// Get the names of the fields currently present in the model, including projected fields. Registered subfields
334 /// are not included, use GetRegisteredSubfieldnames() for this.
335 const std::unordered_set<std::string> &GetFieldNames() const { return fFieldNames; }
336 /// Get the (qualified) names of subfields that have been registered to be included in entries from this model.
337 const std::unordered_set<std::string> &GetRegisteredSubfieldNames() const { return fRegisteredSubfields; }
338
339 /// Estimate the memory usage for this model during writing
340 ///
341 /// This will return an estimate in bytes for the internal page and compression buffers. The value should be
342 /// understood per sequential RNTupleWriter or per RNTupleFillContext created for a RNTupleParallelWriter
343 /// constructed with this model.
345};
346
347namespace Internal {
348
349// clang-format off
350/**
351\class ROOT::Internal::RNTupleModelChangeset
352\ingroup NTuple
353\brief The incremental changes to a `RNTupleModel`
354
355Represents a set of alterations to a `RNTupleModel` that happened after the model is used to initialize a `RPageSink`
356instance. This object can be used to communicate metadata updates to a `RPageSink`.
357You will not normally use this directly; see `RNTupleModel::RUpdater` instead.
358*/
359// clang-format on
362 /// Points to the fields in fModel that were added as part of an updater transaction
363 std::vector<ROOT::RFieldBase *> fAddedFields;
364 /// Points to the projected fields in fModel that were added as part of an updater transaction
365 std::vector<ROOT::RFieldBase *> fAddedProjectedFields;
366
368 bool IsEmpty() const { return fAddedFields.empty() && fAddedProjectedFields.empty(); }
369
370 void AddField(std::unique_ptr<ROOT::RFieldBase> field);
372 AddProjectedField(std::unique_ptr<ROOT::RFieldBase> field, RNTupleModel::FieldMappingFunc_t mapping);
373};
374
375} // namespace Internal
376
377/// A model is usually immutable after passing it to an `RNTupleWriter`. However, for the rare
378/// cases that require changing the model after the fact, `RUpdater` provides limited support for
379/// incremental updates, e.g. addition of new fields.
380///
381/// See `RNTupleWriter::CreateModelUpdater()` for an example.
383private:
386 std::uint64_t fNewModelId = 0; ///< The model ID after committing
387
388public:
391 /// Begin a new set of alterations to the underlying model. As a side effect, all REntry
392 /// instances related to the model are invalidated.
393 void BeginUpdate();
394 /// Commit changes since the last call to `BeginUpdate()`. All the invalidated REntries remain
395 /// invalid. `CreateEntry()` or `CreateBareEntry()` can be used to create an REntry that
396 /// matches the new model. Upon completion, `BeginUpdate()` can be called again to begin a new set of changes.
397 void CommitUpdate();
398
399 template <typename T>
400 std::shared_ptr<T> MakeField(std::string_view name, std::string_view description = "")
401 {
404 auto it =
405 std::find_if(fieldZero->begin(), fieldZero->end(), [&](const auto &f) { return f.GetFieldName() == name; });
406 R__ASSERT(it != fieldZero->end());
407 fOpenChangeset.fAddedFields.emplace_back(&(*it));
408 return objPtr;
409 }
410
411 void AddField(std::unique_ptr<ROOT::RFieldBase> field);
412
413 RResult<void> AddProjectedField(std::unique_ptr<ROOT::RFieldBase> field, FieldMappingFunc_t mapping);
414};
415
416namespace Experimental {
417// TODO(gparolini): remove before branching ROOT v6.36
418using RNTupleModel [[deprecated("ROOT::Experimental::RNTupleModel moved to ROOT::RNTupleModel")]] = ROOT::RNTupleModel;
419} // namespace Experimental
420
421} // namespace ROOT
422
423#endif
#define f(i)
Definition RSha256.hxx:104
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
char name[80]
Definition TGX11.cxx:110
The projected fields of a RNTupleModel
const ROOT::RFieldBase * GetSourceField(const ROOT::RFieldBase *target) const
const RNTupleModel * fModel
The model this set of projected fields belongs to.
std::unordered_map< const ROOT::RFieldBase *, const ROOT::RFieldBase * > FieldMap_t
The map keys are the projected target fields, the map values are the backing source fields Note that ...
RResult< void > Add(std::unique_ptr< ROOT::RFieldBase > field, const FieldMap_t &fieldMap)
Adds a new projected field.
RProjectedFields(RProjectedFields &&)=default
RProjectedFields(std::unique_ptr< ROOT::RFieldZero > fieldZero)
RProjectedFields(const RNTupleModel &model)
std::unique_ptr< RProjectedFields > Clone(const RNTupleModel &newModel) const
The new model needs to be a clone of fModel.
RProjectedFields & operator=(const RProjectedFields &)=delete
FieldMap_t fFieldMap
Maps the source fields from fModel to the target projected fields attached to fFieldZero.
std::unique_ptr< ROOT::RFieldZero > fFieldZero
The projected fields are attached to this zero field.
RProjectedFields(const RProjectedFields &)=delete
RResult< void > EnsureValidMapping(const ROOT::RFieldBase *target, const FieldMap_t &fieldMap)
Asserts that the passed field is a valid target of the source field provided in the field map.
ROOT::RFieldZero & GetFieldZero()
RProjectedFields & operator=(RProjectedFields &&)=default
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Definition REntry.hxx:56
Points to an array of objects with RNTuple I/O support, used for bulk reading.
A field translates read and write calls from/to underlying columns to/from tree values.
A field token identifies a (sub)field in an entry.
The container field for an ntuple model, which itself has no physical representation.
Definition RField.hxx:56
A model is usually immutable after passing it to an RNTupleWriter.
ROOT::RNTupleWriter & fWriter
std::uint64_t fNewModelId
The model ID after committing.
void CommitUpdate()
Commit changes since the last call to BeginUpdate().
RResult< void > AddProjectedField(std::unique_ptr< ROOT::RFieldBase > field, FieldMappingFunc_t mapping)
RUpdater(ROOT::RNTupleWriter &writer)
Internal::RNTupleModelChangeset fOpenChangeset
void AddField(std::unique_ptr< ROOT::RFieldBase > field)
std::shared_ptr< T > MakeField(std::string_view name, std::string_view description="")
void BeginUpdate()
Begin a new set of alterations to the underlying model.
The RNTupleModel encapulates the schema of an ntuple.
std::unique_ptr< ROOT::REntry > CreateEntry() const
RNTupleModel(std::unique_ptr< ROOT::RFieldZero > fieldZero)
void AddSubfield(std::string_view fieldName, ROOT::REntry &entry, bool initializeValue=true) const
Add a subfield to the provided entry.
std::unique_ptr< RNTupleModel > Clone() const
std::uint64_t fModelId
Every model has a unique ID to distinguish it from other models.
void EnsureValidFieldName(std::string_view fieldName)
Checks that user-provided field names are valid in the context of this RNTuple model.
RNTupleModel & operator=(const RNTupleModel &)=delete
std::uint64_t GetModelId() const
ROOT::RFieldZero & GetMutableFieldZero()
Mutable access to the root field is used to make adjustments to the fields.
const std::unordered_set< std::string > & GetFieldNames() const
Get the names of the fields currently present in the model, including projected fields.
std::unordered_set< std::string > fRegisteredSubfields
Keeps track of which subfields have been registered to be included in entries belonging to this model...
const ROOT::RFieldZero & GetConstFieldZero() const
std::size_t EstimateWriteMemoryUsage(const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions()) const
Estimate the memory usage for this model during writing.
EState fModelState
Changed by Freeze() / Unfreeze() and by the RUpdater.
ROOT::REntry & GetDefaultEntry()
void EnsureNotFrozen() const
Throws an RException if fFrozen is true.
void AddField(std::unique_ptr< ROOT::RFieldBase > field)
Adds a field whose type is not known at compile time.
static std::unique_ptr< RNTupleModel > Create()
std::string fDescription
Free text set by the user.
bool IsFrozen() const
void SetDescription(std::string_view description)
std::unique_ptr< Experimental::Detail::RRawPtrWriteEntry > CreateRawPtrWriteEntry() const
std::unique_ptr< Internal::RProjectedFields > fProjectedFields
The set of projected top-level fields.
RNTupleModel(const RNTupleModel &)=delete
const std::string & GetDescription() const
RResult< void > AddProjectedField(std::unique_ptr< ROOT::RFieldBase > field, FieldMappingFunc_t mapping)
Adds a top-level field based on existing fields.
ROOT::RFieldToken GetToken(std::string_view fieldName) const
Creates a token to be used in REntry methods to address a field present in the entry.
std::unordered_set< std::string > fFieldNames
Keeps track of which field names are taken, including projected field names.
std::unique_ptr< ROOT::RFieldZero > fFieldZero
Hierarchy of fields consisting of simple types and collections (sub trees)
void EnsureNotBare() const
Throws an RException if fDefaultEntry is nullptr.
void RegisterSubfield(std::string_view qualifiedFieldName)
Register a subfield so it can be accessed directly from entries belonging to the model.
ROOT::RFieldBase * FindField(std::string_view fieldName) const
The field name can be a top-level field or a nested field. Returns nullptr if the field is not in the...
std::shared_ptr< T > MakeField(std::string_view name, std::string_view description="")
Creates a new field given a name or {name, description} pair and a corresponding, default-constructed...
std::unique_ptr< ROOT::REntry > fDefaultEntry
Contains field values corresponding to the created top-level fields, as well as registered subfields.
ROOT::RFieldBase & GetMutableField(std::string_view fieldName)
const std::unordered_set< std::string > & GetRegisteredSubfieldNames() const
Get the (qualified) names of subfields that have been registered to be included in entries from this ...
std::uint64_t GetSchemaId() const
static std::unique_ptr< RNTupleModel > CreateBare()
A bare model has no default entry.
std::function< std::string(const std::string &)> FieldMappingFunc_t
User provided function that describes the mapping of existing source fields to projected fields in te...
~RNTupleModel()=default
bool IsExpired() const
std::uint64_t fSchemaId
Models have a separate schema ID to remember that the clone of a frozen model still has the same sche...
ROOT::RFieldBase::RBulk CreateBulk(std::string_view fieldName) const
Calls the given field's CreateBulk() method. Throws an exception if no field with the given name exis...
const ROOT::RFieldBase & GetConstField(std::string_view fieldName) const
std::unique_ptr< ROOT::REntry > CreateBareEntry() const
In a bare entry, all values point to nullptr.
Common user-tunable settings for storing RNTuples.
An RNTuple that gets filled with entries (data) and writes them to storage.
const_iterator begin() const
const_iterator end() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:197
ROOT::RFieldZero & GetFieldZeroOfModel(RNTupleModel &model)
RProjectedFields & GetProjectedFieldsOfModel(RNTupleModel &model)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
The incremental changes to a RNTupleModel
std::vector< ROOT::RFieldBase * > fAddedProjectedFields
Points to the projected fields in fModel that were added as part of an updater transaction.
void AddField(std::unique_ptr< ROOT::RFieldBase > field)
std::vector< ROOT::RFieldBase * > fAddedFields
Points to the fields in fModel that were added as part of an updater transaction.
ROOT::RResult< void > AddProjectedField(std::unique_ptr< ROOT::RFieldBase > field, RNTupleModel::FieldMappingFunc_t mapping)