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>
19#include <ROOT/RNTupleModel.hxx>
21#include <ROOT/StringUtils.hxx>
22
23#include <atomic>
24#include <cstdlib>
25#include <memory>
26#include <utility>
27
28namespace {
29std::uint64_t GetNewModelId()
30{
31 static std::atomic<std::uint64_t> gLastModelId = 0;
32 return ++gLastModelId;
33}
34} // anonymous namespace
35
36std::unique_ptr<ROOT::Experimental::RNTupleModel>
38 std::string_view rightFieldPrefix)
39{
40 if (!left.IsFrozen() || !right.IsFrozen())
41 throw RException(R__FAIL("invalid attempt to merge unfrozen models"));
42
43 auto newModel = left.Clone();
44 newModel->Unfreeze();
45
46 if (!rightFieldPrefix.empty()) {
47 newModel->MakeCollection(std::string(rightFieldPrefix), right.Clone());
48 } else {
49 for (const auto &f : right.GetFieldZero().GetSubFields()) {
50 newModel->AddField(f->Clone(f->GetFieldName()));
51 }
52 }
53
54 newModel->Freeze();
55 return newModel;
56}
57
58//------------------------------------------------------------------------------
59
62 const FieldMap_t &fieldMap)
63{
64 auto source = fieldMap.at(target);
65 const bool hasCompatibleStructure =
66 (source->GetStructure() == target->GetStructure()) ||
67 ((source->GetStructure() == ENTupleStructure::kCollection) && dynamic_cast<const RCardinalityField *>(target));
68 if (!hasCompatibleStructure)
69 return R__FAIL("field mapping structural mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
70 if ((source->GetStructure() == ENTupleStructure::kLeaf) || (source->GetStructure() == ENTupleStructure::kUnsplit)) {
71 if (target->GetTypeName() != source->GetTypeName())
72 return R__FAIL("field mapping type mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
73 }
74
75 // We support projections only across records and collections. In the following, we check that the projected
76 // field is on the same path of collection fields in the field tree than the source field.
77
78 // Finds the first non-record parent field of the input field
79 auto fnBreakPoint = [](const RFieldBase *f) -> const RFieldBase * {
80 auto parent = f->GetParent();
81 while (parent) {
82 if (parent->GetStructure() != ENTupleStructure::kRecord)
83 return parent;
84 parent = parent->GetParent();
85 }
86 // We reached the zero field
87 return nullptr;
88 };
89
90 // If source or target has a variant or reference as a parent, error out
91 auto *sourceBreakPoint = fnBreakPoint(source);
92 if (sourceBreakPoint && sourceBreakPoint->GetStructure() != ENTupleStructure::kCollection)
93 return R__FAIL("unsupported field mapping (source structure)");
94 auto *targetBreakPoint = fnBreakPoint(target);
95 if (targetBreakPoint && sourceBreakPoint->GetStructure() != ENTupleStructure::kCollection)
96 return R__FAIL("unsupported field mapping (target structure)");
97
98 if (!sourceBreakPoint && !targetBreakPoint) {
99 // Source and target have no collections as parent
100 return RResult<void>::Success();
101 }
102 if (sourceBreakPoint && targetBreakPoint) {
103 if (sourceBreakPoint == targetBreakPoint) {
104 // Source and target are children of the same collection
105 return RResult<void>::Success();
106 }
107 if (auto it = fieldMap.find(targetBreakPoint); it != fieldMap.end() && it->second == sourceBreakPoint) {
108 // The parent collection of parent is mapped to the parent collection of the source
109 return RResult<void>::Success();
110 }
111 // Source and target are children of different collections
112 return R__FAIL("field mapping structure mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
113 }
114
115 // Either source or target have no collection as a parent, but the other one has; that doesn't fit
116 return R__FAIL("field mapping structure mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
117}
118
120ROOT::Experimental::RNTupleModel::RProjectedFields::Add(std::unique_ptr<RFieldBase> field, const FieldMap_t &fieldMap)
121{
122 auto result = EnsureValidMapping(field.get(), fieldMap);
123 if (!result)
124 return R__FORWARD_ERROR(result);
125 for (const auto &f : *field) {
126 result = EnsureValidMapping(&f, fieldMap);
127 if (!result)
128 return R__FORWARD_ERROR(result);
129 }
130
131 fFieldMap.insert(fieldMap.begin(), fieldMap.end());
132 fFieldZero->Attach(std::move(field));
133 return RResult<void>::Success();
134}
135
138{
139 if (auto it = fFieldMap.find(target); it != fFieldMap.end())
140 return it->second;
141 return nullptr;
142}
143
144std::unique_ptr<ROOT::Experimental::RNTupleModel::RProjectedFields>
146{
147 auto cloneFieldZero = std::unique_ptr<RFieldZero>(static_cast<RFieldZero *>(fFieldZero->Clone("").release()));
148 auto clone = std::unique_ptr<RProjectedFields>(new RProjectedFields(std::move(cloneFieldZero)));
149 clone->fModel = newModel;
150 // TODO(jblomer): improve quadratic search to re-wire the field mappings given the new model and the cloned
151 // projected fields. Not too critical as we generally expect a limited number of projected fields
152 for (const auto &[k, v] : fFieldMap) {
153 for (const auto &f : *clone->GetFieldZero()) {
154 if (f.GetQualifiedFieldName() == k->GetQualifiedFieldName()) {
155 clone->fFieldMap[&f] = clone->fModel->FindField(v->GetQualifiedFieldName());
156 break;
157 }
158 }
159 }
160 return clone;
161}
162
164 : fWriter(writer), fOpenChangeset(fWriter.GetUpdatableModel())
165{
166}
167
169{
170 fOpenChangeset.fModel.Unfreeze();
171 // We set the model ID to zero until CommitUpdate(). That prevents calls to RNTupleWriter::Fill() in the middle
172 // of updates
173 std::swap(fOpenChangeset.fModel.fModelId, fNewModelId);
174}
175
177{
178 fOpenChangeset.fModel.Freeze();
179 std::swap(fOpenChangeset.fModel.fModelId, fNewModelId);
180 if (fOpenChangeset.IsEmpty())
181 return;
182 Internal::RNTupleModelChangeset toCommit{fOpenChangeset.fModel};
183 std::swap(fOpenChangeset.fAddedFields, toCommit.fAddedFields);
184 std::swap(fOpenChangeset.fAddedProjectedFields, toCommit.fAddedProjectedFields);
185 fWriter.GetSink().UpdateSchema(toCommit, fWriter.GetNEntries());
186}
187
188void ROOT::Experimental::RNTupleModel::RUpdater::AddField(std::unique_ptr<RFieldBase> field)
189{
190 auto fieldp = field.get();
191 fOpenChangeset.fModel.AddField(std::move(field));
192 fOpenChangeset.fAddedFields.emplace_back(fieldp);
193}
194
197 FieldMappingFunc_t mapping)
198{
199 auto fieldp = field.get();
200 auto result = fOpenChangeset.fModel.AddProjectedField(std::move(field), mapping);
201 if (result)
202 fOpenChangeset.fAddedProjectedFields.emplace_back(fieldp);
204}
205
207{
208 RResult<void> nameValid = RFieldBase::EnsureValidFieldName(fieldName);
209 if (!nameValid) {
210 nameValid.Throw();
211 }
212 auto fieldNameStr = std::string(fieldName);
213 if (fFieldNames.count(fieldNameStr) > 0)
214 throw RException(R__FAIL("field name '" + fieldNameStr + "' already exists in NTuple model"));
215}
216
218{
219 if (IsFrozen())
220 throw RException(R__FAIL("invalid attempt to modify frozen model"));
221}
222
224{
225 if (IsBare())
226 throw RException(R__FAIL("invalid attempt to use default entry of bare model"));
227}
228
229ROOT::Experimental::RNTupleModel::RNTupleModel(std::unique_ptr<RFieldZero> fieldZero)
230 : fFieldZero(std::move(fieldZero)), fModelId(GetNewModelId()), fSchemaId(fModelId)
231{}
232
233std::unique_ptr<ROOT::Experimental::RNTupleModel> ROOT::Experimental::RNTupleModel::CreateBare()
234{
235 return CreateBare(std::make_unique<RFieldZero>());
236}
237
238std::unique_ptr<ROOT::Experimental::RNTupleModel>
239ROOT::Experimental::RNTupleModel::CreateBare(std::unique_ptr<RFieldZero> fieldZero)
240{
241 auto model = std::unique_ptr<RNTupleModel>(new RNTupleModel(std::move(fieldZero)));
242 model->fProjectedFields = std::make_unique<RProjectedFields>(model.get());
243 return model;
244}
245
246std::unique_ptr<ROOT::Experimental::RNTupleModel> ROOT::Experimental::RNTupleModel::Create()
247{
248 return Create(std::make_unique<RFieldZero>());
249}
250
251std::unique_ptr<ROOT::Experimental::RNTupleModel>
252ROOT::Experimental::RNTupleModel::Create(std::unique_ptr<RFieldZero> fieldZero)
253{
254 auto model = CreateBare(std::move(fieldZero));
255 model->fDefaultEntry = std::unique_ptr<REntry>(new REntry(model->fModelId, model->fSchemaId));
256 return model;
257}
258
259std::unique_ptr<ROOT::Experimental::RNTupleModel> ROOT::Experimental::RNTupleModel::Clone() const
260{
261 auto cloneModel = std::unique_ptr<RNTupleModel>(
262 new RNTupleModel(std::unique_ptr<RFieldZero>(static_cast<RFieldZero *>(fFieldZero->Clone("").release()))));
263 cloneModel->fModelId = GetNewModelId();
264 // For a frozen model, we can keep the schema id because adding new fields is forbidden. It is reset in Unfreeze()
265 // if called by the user.
266 if (fIsFrozen) {
267 cloneModel->fSchemaId = fSchemaId;
268 } else {
269 cloneModel->fSchemaId = cloneModel->fModelId;
270 }
271 cloneModel->fIsFrozen = fIsFrozen;
272 cloneModel->fFieldNames = fFieldNames;
273 cloneModel->fDescription = fDescription;
274 cloneModel->fProjectedFields = fProjectedFields->Clone(cloneModel.get());
275 if (fDefaultEntry) {
276 cloneModel->fDefaultEntry = std::unique_ptr<REntry>(new REntry(cloneModel->fModelId, cloneModel->fSchemaId));
277 for (const auto &f : cloneModel->fFieldZero->GetSubFields()) {
278 cloneModel->fDefaultEntry->AddValue(f->CreateValue());
279 }
280 }
281 return cloneModel;
282}
283
285{
286 if (fieldName.empty())
287 return nullptr;
288
289 auto *field = static_cast<ROOT::Experimental::RFieldBase *>(fFieldZero.get());
290 for (auto subfieldName : ROOT::Split(fieldName, ".")) {
291 const auto subfields = field->GetSubFields();
292 auto it = std::find_if(subfields.begin(), subfields.end(),
293 [&](const auto *f) { return f->GetFieldName() == subfieldName; });
294 if (it != subfields.end()) {
295 field = *it;
296 } else {
297 field = nullptr;
298 break;
299 }
300 }
301
302 return field;
303}
304
305void ROOT::Experimental::RNTupleModel::AddField(std::unique_ptr<RFieldBase> field)
306{
307 EnsureNotFrozen();
308 if (!field)
309 throw RException(R__FAIL("null field"));
310 EnsureValidFieldName(field->GetFieldName());
311
312 if (fDefaultEntry)
313 fDefaultEntry->AddValue(field->CreateValue());
314 fFieldNames.insert(field->GetFieldName());
315 fFieldZero->Attach(std::move(field));
316}
317
320{
321 EnsureNotFrozen();
322 if (!field)
323 return R__FAIL("null field");
324 auto fieldName = field->GetFieldName();
325
327 auto sourceField = FindField(mapping(fieldName));
328 if (!sourceField)
329 return R__FAIL("no such field: " + mapping(fieldName));
330 fieldMap[field.get()] = sourceField;
331 for (const auto &subField : *field) {
332 sourceField = FindField(mapping(subField.GetQualifiedFieldName()));
333 if (!sourceField)
334 return R__FAIL("no such field: " + mapping(fieldName));
335 fieldMap[&subField] = sourceField;
336 }
337
338 EnsureValidFieldName(fieldName);
339 auto result = fProjectedFields->Add(std::move(field), fieldMap);
340 if (!result) {
341 return R__FORWARD_ERROR(result);
342 }
343 fFieldNames.insert(fieldName);
344 return RResult<void>::Success();
345}
346
347std::shared_ptr<ROOT::Experimental::RNTupleCollectionWriter>
349 std::unique_ptr<RNTupleModel> collectionModel)
350{
351 EnsureNotFrozen();
352 EnsureValidFieldName(fieldName);
353 if (!collectionModel) {
354 throw RException(R__FAIL("null collectionModel"));
355 }
356
357 auto collectionWriter = std::make_shared<RNTupleCollectionWriter>(std::move(collectionModel->fDefaultEntry));
358
359 auto field = std::make_unique<RCollectionField>(fieldName, collectionWriter, std::move(collectionModel->fFieldZero));
360 field->SetDescription(collectionModel->GetDescription());
361
362 if (fDefaultEntry)
363 fDefaultEntry->AddValue(field->BindValue(std::shared_ptr<void>(collectionWriter->GetOffsetPtr(), [](void *) {})));
364
365 fFieldNames.insert(field->GetFieldName());
366 fFieldZero->Attach(std::move(field));
367 return collectionWriter;
368}
369
371{
372 if (!IsFrozen())
373 throw RException(R__FAIL("invalid attempt to get mutable zero field of unfrozen model"));
374 return *fFieldZero;
375}
376
378{
379 auto f = FindField(fieldName);
380 if (!f)
381 throw RException(R__FAIL("invalid field: " + std::string(fieldName)));
382
383 return *f;
384}
385
387{
388 EnsureNotBare();
389 return *fDefaultEntry;
390}
391
393{
394 if (!IsFrozen())
395 throw RException(R__FAIL("invalid attempt to get default entry of unfrozen model"));
396 EnsureNotBare();
397 return *fDefaultEntry;
398}
399
400std::unique_ptr<ROOT::Experimental::REntry> ROOT::Experimental::RNTupleModel::CreateEntry() const
401{
402 if (!IsFrozen())
403 throw RException(R__FAIL("invalid attempt to create entry of unfrozen model"));
404
405 auto entry = std::unique_ptr<REntry>(new REntry(fModelId, fSchemaId));
406 for (const auto &f : fFieldZero->GetSubFields()) {
407 entry->AddValue(f->CreateValue());
408 }
409 return entry;
410}
411
412std::unique_ptr<ROOT::Experimental::REntry> ROOT::Experimental::RNTupleModel::CreateBareEntry() const
413{
414 if (!IsFrozen())
415 throw RException(R__FAIL("invalid attempt to create entry of unfrozen model"));
416
417 auto entry = std::unique_ptr<REntry>(new REntry(fModelId, fSchemaId));
418 for (const auto &f : fFieldZero->GetSubFields()) {
419 entry->AddValue(f->BindValue(nullptr));
420 }
421 return entry;
422}
423
425{
426 const auto &topLevelFields = fFieldZero->GetSubFields();
427 auto it = std::find_if(topLevelFields.begin(), topLevelFields.end(),
428 [&fieldName](const RFieldBase *f) { return f->GetFieldName() == fieldName; });
429
430 if (it == topLevelFields.end()) {
431 throw RException(R__FAIL("invalid field name: " + std::string(fieldName)));
432 }
433 return REntry::RFieldToken(std::distance(topLevelFields.begin(), it), fSchemaId);
434}
435
437{
438 if (!IsFrozen())
439 throw RException(R__FAIL("invalid attempt to create bulk of unfrozen model"));
440
441 auto f = FindField(fieldName);
442 if (!f)
443 throw RException(R__FAIL("no such field: " + std::string(fieldName)));
444 return f->CreateBulk();
445}
446
448{
449 if (!IsFrozen())
450 return;
451
452 fModelId = GetNewModelId();
453 fSchemaId = fModelId;
454 if (fDefaultEntry) {
455 fDefaultEntry->fModelId = fModelId;
456 fDefaultEntry->fSchemaId = fSchemaId;
457 }
458 fIsFrozen = false;
459}
460
462{
463 fIsFrozen = true;
464}
465
466void ROOT::Experimental::RNTupleModel::SetDescription(std::string_view description)
467{
468 EnsureNotFrozen();
469 fDescription = std::string(description);
470}
471
473{
474 std::size_t bytes = 0;
475 std::size_t minPageBufferSize = 0;
476
477 // Start with the size of the page buffers used to fill a persistent sink
478 std::size_t nColumns = 0;
479 for (auto &&field : *fFieldZero) {
480 for (const auto &r : field.GetColumnRepresentatives()) {
481 nColumns += r.size();
482 for (auto columnType : r) {
483 minPageBufferSize +=
485 }
486 }
487 }
488 bytes = std::min(options.GetPageBufferBudget(), nColumns * options.GetMaxUnzippedPageSize());
489
490 // If using buffered writing with RPageSinkBuf, we create a clone of the model and keep at least
491 // the compressed pages in memory.
492 if (options.GetUseBufferedWrite()) {
493 bytes += minPageBufferSize;
494 // Use the target cluster size as an estimate for all compressed pages combined.
496 int compression = options.GetCompression();
497 if (compression != 0 && options.GetUseImplicitMT() == RNTupleWriteOptions::EImplicitMT::kDefault) {
498 // With IMT, compression happens asynchronously which means that the uncompressed pages also stay around. Use a
499 // compression factor of 2x as a very rough estimate.
500 bytes += 2 * options.GetApproxZippedClusterSize();
501 }
502 }
503
504 return bytes;
505}
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
Definition RError.hxx:294
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
Definition RError.hxx:292
#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:290
#define f(i)
Definition RSha256.hxx:104
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
static std::unique_ptr< RColumnElementBase > Generate(EColumnType type)
If CppT == void, use the default C++ type for the given column type.
An artificial field that transforms an RNTuple column that contains the offset of collections into co...
Definition RField.hxx:307
The field token identifies a top-level field in this entry.
Definition REntry.hxx:60
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Definition REntry.hxx:50
Base class for all ROOT issued exceptions.
Definition RError.hxx:78
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
std::vector< RFieldBase * > GetSubFields()
Definition RField.cxx:1017
static RResult< void > EnsureValidFieldName(std::string_view fieldName)
Check whether a given string is a valid field name.
Definition RField.cxx:910
The container field for an ntuple model, which itself has no physical representation.
Definition RField.hxx:59
Projected fields are fields whose columns are reused from existing fields.
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::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 ...
const RFieldBase * GetSourceField(const RFieldBase *target) const
RResult< void > Add(std::unique_ptr< RFieldBase > field, const FieldMap_t &fieldMap)
Adds a new projected field.
std::unique_ptr< RProjectedFields > Clone(const RNTupleModel *newModel) const
The new model needs to be a clone of fModel.
void CommitUpdate()
Commit changes since the last call to BeginUpdate().
void BeginUpdate()
Begin a new set of alterations to the underlying model.
RResult< void > AddProjectedField(std::unique_ptr< RFieldBase > field, FieldMappingFunc_t mapping)
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 NTuple 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::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 top-level field.
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.
std::size_t EstimateWriteMemoryUsage(const RNTupleWriteOptions &options=RNTupleWriteOptions()) const
Estimate the memory usage for this model during writing.
std::shared_ptr< RNTupleCollectionWriter > MakeCollection(std::string_view fieldName, std::unique_ptr< RNTupleModel > collectionModel)
Ingests a model for a sub collection and attaches it to the current model.
const RFieldBase & GetField(std::string_view fieldName) const
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()
RResult< void > AddProjectedField(std::unique_ptr< RFieldBase > field, FieldMappingFunc_t mapping)
Adds a top-level field based on existing fields.
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...
RNTupleModel(std::unique_ptr< RFieldZero > fieldZero)
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.
RFieldZero & GetFieldZero()
Non-const access to the root field is used to commit clusters during writing, and to make adjustments...
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.
void Throw()
Throws an RException with fError.
Definition RError.cxx:67
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:194
std::unique_ptr< RNTupleModel > MergeModels(const RNTupleModel &left, const RNTupleModel &right, std::string_view rightFieldPrefix="")
Merge two RNTuple models.
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