Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleModel.cxx
Go to the documentation of this file.
1/// \file RNTupleModel.cxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-15
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#include <ROOT/RError.hxx>
17#include <ROOT/RField.hxx>
18#include <ROOT/RNTupleModel.hxx>
20#include <ROOT/StringUtils.hxx>
21
22#include <atomic>
23#include <cstdlib>
24#include <memory>
25#include <utility>
26
27namespace {
28std::uint64_t GetNewModelId()
29{
30 static std::atomic<std::uint64_t> gLastModelId = 0;
31 return ++gLastModelId;
32}
33} // anonymous namespace
34
37{
38 if (model.IsExpired()) {
39 throw RException(R__FAIL("invalid use of expired model"));
40 }
41 return *model.fFieldZero;
42}
43
46{
47 if (model.IsExpired()) {
48 throw RException(R__FAIL("invalid use of expired model"));
49 }
50 return *model.fProjectedFields;
51}
52
53//------------------------------------------------------------------------------
54
57{
58 auto source = fieldMap.at(target);
59 const bool hasCompatibleStructure =
60 (source->GetStructure() == target->GetStructure()) ||
61 ((source->GetStructure() == ENTupleStructure::kCollection) && dynamic_cast<const RCardinalityField *>(target));
63 return R__FAIL("field mapping structural mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
64 if ((source->GetStructure() == ENTupleStructure::kLeaf) || (source->GetStructure() == ENTupleStructure::kStreamer)) {
65 if (target->GetTypeName() != source->GetTypeName())
66 return R__FAIL("field mapping type mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
67 }
68
69 auto fnHasArrayParent = [](const RFieldBase &f) -> bool {
70 auto parent = f.GetParent();
71 while (parent) {
72 if (parent->GetNRepetitions() > 0)
73 return true;
74 parent = parent->GetParent();
75 }
76 return false;
77 };
79 return R__FAIL("unsupported field mapping across fixed-size arrays");
80 }
81
82 // We support projections only across records and collections. In the following, we check that the projected
83 // field is on the same path of collection fields in the field tree than the source field.
84
85 // Finds the first non-record parent field of the input field
86 auto fnBreakPoint = [](const RFieldBase *f) -> const RFieldBase * {
87 auto parent = f->GetParent();
88 while (parent) {
89 if ((parent->GetStructure() != ENTupleStructure::kRecord) &&
90 (parent->GetStructure() != ENTupleStructure::kLeaf)) {
91 return parent;
92 }
93 parent = parent->GetParent();
94 }
95 // We reached the zero field
96 return nullptr;
97 };
98
99 // If source or target has a variant or reference as a parent, error out
102 return R__FAIL("unsupported field mapping (source structure)");
105 return R__FAIL("unsupported field mapping (target structure)");
106
108 // Source and target have no collections as parent
109 return RResult<void>::Success();
110 }
113 // Source and target are children of the same collection
114 return RResult<void>::Success();
115 }
116 if (auto it = fieldMap.find(targetBreakPoint); it != fieldMap.end() && it->second == sourceBreakPoint) {
117 // The parent collection of parent is mapped to the parent collection of the source
118 return RResult<void>::Success();
119 }
120 // Source and target are children of different collections
121 return R__FAIL("field mapping structure mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
122 }
123
124 // Either source or target have no collection as a parent, but the other one has; that doesn't fit
125 return R__FAIL("field mapping structure mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
126}
127
130{
131 auto result = EnsureValidMapping(field.get(), fieldMap);
132 if (!result)
133 return R__FORWARD_ERROR(result);
134 for (const auto &f : *field) {
135 result = EnsureValidMapping(&f, fieldMap);
136 if (!result)
137 return R__FORWARD_ERROR(result);
138 }
139
140 fFieldMap.insert(fieldMap.begin(), fieldMap.end());
141 fFieldZero->Attach(std::move(field));
142 return RResult<void>::Success();
143}
144
147{
148 if (auto it = fFieldMap.find(target); it != fFieldMap.end())
149 return it->second;
150 return nullptr;
151}
152
153std::unique_ptr<ROOT::Experimental::Internal::RProjectedFields>
155{
156 auto cloneFieldZero = std::unique_ptr<RFieldZero>(static_cast<RFieldZero *>(fFieldZero->Clone("").release()));
157 auto clone = std::unique_ptr<RProjectedFields>(new RProjectedFields(std::move(cloneFieldZero)));
158 clone->fModel = &newModel;
159 // TODO(jblomer): improve quadratic search to re-wire the field mappings given the new model and the cloned
160 // projected fields. Not too critical as we generally expect a limited number of projected fields
161 for (const auto &[k, v] : fFieldMap) {
162 for (const auto &f : clone->GetFieldZero()) {
163 if (f.GetQualifiedFieldName() == k->GetQualifiedFieldName()) {
164 clone->fFieldMap[&f] = &newModel.GetConstField(v->GetQualifiedFieldName());
165 break;
166 }
167 }
168 }
169 return clone;
170}
171
173 : fWriter(writer), fOpenChangeset(fWriter.GetUpdatableModel())
174{
175}
176
178{
179 fOpenChangeset.fModel.Unfreeze();
180 // We set the model ID to zero until CommitUpdate(). That prevents calls to RNTupleWriter::Fill() in the middle
181 // of updates
182 std::swap(fOpenChangeset.fModel.fModelId, fNewModelId);
183}
184
186{
187 fOpenChangeset.fModel.Freeze();
188 std::swap(fOpenChangeset.fModel.fModelId, fNewModelId);
189 if (fOpenChangeset.IsEmpty())
190 return;
191 Internal::RNTupleModelChangeset toCommit{fOpenChangeset.fModel};
192 std::swap(fOpenChangeset.fAddedFields, toCommit.fAddedFields);
193 std::swap(fOpenChangeset.fAddedProjectedFields, toCommit.fAddedProjectedFields);
194 fWriter.GetSink().UpdateSchema(toCommit, fWriter.GetNEntries());
195}
196
198{
199 auto fieldp = field.get();
200 fOpenChangeset.fModel.AddField(std::move(field));
201 fOpenChangeset.fAddedFields.emplace_back(fieldp);
202}
203
206{
207 auto fieldp = field.get();
208 auto result = fOpenChangeset.fModel.AddProjectedField(std::move(field), mapping);
209 if (result)
210 fOpenChangeset.fAddedProjectedFields.emplace_back(fieldp);
212}
213
215{
217 if (!nameValid) {
218 nameValid.Throw();
219 }
220 if (fieldName.empty()) {
221 throw RException(R__FAIL("name cannot be empty string \"\""));
222 }
223 auto fieldNameStr = std::string(fieldName);
224 if (fFieldNames.count(fieldNameStr) > 0)
225 throw RException(R__FAIL("field name '" + fieldNameStr + "' already exists in NTuple model"));
226}
227
229{
230 if (IsFrozen())
231 throw RException(R__FAIL("invalid attempt to modify frozen model"));
232}
233
235{
236 if (IsBare())
237 throw RException(R__FAIL("invalid attempt to use default entry of bare model"));
238}
239
243
244std::unique_ptr<ROOT::Experimental::RNTupleModel> ROOT::Experimental::RNTupleModel::CreateBare()
245{
246 return CreateBare(std::make_unique<RFieldZero>());
247}
248
249std::unique_ptr<ROOT::Experimental::RNTupleModel>
251{
252 auto model = std::unique_ptr<RNTupleModel>(new RNTupleModel(std::move(fieldZero)));
253 model->fProjectedFields = std::make_unique<Internal::RProjectedFields>(*model);
254 return model;
255}
256
257std::unique_ptr<ROOT::Experimental::RNTupleModel> ROOT::Experimental::RNTupleModel::Create()
258{
259 return Create(std::make_unique<RFieldZero>());
260}
261
262std::unique_ptr<ROOT::Experimental::RNTupleModel>
264{
265 auto model = CreateBare(std::move(fieldZero));
266 model->fDefaultEntry = std::unique_ptr<REntry>(new REntry(model->fModelId, model->fSchemaId));
267 return model;
268}
269
270std::unique_ptr<ROOT::Experimental::RNTupleModel> ROOT::Experimental::RNTupleModel::Clone() const
271{
272 auto cloneModel = std::unique_ptr<RNTupleModel>(
273 new RNTupleModel(std::unique_ptr<RFieldZero>(static_cast<RFieldZero *>(fFieldZero->Clone("").release()))));
274 cloneModel->fModelId = GetNewModelId();
275 // For a frozen model, we can keep the schema id because adding new fields is forbidden. It is reset in Unfreeze()
276 // if called by the user.
277 if (IsFrozen()) {
278 cloneModel->fSchemaId = fSchemaId;
279 } else {
280 cloneModel->fSchemaId = cloneModel->fModelId;
281 }
282 cloneModel->fModelState = (fModelState == EState::kExpired) ? EState::kFrozen : fModelState;
283 cloneModel->fFieldNames = fFieldNames;
284 cloneModel->fDescription = fDescription;
285 cloneModel->fProjectedFields = fProjectedFields->Clone(*cloneModel);
286 cloneModel->fRegisteredSubfields = fRegisteredSubfields;
287 if (fDefaultEntry) {
288 cloneModel->fDefaultEntry = std::unique_ptr<REntry>(new REntry(cloneModel->fModelId, cloneModel->fSchemaId));
289 for (const auto &f : cloneModel->fFieldZero->GetSubFields()) {
290 cloneModel->fDefaultEntry->AddValue(f->CreateValue());
291 }
292 for (const auto &f : cloneModel->fRegisteredSubfields) {
293 cloneModel->AddSubfield(f, *cloneModel->fDefaultEntry);
294 }
295 }
296 return cloneModel;
297}
298
300{
301 if (fieldName.empty())
302 return nullptr;
303
304 auto *field = static_cast<ROOT::Experimental::RFieldBase *>(fFieldZero.get());
305 for (auto subfieldName : ROOT::Split(fieldName, ".")) {
306 const auto subfields = field->GetSubFields();
307 auto it = std::find_if(subfields.begin(), subfields.end(),
308 [&](const auto *f) { return f->GetFieldName() == subfieldName; });
309 if (it != subfields.end()) {
310 field = *it;
311 } else {
312 field = nullptr;
313 break;
314 }
315 }
316
317 return field;
318}
319
320void ROOT::Experimental::RNTupleModel::AddField(std::unique_ptr<RFieldBase> field)
321{
322 EnsureNotFrozen();
323 if (!field)
324 throw RException(R__FAIL("null field"));
325 EnsureValidFieldName(field->GetFieldName());
326
327 if (fDefaultEntry)
328 fDefaultEntry->AddValue(field->CreateValue());
329 fFieldNames.insert(field->GetFieldName());
330 fFieldZero->Attach(std::move(field));
331}
332
334 bool initializeValue) const
335{
336 auto field = FindField(qualifiedFieldName);
337 if (initializeValue)
338 entry.AddValue(field->CreateValue());
339 else
340 entry.AddValue(field->BindValue(nullptr));
341}
342
344{
345 if (qualifiedFieldName.empty())
346 throw RException(R__FAIL("no field name provided"));
347
348 if (fFieldNames.find(std::string(qualifiedFieldName)) != fFieldNames.end()) {
349 throw RException(
350 R__FAIL("cannot register top-level field \"" + std::string(qualifiedFieldName) + "\" as a subfield"));
351 }
352
353 if (fRegisteredSubfields.find(std::string(qualifiedFieldName)) != fRegisteredSubfields.end())
354 throw RException(R__FAIL("subfield \"" + std::string(qualifiedFieldName) + "\" already registered"));
355
356 EnsureNotFrozen();
357
358 auto *field = FindField(qualifiedFieldName);
359 if (!field) {
360 throw RException(R__FAIL("could not find subfield \"" + std::string(qualifiedFieldName) + "\" in model"));
361 }
362
363 auto parent = field->GetParent();
364 while (parent && !parent->GetFieldName().empty()) {
365 if (parent->GetStructure() == ENTupleStructure::kCollection || parent->GetNRepetitions() > 0 ||
366 parent->GetStructure() == ENTupleStructure::kVariant) {
367 throw RException(R__FAIL(
368 "registering a subfield as part of a collection, fixed-sized array or std::variant is not supported"));
369 }
370 parent = parent->GetParent();
371 }
372
373 if (fDefaultEntry)
374 AddSubfield(qualifiedFieldName, *fDefaultEntry);
375 fRegisteredSubfields.emplace(qualifiedFieldName);
376}
377
380{
381 EnsureNotFrozen();
382 if (!field)
383 return R__FAIL("null field");
384 auto fieldName = field->GetFieldName();
385
387 auto sourceField = FindField(mapping(fieldName));
388 if (!sourceField)
389 return R__FAIL("no such field: " + mapping(fieldName));
390 fieldMap[field.get()] = sourceField;
391 for (const auto &subField : *field) {
392 sourceField = FindField(mapping(subField.GetQualifiedFieldName()));
393 if (!sourceField)
394 return R__FAIL("no such field: " + mapping(subField.GetQualifiedFieldName()));
396 }
397
398 EnsureValidFieldName(fieldName);
399 auto result = fProjectedFields->Add(std::move(field), fieldMap);
400 if (!result) {
401 return R__FORWARD_ERROR(result);
402 }
403 fFieldNames.insert(fieldName);
404 return RResult<void>::Success();
405}
406
408{
409 if (IsFrozen())
410 throw RException(R__FAIL("invalid attempt to get mutable zero field of frozen model"));
411 return *fFieldZero;
412}
413
415{
416 if (IsFrozen())
417 throw RException(R__FAIL("invalid attempt to get mutable field of frozen model"));
418 auto f = FindField(fieldName);
419 if (!f)
420 throw RException(R__FAIL("invalid field: " + std::string(fieldName)));
421
422 return *f;
423}
424
426{
427 auto f = FindField(fieldName);
428 if (!f)
429 throw RException(R__FAIL("invalid field: " + std::string(fieldName)));
430
431 return *f;
432}
433
435{
436 EnsureNotBare();
437 return *fDefaultEntry;
438}
439
441{
442 if (!IsFrozen())
443 throw RException(R__FAIL("invalid attempt to get default entry of unfrozen model"));
444 EnsureNotBare();
445 return *fDefaultEntry;
446}
447
448std::unique_ptr<ROOT::Experimental::REntry> ROOT::Experimental::RNTupleModel::CreateEntry() const
449{
450 switch (fModelState) {
451 case EState::kBuilding: throw RException(R__FAIL("invalid attempt to create entry of unfrozen model"));
452 case EState::kExpired: throw RException(R__FAIL("invalid attempt to create entry of expired model"));
453 case EState::kFrozen: break;
454 }
455
456 auto entry = std::unique_ptr<REntry>(new REntry(fModelId, fSchemaId));
457 for (const auto &f : fFieldZero->GetSubFields()) {
458 entry->AddValue(f->CreateValue());
459 }
460 for (const auto &f : fRegisteredSubfields) {
461 AddSubfield(f, *entry);
462 }
463 return entry;
464}
465
466std::unique_ptr<ROOT::Experimental::REntry> ROOT::Experimental::RNTupleModel::CreateBareEntry() const
467{
468 switch (fModelState) {
469 case EState::kBuilding: throw RException(R__FAIL("invalid attempt to create entry of unfrozen model"));
470 case EState::kExpired: throw RException(R__FAIL("invalid attempt to create entry of expired model"));
471 case EState::kFrozen: break;
472 }
473
474 auto entry = std::unique_ptr<REntry>(new REntry(fModelId, fSchemaId));
475 for (const auto &f : fFieldZero->GetSubFields()) {
476 entry->AddValue(f->BindValue(nullptr));
477 }
478 for (const auto &f : fRegisteredSubfields) {
479 AddSubfield(f, *entry, false /* initializeValue */);
480 }
481 return entry;
482}
483
485{
486 const auto &topLevelFields = fFieldZero->GetSubFields();
487 auto it = std::find_if(topLevelFields.begin(), topLevelFields.end(),
488 [&fieldName](const RFieldBase *f) { return f->GetFieldName() == fieldName; });
489
490 if (it == topLevelFields.end()) {
491 throw RException(R__FAIL("invalid field name: " + std::string(fieldName)));
492 }
493 return REntry::RFieldToken(std::distance(topLevelFields.begin(), it), fSchemaId);
494}
495
497{
498 switch (fModelState) {
499 case EState::kBuilding: throw RException(R__FAIL("invalid attempt to create bulk of unfrozen model"));
500 case EState::kExpired: throw RException(R__FAIL("invalid attempt to create bulk of expired model"));
501 case EState::kFrozen: break;
502 }
503
504 auto f = FindField(fieldName);
505 if (!f)
506 throw RException(R__FAIL("no such field: " + std::string(fieldName)));
507 return f->CreateBulk();
508}
509
511{
512 switch (fModelState) {
513 case EState::kExpired: return;
514 case EState::kBuilding: throw RException(R__FAIL("invalid attempt to expire unfrozen model"));
515 case EState::kFrozen: break;
516 }
517
518 // Ensure that Fill() does not work anymore
519 fModelId = 0;
520 fModelState = EState::kExpired;
521}
522
524{
525 switch (fModelState) {
526 case EState::kBuilding: return;
527 case EState::kExpired: throw RException(R__FAIL("invalid attempt to unfreeze expired model"));
528 case EState::kFrozen: break;
529 }
530
531 fModelId = GetNewModelId();
532 fSchemaId = fModelId;
533 if (fDefaultEntry) {
534 fDefaultEntry->fModelId = fModelId;
535 fDefaultEntry->fSchemaId = fSchemaId;
536 }
537 fModelState = EState::kBuilding;
538}
539
541{
542 if (fModelState == EState::kExpired)
543 throw RException(R__FAIL("invalid attempt to freeze expired model"));
544
545 fModelState = EState::kFrozen;
546}
547
549{
550 EnsureNotFrozen();
551 fDescription = std::string(description);
552}
553
555{
556 std::size_t bytes = 0;
557 std::size_t minPageBufferSize = 0;
558
559 // Start with the size of the page buffers used to fill a persistent sink
560 std::size_t nColumns = 0;
561 for (auto &&field : *fFieldZero) {
562 for (const auto &r : field.GetColumnRepresentatives()) {
563 nColumns += r.size();
564 minPageBufferSize += r.size() * options.GetInitialUnzippedPageSize();
565 }
566 }
567 bytes = std::min(options.GetPageBufferBudget(), nColumns * options.GetMaxUnzippedPageSize());
568
569 // If using buffered writing with RPageSinkBuf, we create a clone of the model and keep at least
570 // the compressed pages in memory.
571 if (options.GetUseBufferedWrite()) {
573 // Use the target cluster size as an estimate for all compressed pages combined.
575 int compression = options.GetCompression();
577 // With IMT, compression happens asynchronously which means that the uncompressed pages also stay around. Use a
578 // compression factor of 2x as a very rough estimate.
579 bytes += 2 * options.GetApproxZippedClusterSize();
580 }
581 }
582
583 return bytes;
584}
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
Definition RError.hxx:303
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
Definition RError.hxx:301
#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:299
#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.
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
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 Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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 bytes
The projected fields of a RNTupleModel
RResult< void > EnsureValidMapping(const RFieldBase *target, const FieldMap_t &fieldMap)
Asserts that the passed field is a valid target of the source field provided in the field map.
std::unique_ptr< RProjectedFields > Clone(const RNTupleModel &newModel) const
The new model needs to be a clone of fModel.
std::unordered_map< const RFieldBase *, const 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< RFieldBase > field, const FieldMap_t &fieldMap)
Adds a new projected field.
const RFieldBase * GetSourceField(const RFieldBase *target) const
An artificial field that transforms an RNTuple column that contains the offset of collections into co...
Definition RField.hxx:285
The field token identifies a (sub)field in this entry.
Definition REntry.hxx:63
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Definition REntry.hxx:51
Similar to RValue but manages an array of consecutive values.
A field translates read and write calls from/to underlying columns to/from tree values.
const RFieldBase * GetParent() const
The container field for an ntuple model, which itself has no physical representation.
Definition RField.hxx:58
RResult< void > AddProjectedField(std::unique_ptr< RFieldBase > field, FieldMappingFunc_t mapping)
void CommitUpdate()
Commit changes since the last call to BeginUpdate().
void BeginUpdate()
Begin a new set of alterations to the underlying model.
void AddField(std::unique_ptr< RFieldBase > field)
The RNTupleModel encapulates the schema of an ntuple.
std::unordered_set< std::string > fFieldNames
Keeps track of which field names are taken, including projected field names.
void EnsureValidFieldName(std::string_view fieldName)
Checks that user-provided field names are valid in the context of this RNTuple model.
std::uint64_t fModelId
Every model has a unique ID to distinguish it from other models.
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...
std::unique_ptr< Internal::RProjectedFields > fProjectedFields
The set of projected top-level fields.
const RFieldBase & GetConstField(std::string_view fieldName) 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...
REntry::RFieldToken GetToken(std::string_view fieldName) const
Creates a token to be used in REntry methods to address a field present in the entry.
void EnsureNotBare() const
Throws an RException if fDefaultEntry is nullptr.
std::unique_ptr< RNTupleModel > Clone() const
void EnsureNotFrozen() const
Throws an RException if fFrozen is true.
RFieldZero & GetMutableFieldZero()
Mutable access to the root field is used to make adjustments to the fields.
std::size_t EstimateWriteMemoryUsage(const RNTupleWriteOptions &options=RNTupleWriteOptions()) const
Estimate the memory usage for this model during writing.
std::unique_ptr< REntry > CreateBareEntry() const
In a bare entry, all values point to nullptr.
std::unique_ptr< REntry > CreateEntry() const
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...
static std::unique_ptr< RNTupleModel > Create()
void AddSubfield(std::string_view fieldName, REntry &entry, bool initializeValue=true) const
Add a subfield to the provided entry.
void SetDescription(std::string_view description)
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...
RResult< void > AddProjectedField(std::unique_ptr< RFieldBase > field, FieldMappingFunc_t mapping)
Adds a top-level field based on existing fields.
RNTupleModel(std::unique_ptr< RFieldZero > fieldZero)
RFieldBase & GetMutableField(std::string_view fieldName)
static std::unique_ptr< RNTupleModel > CreateBare()
A bare model has no default entry.
void AddField(std::unique_ptr< RFieldBase > field)
Adds a field whose type is not known at compile time.
void RegisterSubfield(std::string_view qualifiedFieldName)
Register a subfield so it can be accessed directly from entries belonging to the model.
std::unique_ptr< RFieldZero > fFieldZero
Hierarchy of fields consisting of simple types and collections (sub trees)
Common user-tunable settings for storing ntuples.
An RNTuple that gets filled with entries (data) and writes them to storage.
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
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
RResult< void > EnsureValidNameForRNTuple(std::string_view name, std::string_view where)
Check whether a given string is a valid name according to the RNTuple specification.
RProjectedFields & GetProjectedFieldsOfModel(RNTupleModel &model)
RFieldZero & GetFieldZeroOfModel(RNTupleModel &model)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
The incremental changes to a RNTupleModel