Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RFieldBase.cxx
Go to the documentation of this file.
1/// \file RFieldBase.cxx
2/// \ingroup NTuple
3/// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
4/// \date 2024-11-19
5
6#include <ROOT/RError.hxx>
7#include <ROOT/RField.hxx>
8#include <ROOT/RFieldBase.hxx>
10#include <ROOT/RFieldUtils.hxx>
11#include <ROOT/RNTupleUtils.hxx>
12
13#include <TClass.h>
14#include <TClassEdit.h>
15#include <TEnum.h>
16
17#include <string>
18#include <vector>
19
20namespace {
21
22/// Used as a thread local context storage for Create(); steers the behavior of the Create() call stack
23class CreateContextGuard;
24class CreateContext {
25 friend class CreateContextGuard;
26 /// All classes that were defined by Create() calls higher up in the stack. Finds cyclic type definitions.
27 std::vector<std::string> fClassesOnStack;
28 /// If set to true, Create() will create an RInvalidField on error instead of throwing an exception.
29 /// This is used in RFieldBase::Check() to identify unsupported sub fields.
30 bool fContinueOnError = false;
31
32public:
33 CreateContext() = default;
34 bool GetContinueOnError() const { return fContinueOnError; }
35};
36
37/// RAII for modifications of CreateContext
38class CreateContextGuard {
39 CreateContext &fCreateContext;
40 std::size_t fNOriginalClassesOnStack;
41 bool fOriginalContinueOnError;
42
43public:
44 CreateContextGuard(CreateContext &ctx)
45 : fCreateContext(ctx),
46 fNOriginalClassesOnStack(ctx.fClassesOnStack.size()),
47 fOriginalContinueOnError(ctx.fContinueOnError)
48 {
49 }
51 {
52 fCreateContext.fClassesOnStack.resize(fNOriginalClassesOnStack);
53 fCreateContext.fContinueOnError = fOriginalContinueOnError;
54 }
55
56 void AddClassToStack(const std::string &cl)
57 {
58 if (std::find(fCreateContext.fClassesOnStack.begin(), fCreateContext.fClassesOnStack.end(), cl) !=
59 fCreateContext.fClassesOnStack.end()) {
60 throw ROOT::RException(R__FAIL("cyclic class definition: " + cl));
61 }
62 fCreateContext.fClassesOnStack.emplace_back(cl);
63 }
64
65 void SetContinueOnError(bool value) { fCreateContext.fContinueOnError = value; }
66};
67
68} // anonymous namespace
69
87
89ROOT::Internal::CallFieldBaseCreate(const std::string &fieldName, const std::string &typeName,
90 const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc,
92{
93 return RFieldBase::Create(fieldName, typeName, options, desc, fieldId);
94}
95
96//------------------------------------------------------------------------------
97
99{
100 // A single representations with an empty set of columns
103}
104
112
113//------------------------------------------------------------------------------
114
116{
117 // Set fObjPtr to an aliased shared_ptr of the input raw pointer. Note that
118 // fObjPtr will be non-empty but have use count zero.
120}
121
122//------------------------------------------------------------------------------
123
125 : fField(other.fField),
127 fCapacity(other.fCapacity),
129 fIsAdopted(other.fIsAdopted),
130 fNValidValues(other.fNValidValues),
131 fFirstIndex(other.fFirstIndex)
132{
133 std::swap(fDeleter, other.fDeleter);
134 std::swap(fValues, other.fValues);
135 std::swap(fMaskAvail, other.fMaskAvail);
136}
137
139{
140 std::swap(fField, other.fField);
141 std::swap(fDeleter, other.fDeleter);
142 std::swap(fValues, other.fValues);
143 std::swap(fValueSize, other.fValueSize);
144 std::swap(fCapacity, other.fCapacity);
145 std::swap(fSize, other.fSize);
146 std::swap(fIsAdopted, other.fIsAdopted);
147 std::swap(fMaskAvail, other.fMaskAvail);
148 std::swap(fNValidValues, other.fNValidValues);
149 std::swap(fFirstIndex, other.fFirstIndex);
150 return *this;
151}
152
154{
155 if (fValues)
156 ReleaseValues();
157}
158
160{
161 if (fIsAdopted)
162 return;
163
164 if (!(fField->GetTraits() & RFieldBase::kTraitTriviallyDestructible)) {
165 for (std::size_t i = 0; i < fCapacity; ++i) {
166 fDeleter->operator()(GetValuePtrAt(i), true /* dtorOnly */);
167 }
168 }
169
170 operator delete(fValues);
171}
172
174{
175 if (fCapacity < size) {
176 if (fIsAdopted) {
177 throw RException(R__FAIL("invalid attempt to bulk read beyond the adopted buffer"));
178 }
179 ReleaseValues();
180 fValues = operator new(size * fValueSize);
181
182 if (!(fField->GetTraits() & RFieldBase::kTraitTriviallyConstructible)) {
183 for (std::size_t i = 0; i < size; ++i) {
184 fField->ConstructValue(GetValuePtrAt(i));
185 }
186 }
187
188 fMaskAvail = std::make_unique<bool[]>(size);
189 fCapacity = size;
190 }
191
192 std::fill(fMaskAvail.get(), fMaskAvail.get() + size, false);
193 fNValidValues = 0;
194
195 fFirstIndex = firstIndex;
196 fSize = size;
197}
198
200{
201 fNValidValues = 0;
202 for (std::size_t i = 0; i < fSize; ++i)
203 fNValidValues += static_cast<std::size_t>(fMaskAvail[i]);
204}
205
206void ROOT::RFieldBase::RBulkValues::AdoptBuffer(void *buf, std::size_t capacity)
207{
208 ReleaseValues();
209 fValues = buf;
210 fCapacity = capacity;
211 fSize = capacity;
212
213 fMaskAvail = std::make_unique<bool[]>(capacity);
214
215 fFirstIndex = RNTupleLocalIndex();
216
217 fIsAdopted = true;
218}
219
220//------------------------------------------------------------------------------
221
223{
224 R__LOG_WARNING(ROOT::Internal::NTupleLog()) << "possibly leaking object from RField<T>::CreateObject<void>";
225}
226
227template <>
228std::unique_ptr<void, typename ROOT::RFieldBase::RCreateObjectDeleter<void>::deleter>
229ROOT::RFieldBase::CreateObject<void>() const
230{
232 return std::unique_ptr<void, RCreateObjectDeleter<void>::deleter>(CreateObjectRawPtr(), gDeleter);
233}
234
235//------------------------------------------------------------------------------
236
237ROOT::RFieldBase::RFieldBase(std::string_view name, std::string_view type, ROOT::ENTupleStructure structure,
238 bool isSimple, std::size_t nRepetitions)
239 : fName(name),
240 fType(type),
241 fStructure(structure),
244 fParent(nullptr),
245 fPrincipalColumn(nullptr),
247{
249}
250
252{
253 std::string result = GetFieldName();
254 auto parent = GetParent();
255 while (parent && !parent->GetFieldName().empty()) {
256 result = parent->GetFieldName() + "." + result;
257 parent = parent->GetParent();
258 }
259 return result;
260}
261
263ROOT::RFieldBase::Create(const std::string &fieldName, const std::string &typeName)
264{
265 return R__FORWARD_RESULT(
267}
268
269std::vector<ROOT::RFieldBase::RCheckResult>
270ROOT::RFieldBase::Check(const std::string &fieldName, const std::string &typeName)
271{
274 cfOpts.SetReturnInvalidOnError(true);
275 cfOpts.SetEmulateUnknownTypes(false);
276 fieldZero.Attach(RFieldBase::Create(fieldName, typeName, cfOpts, nullptr, kInvalidDescriptorId).Unwrap());
277
278 std::vector<RCheckResult> result;
279 for (const auto &f : fieldZero) {
280 const bool isInvalidField = f.GetTraits() & RFieldBase::kTraitInvalidField;
281 if (!isInvalidField)
282 continue;
283
284 const auto &invalidField = static_cast<const RInvalidField &>(f);
285 result.emplace_back(
286 RCheckResult{invalidField.GetQualifiedFieldName(), invalidField.GetTypeName(), invalidField.GetError()});
287 }
288 return result;
289}
290
292ROOT::RFieldBase::Create(const std::string &fieldName, const std::string &typeName,
293 const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc,
295{
298
300
301 thread_local CreateContext createContext;
302 CreateContextGuard createContextGuard(createContext);
303 if (options.GetReturnInvalidOnError())
304 createContextGuard.SetContinueOnError(true);
305
306 auto fnFail = [&fieldName,
307 &resolvedType](const std::string &errMsg,
309 RInvalidField::ECategory::kTypeError) -> RResult<std::unique_ptr<RFieldBase>> {
310 if (createContext.GetContinueOnError()) {
311 return std::unique_ptr<RFieldBase>(std::make_unique<RInvalidField>(fieldName, resolvedType, errMsg, cat));
312 } else {
313 return R__FAIL(errMsg);
314 }
315 };
316
317 if (resolvedType.empty())
318 return R__FORWARD_RESULT(fnFail("no type name specified for field '" + fieldName + "'"));
319
320 std::unique_ptr<ROOT::RFieldBase> result;
321
322 const auto maybeGetChildId = [desc, fieldId](int childId) {
323 if (desc) {
324 const auto &fieldDesc = desc->GetFieldDescriptor(fieldId);
325 return fieldDesc.GetLinkIds().at(childId);
326 } else {
328 }
329 };
330
331 // try-catch block to intercept any exception that may be thrown by Unwrap() so that this
332 // function never throws but returns RResult::Error instead.
333 try {
334 if (resolvedType == "bool") {
335 result = std::make_unique<RField<bool>>(fieldName);
336 } else if (resolvedType == "char") {
337 result = std::make_unique<RField<char>>(fieldName);
338 } else if (resolvedType == "std::byte") {
339 result = std::make_unique<RField<std::byte>>(fieldName);
340 } else if (resolvedType == "std::int8_t") {
341 result = std::make_unique<RField<std::int8_t>>(fieldName);
342 } else if (resolvedType == "std::uint8_t") {
343 result = std::make_unique<RField<std::uint8_t>>(fieldName);
344 } else if (resolvedType == "std::int16_t") {
345 result = std::make_unique<RField<std::int16_t>>(fieldName);
346 } else if (resolvedType == "std::uint16_t") {
347 result = std::make_unique<RField<std::uint16_t>>(fieldName);
348 } else if (resolvedType == "std::int32_t") {
349 result = std::make_unique<RField<std::int32_t>>(fieldName);
350 } else if (resolvedType == "std::uint32_t") {
351 result = std::make_unique<RField<std::uint32_t>>(fieldName);
352 } else if (resolvedType == "std::int64_t") {
353 result = std::make_unique<RField<std::int64_t>>(fieldName);
354 } else if (resolvedType == "std::uint64_t") {
355 result = std::make_unique<RField<std::uint64_t>>(fieldName);
356 } else if (resolvedType == "float") {
357 result = std::make_unique<RField<float>>(fieldName);
358 } else if (resolvedType == "double") {
359 result = std::make_unique<RField<double>>(fieldName);
360 } else if (resolvedType == "Double32_t") {
361 result = std::make_unique<RField<double>>(fieldName);
362 static_cast<RField<double> *>(result.get())->SetDouble32();
363 // Prevent the type alias from being reset by returning early
364 return result;
365 } else if (resolvedType == "std::string") {
366 result = std::make_unique<RField<std::string>>(fieldName);
367 } else if (resolvedType == "TObject") {
368 result = std::make_unique<RField<TObject>>(fieldName);
369 } else if (resolvedType == "std::vector<bool>") {
370 result = std::make_unique<RField<std::vector<bool>>>(fieldName);
371 } else if (resolvedType.substr(0, 12) == "std::vector<") {
372 std::string itemTypeName = resolvedType.substr(12, resolvedType.length() - 13);
373 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0));
374 result = std::make_unique<RVectorField>(fieldName, itemField.Unwrap());
375 } else if (resolvedType.substr(0, 19) == "ROOT::VecOps::RVec<") {
376 std::string itemTypeName = resolvedType.substr(19, resolvedType.length() - 20);
377 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0));
378 result = std::make_unique<RRVecField>(fieldName, itemField.Unwrap());
379 } else if (resolvedType.substr(0, 11) == "std::array<") {
380 auto arrayDef = TokenizeTypeList(resolvedType.substr(11, resolvedType.length() - 12));
381 if (arrayDef.size() != 2) {
382 return R__FORWARD_RESULT(fnFail("the template list for std::array must have exactly two elements"));
383 }
385 auto itemField = Create("_0", arrayDef[0], options, desc, maybeGetChildId(0));
386 result = std::make_unique<RArrayField>(fieldName, itemField.Unwrap(), arrayLength);
387 } else if (resolvedType.substr(0, 13) == "std::variant<") {
388 auto innerTypes = TokenizeTypeList(resolvedType.substr(13, resolvedType.length() - 14));
389 std::vector<std::unique_ptr<RFieldBase>> items;
390 items.reserve(innerTypes.size());
391 for (unsigned int i = 0; i < innerTypes.size(); ++i) {
392 items.emplace_back(
393 Create("_" + std::to_string(i), innerTypes[i], options, desc, maybeGetChildId(i)).Unwrap());
394 }
395 result = std::make_unique<RVariantField>(fieldName, std::move(items));
396 } else if (resolvedType.substr(0, 10) == "std::pair<") {
397 auto innerTypes = TokenizeTypeList(resolvedType.substr(10, resolvedType.length() - 11));
398 if (innerTypes.size() != 2) {
399 return R__FORWARD_RESULT(fnFail("the type list for std::pair must have exactly two elements"));
400 }
401 std::array<std::unique_ptr<RFieldBase>, 2> items{
402 Create("_0", innerTypes[0], options, desc, maybeGetChildId(0)).Unwrap(),
403 Create("_1", innerTypes[1], options, desc, maybeGetChildId(1)).Unwrap()};
404 result = std::make_unique<RPairField>(fieldName, std::move(items));
405 } else if (resolvedType.substr(0, 11) == "std::tuple<") {
406 auto innerTypes = TokenizeTypeList(resolvedType.substr(11, resolvedType.length() - 12));
407 std::vector<std::unique_ptr<RFieldBase>> items;
408 items.reserve(innerTypes.size());
409 for (unsigned int i = 0; i < innerTypes.size(); ++i) {
410 items.emplace_back(
411 Create("_" + std::to_string(i), innerTypes[i], options, desc, maybeGetChildId(i)).Unwrap());
412 }
413 result = std::make_unique<RTupleField>(fieldName, std::move(items));
414 } else if (resolvedType.substr(0, 12) == "std::bitset<") {
415 auto size = ParseUIntTypeToken(resolvedType.substr(12, resolvedType.length() - 13));
416 result = std::make_unique<RBitsetField>(fieldName, size);
417 } else if (resolvedType.substr(0, 16) == "std::unique_ptr<") {
418 std::string itemTypeName = resolvedType.substr(16, resolvedType.length() - 17);
419 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
420 auto normalizedInnerTypeName = itemField->GetTypeName();
421 result = std::make_unique<RUniquePtrField>(fieldName, "std::unique_ptr<" + normalizedInnerTypeName + ">",
422 std::move(itemField));
423 } else if (resolvedType.substr(0, 14) == "std::optional<") {
424 std::string itemTypeName = resolvedType.substr(14, resolvedType.length() - 15);
425 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
426 auto normalizedInnerTypeName = itemField->GetTypeName();
427 result = std::make_unique<ROptionalField>(fieldName, "std::optional<" + normalizedInnerTypeName + ">",
428 std::move(itemField));
429 } else if (resolvedType.substr(0, 9) == "std::set<") {
430 std::string itemTypeName = resolvedType.substr(9, resolvedType.length() - 10);
431 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
432 auto normalizedInnerTypeName = itemField->GetTypeName();
433 result =
434 std::make_unique<RSetField>(fieldName, "std::set<" + normalizedInnerTypeName + ">", std::move(itemField));
435 } else if (resolvedType.substr(0, 19) == "std::unordered_set<") {
436 std::string itemTypeName = resolvedType.substr(19, resolvedType.length() - 20);
437 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
438 auto normalizedInnerTypeName = itemField->GetTypeName();
439 result = std::make_unique<RSetField>(fieldName, "std::unordered_set<" + normalizedInnerTypeName + ">",
440 std::move(itemField));
441 } else if (resolvedType.substr(0, 14) == "std::multiset<") {
442 std::string itemTypeName = resolvedType.substr(14, resolvedType.length() - 15);
443 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
444 auto normalizedInnerTypeName = itemField->GetTypeName();
445 result = std::make_unique<RSetField>(fieldName, "std::multiset<" + normalizedInnerTypeName + ">",
446 std::move(itemField));
447 } else if (resolvedType.substr(0, 24) == "std::unordered_multiset<") {
448 std::string itemTypeName = resolvedType.substr(24, resolvedType.length() - 25);
449 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
450 auto normalizedInnerTypeName = itemField->GetTypeName();
451 result = std::make_unique<RSetField>(fieldName, "std::unordered_multiset<" + normalizedInnerTypeName + ">",
452 std::move(itemField));
453 } else if (resolvedType.substr(0, 9) == "std::map<") {
454 auto innerTypes = TokenizeTypeList(resolvedType.substr(9, resolvedType.length() - 10));
455 if (innerTypes.size() != 2) {
456 return R__FORWARD_RESULT(fnFail("the type list for std::map must have exactly two elements"));
457 }
458
459 auto itemField =
460 Create("_0", "std::pair<" + innerTypes[0] + "," + innerTypes[1] + ">", options, desc, maybeGetChildId(0))
461 .Unwrap();
462
463 // We use the type names of subfields of the newly created item fields to create the map's type name to
464 // ensure the inner type names are properly normalized.
465 auto keyTypeName = itemField->GetConstSubfields()[0]->GetTypeName();
466 auto valueTypeName = itemField->GetConstSubfields()[1]->GetTypeName();
467
468 result = std::make_unique<RMapField>(fieldName, "std::map<" + keyTypeName + "," + valueTypeName + ">",
469 std::move(itemField));
470 } else if (resolvedType.substr(0, 19) == "std::unordered_map<") {
471 auto innerTypes = TokenizeTypeList(resolvedType.substr(19, resolvedType.length() - 20));
472 if (innerTypes.size() != 2)
473 return R__FORWARD_RESULT(fnFail("the type list for std::unordered_map must have exactly two elements"));
474
475 auto itemField =
476 Create("_0", "std::pair<" + innerTypes[0] + "," + innerTypes[1] + ">", options, desc, maybeGetChildId(0))
477 .Unwrap();
478
479 // We use the type names of subfields of the newly created item fields to create the map's type name to
480 // ensure the inner type names are properly normalized.
481 auto keyTypeName = itemField->GetConstSubfields()[0]->GetTypeName();
482 auto valueTypeName = itemField->GetConstSubfields()[1]->GetTypeName();
483
484 result = std::make_unique<RMapField>(
485 fieldName, "std::unordered_map<" + keyTypeName + "," + valueTypeName + ">", std::move(itemField));
486 } else if (resolvedType.substr(0, 14) == "std::multimap<") {
487 auto innerTypes = TokenizeTypeList(resolvedType.substr(14, resolvedType.length() - 15));
488 if (innerTypes.size() != 2)
489 return R__FORWARD_RESULT(fnFail("the type list for std::multimap must have exactly two elements"));
490
491 auto itemField =
492 Create("_0", "std::pair<" + innerTypes[0] + "," + innerTypes[1] + ">", options, desc, maybeGetChildId(0))
493 .Unwrap();
494
495 // We use the type names of subfields of the newly created item fields to create the map's type name to
496 // ensure the inner type names are properly normalized.
497 auto keyTypeName = itemField->GetConstSubfields()[0]->GetTypeName();
498 auto valueTypeName = itemField->GetConstSubfields()[1]->GetTypeName();
499
500 result = std::make_unique<RMapField>(fieldName, "std::multimap<" + keyTypeName + "," + valueTypeName + ">",
501 std::move(itemField));
502 } else if (resolvedType.substr(0, 24) == "std::unordered_multimap<") {
503 auto innerTypes = TokenizeTypeList(resolvedType.substr(24, resolvedType.length() - 25));
504 if (innerTypes.size() != 2)
505 return R__FORWARD_RESULT(
506 fnFail("the type list for std::unordered_multimap must have exactly two elements"));
507
508 auto itemField =
509 Create("_0", "std::pair<" + innerTypes[0] + "," + innerTypes[1] + ">", options, desc, maybeGetChildId(0))
510 .Unwrap();
511
512 // We use the type names of subfields of the newly created item fields to create the map's type name to
513 // ensure the inner type names are properly normalized.
514 auto keyTypeName = itemField->GetConstSubfields()[0]->GetTypeName();
515 auto valueTypeName = itemField->GetConstSubfields()[1]->GetTypeName();
516
517 result = std::make_unique<RMapField>(
518 fieldName, "std::unordered_multimap<" + keyTypeName + "," + valueTypeName + ">", std::move(itemField));
519 } else if (resolvedType.substr(0, 12) == "std::atomic<") {
520 std::string itemTypeName = resolvedType.substr(12, resolvedType.length() - 13);
521 auto itemField = Create("_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
522 auto normalizedInnerTypeName = itemField->GetTypeName();
523 result = std::make_unique<RAtomicField>(fieldName, "std::atomic<" + normalizedInnerTypeName + ">",
524 std::move(itemField));
525 } else if (resolvedType.substr(0, 25) == "ROOT::RNTupleCardinality<") {
526 auto innerTypes = TokenizeTypeList(resolvedType.substr(25, resolvedType.length() - 26));
527 if (innerTypes.size() != 1)
528 return R__FORWARD_RESULT(fnFail("invalid cardinality template: " + resolvedType));
530 if (canonicalInnerType == "std::uint32_t") {
531 result = std::make_unique<RField<RNTupleCardinality<std::uint32_t>>>(fieldName);
532 } else if (canonicalInnerType == "std::uint64_t") {
533 result = std::make_unique<RField<RNTupleCardinality<std::uint64_t>>>(fieldName);
534 } else {
535 return R__FORWARD_RESULT(fnFail("invalid cardinality template: " + resolvedType));
536 }
537 }
538
539 if (!result) {
540 auto e = TEnum::GetEnum(resolvedType.c_str());
541 if (e != nullptr) {
542 result = std::make_unique<REnumField>(fieldName, typeName);
543 }
544 }
545
546 if (!result) {
547 auto cl = TClass::GetClass(typeName.c_str());
548
549 if (cl && cl->GetState() > TClass::kForwardDeclared) {
550 createContextGuard.AddClassToStack(resolvedType);
551 if (cl->GetCollectionProxy()) {
552 result = std::make_unique<RProxiedCollectionField>(fieldName, typeName);
553 }
554 // NOTE: if the class is not at least "Interpreted" we currently don't try to construct
555 // the RClassField, as in that case we'd need to fetch the information from the StreamerInfo
556 // rather than from TClass. This might be desirable in the future, but for now in this
557 // situation we rely on field emulation instead.
558 else if (cl->GetState() >= TClass::kInterpreted) {
561 result = std::make_unique<RStreamerField>(fieldName, typeName);
562 } else {
563 result = std::make_unique<RClassField>(fieldName, typeName);
564 }
565 }
566 }
567
568 // If we get here then we failed to meet all the conditions to create a "properly typed" field.
569 // Resort to field emulation if the user asked us to.
570 if (!result && options.GetEmulateUnknownTypes()) {
571 assert(desc);
572 const auto &fieldDesc = desc->GetFieldDescriptor(fieldId);
573 if (fieldDesc.GetStructure() == ENTupleStructure::kRecord) {
574 std::vector<std::unique_ptr<RFieldBase>> memberFields;
575 memberFields.reserve(fieldDesc.GetLinkIds().size());
576 for (auto id : fieldDesc.GetLinkIds()) {
577 const auto &memberDesc = desc->GetFieldDescriptor(id);
578 auto field = Create(memberDesc.GetFieldName(), memberDesc.GetTypeName(), options, desc, id).Unwrap();
579 memberFields.emplace_back(std::move(field));
580 }
581 R__ASSERT(typeName == fieldDesc.GetTypeName());
582 auto recordField =
584 recordField->fTypeAlias = fieldDesc.GetTypeAlias();
585 return recordField;
586 } else if (fieldDesc.GetStructure() == ENTupleStructure::kCollection) {
587 if (fieldDesc.GetLinkIds().size() != 1)
588 throw ROOT::RException(R__FAIL("invalid structure for collection field " + fieldName));
589
590 auto itemFieldId = fieldDesc.GetLinkIds()[0];
591 const auto &itemFieldDesc = desc->GetFieldDescriptor(itemFieldId);
592 auto itemField =
593 Create(itemFieldDesc.GetFieldName(), itemFieldDesc.GetTypeName(), options, desc, itemFieldId)
594 .Unwrap();
595 auto vecField =
597 vecField->fTypeAlias = fieldDesc.GetTypeAlias();
598 return vecField;
599 }
600 }
601 }
602 } catch (const RException &e) {
603 auto error = e.GetError();
604 if (createContext.GetContinueOnError()) {
605 return std::unique_ptr<RFieldBase>(std::make_unique<RInvalidField>(fieldName, typeName, error.GetReport(),
607 } else {
608 return error;
609 }
610 } catch (const std::logic_error &e) {
611 // Integer parsing error
612 if (createContext.GetContinueOnError()) {
613 return std::unique_ptr<RFieldBase>(
614 std::make_unique<RInvalidField>(fieldName, typeName, e.what(), RInvalidField::ECategory::kGeneric));
615 } else {
616 return R__FAIL(e.what());
617 }
618 }
619
620 if (result) {
622 if (normOrigType != result->GetTypeName()) {
623 result->fTypeAlias = normOrigType;
624 }
625 return result;
626 }
627 return R__FORWARD_RESULT(fnFail("unknown type: " + typeName, RInvalidField::ECategory::kUnknownType));
628}
629
635
636std::unique_ptr<ROOT::RFieldBase> ROOT::RFieldBase::Clone(std::string_view newName) const
637{
638 auto clone = CloneImpl(newName);
639 clone->fTypeAlias = fTypeAlias;
640 clone->fOnDiskId = fOnDiskId;
641 clone->fDescription = fDescription;
642 // We can just copy the references because fColumnRepresentatives point into a static structure
643 clone->fColumnRepresentatives = fColumnRepresentatives;
644 return clone;
645}
646
647std::size_t ROOT::RFieldBase::AppendImpl(const void * /* from */)
648{
649 R__ASSERT(false && "A non-simple RField must implement its own AppendImpl");
650 return 0;
651}
652
654{
655 R__ASSERT(false);
656}
657
659{
660 ReadGlobalImpl(fPrincipalColumn->GetGlobalIndex(localIndex), to);
661}
662
664{
665 const auto valueSize = GetValueSize();
666 std::size_t nRead = 0;
667 for (std::size_t i = 0; i < bulkSpec.fCount; ++i) {
668 // Value not needed
669 if (bulkSpec.fMaskReq && !bulkSpec.fMaskReq[i])
670 continue;
671
672 // Value already present
673 if (bulkSpec.fMaskAvail[i])
674 continue;
675
676 Read(bulkSpec.fFirstIndex + i, reinterpret_cast<unsigned char *>(bulkSpec.fValues) + i * valueSize);
677 bulkSpec.fMaskAvail[i] = true;
678 nRead++;
679 }
680 return nRead;
681}
682
684{
685 void *where = operator new(GetValueSize());
686 R__ASSERT(where != nullptr);
687 ConstructValue(where);
688 return where;
689}
690
692{
693 void *obj = CreateObjectRawPtr();
694 return RValue(this, std::shared_ptr<void>(obj, RSharedPtrDeleter(GetDeleter())));
695}
696
697std::vector<ROOT::RFieldBase::RValue> ROOT::RFieldBase::SplitValue(const RValue & /*value*/) const
698{
699 return std::vector<RValue>();
700}
701
702void ROOT::RFieldBase::Attach(std::unique_ptr<ROOT::RFieldBase> child)
703{
704 // Note that during a model update, new fields will be attached to the zero field. The zero field, however,
705 // does not change its inital state because only its sub fields get connected by RPageSink::UpdateSchema.
706 if (fState != EState::kUnconnected)
707 throw RException(R__FAIL("invalid attempt to attach subfield to already connected field"));
708 child->fParent = this;
709 fSubfields.emplace_back(std::move(child));
710}
711
713{
714 std::size_t result = globalIndex;
715 for (auto f = this; f != nullptr; f = f->GetParent()) {
716 auto parent = f->GetParent();
717 if (parent && (parent->GetStructure() == ROOT::ENTupleStructure::kCollection ||
718 parent->GetStructure() == ROOT::ENTupleStructure::kVariant)) {
719 return 0U;
720 }
721 result *= std::max(f->GetNRepetitions(), std::size_t{1U});
722 }
723 return result;
724}
725
726std::vector<ROOT::RFieldBase *> ROOT::RFieldBase::GetMutableSubfields()
727{
728 std::vector<RFieldBase *> result;
729 result.reserve(fSubfields.size());
730 for (const auto &f : fSubfields) {
731 result.emplace_back(f.get());
732 }
733 return result;
734}
735
736std::vector<const ROOT::RFieldBase *> ROOT::RFieldBase::GetConstSubfields() const
737{
738 std::vector<const RFieldBase *> result;
739 result.reserve(fSubfields.size());
740 for (const auto &f : fSubfields) {
741 result.emplace_back(f.get());
742 }
743 return result;
744}
745
747{
748 if (!fAvailableColumns.empty()) {
749 const auto activeRepresentationIndex = fPrincipalColumn->GetRepresentationIndex();
750 for (auto &column : fAvailableColumns) {
751 if (column->GetRepresentationIndex() == activeRepresentationIndex) {
752 column->Flush();
753 }
754 }
755 }
756}
757
759{
760 if (!fAvailableColumns.empty()) {
761 const auto activeRepresentationIndex = fPrincipalColumn->GetRepresentationIndex();
762 for (auto &column : fAvailableColumns) {
763 if (column->GetRepresentationIndex() == activeRepresentationIndex) {
764 column->Flush();
765 } else {
766 column->CommitSuppressed();
767 }
768 }
769 }
770 CommitClusterImpl();
771}
772
774{
775 if (fState != EState::kUnconnected)
776 throw RException(R__FAIL("cannot set field description once field is connected"));
777 fDescription = std::string(description);
778}
779
781{
782 if (fState != EState::kUnconnected)
783 throw RException(R__FAIL("cannot set field ID once field is connected"));
784 fOnDiskId = id;
785}
786
787/// Write the given value into columns. The value object has to be of the same type as the field.
788/// Returns the number of uncompressed bytes written.
789std::size_t ROOT::RFieldBase::Append(const void *from)
790{
791 if (~fTraits & kTraitMappable)
792 return AppendImpl(from);
793
794 fPrincipalColumn->Append(from);
795 return fPrincipalColumn->GetElement()->GetPackedSize();
796}
797
802
804{
805 return RValue(this, objPtr);
806}
807
809{
810 if (fIsSimple) {
811 /// For simple types, ignore the mask and memcopy the values into the destination
812 fPrincipalColumn->ReadV(bulkSpec.fFirstIndex, bulkSpec.fCount, bulkSpec.fValues);
813 std::fill(bulkSpec.fMaskAvail, bulkSpec.fMaskAvail + bulkSpec.fCount, true);
814 return RBulkSpec::kAllSet;
815 }
816
817 return ReadBulkImpl(bulkSpec);
818}
819
821{
822 return fSubfields.empty() ? RSchemaIterator(this, -1) : RSchemaIterator(fSubfields[0].get(), 0);
823}
824
829
831{
832 return fSubfields.empty() ? RConstSchemaIterator(this, -1) : RConstSchemaIterator(fSubfields[0].get(), 0);
833}
834
839
841{
842 return fSubfields.empty() ? RConstSchemaIterator(this, -1) : RConstSchemaIterator(fSubfields[0].get(), 0);
843}
844
849
851{
852 if (fColumnRepresentatives.empty()) {
853 return {GetColumnRepresentations().GetSerializationDefault()};
854 }
855
857 result.reserve(fColumnRepresentatives.size());
858 for (const auto &r : fColumnRepresentatives) {
859 result.emplace_back(r.get());
860 }
861 return result;
862}
863
865{
866 if (fState != EState::kUnconnected)
867 throw RException(R__FAIL("cannot set column representative once field is connected"));
868 const auto &validTypes = GetColumnRepresentations().GetSerializationTypes();
869 fColumnRepresentatives.clear();
870 fColumnRepresentatives.reserve(representatives.size());
871 for (const auto &r : representatives) {
872 auto itRepresentative = std::find(validTypes.begin(), validTypes.end(), r);
873 if (itRepresentative == std::end(validTypes))
874 throw RException(R__FAIL("invalid column representative"));
875
876 // don't add a duplicate representation
877 if (std::find_if(fColumnRepresentatives.begin(), fColumnRepresentatives.end(),
878 [&r](const auto &rep) { return r == rep.get(); }) == fColumnRepresentatives.end())
879 fColumnRepresentatives.emplace_back(*itRepresentative);
880 }
881}
882
885 std::uint16_t representationIndex) const
886{
887 static const ColumnRepresentation_t kEmpty;
888
889 if (fOnDiskId == ROOT::kInvalidDescriptorId)
890 throw RException(R__FAIL("No on-disk field information for `" + GetQualifiedFieldName() + "`"));
891
893 for (const auto &c : desc.GetColumnIterable(fOnDiskId)) {
894 if (c.GetRepresentationIndex() == representationIndex)
895 onDiskTypes.emplace_back(c.GetType());
896 }
897 if (onDiskTypes.empty()) {
898 if (representationIndex == 0) {
899 throw RException(R__FAIL("No on-disk column information for field `" + GetQualifiedFieldName() + "`"));
900 }
901 return kEmpty;
902 }
903
904 for (const auto &t : GetColumnRepresentations().GetDeserializationTypes()) {
905 if (t == onDiskTypes)
906 return t;
907 }
908
909 std::string columnTypeNames;
910 for (const auto &t : onDiskTypes) {
911 if (!columnTypeNames.empty())
912 columnTypeNames += ", ";
914 }
915 throw RException(R__FAIL("On-disk column types {" + columnTypeNames + "} for field `" + GetQualifiedFieldName() +
916 "` cannot be matched to its in-memory type `" + GetTypeName() + "` " +
917 "(representation index: " + std::to_string(representationIndex) + ")"));
918}
919
921{
922 fReadCallbacks.push_back(func);
923 fIsSimple = false;
924 return fReadCallbacks.size() - 1;
925}
926
928{
929 fReadCallbacks.erase(fReadCallbacks.begin() + idx);
930 fIsSimple = (fTraits & kTraitMappable) && !fIsArtificial && fReadCallbacks.empty();
931}
932
958
960{
961 if (dynamic_cast<ROOT::RFieldZero *>(this))
962 throw RException(R__FAIL("invalid attempt to connect zero field to page sink"));
963 if (fState != EState::kUnconnected)
964 throw RException(R__FAIL("invalid attempt to connect an already connected field to a page sink"));
965
966 AutoAdjustColumnTypes(pageSink.GetWriteOptions());
967
968 GenerateColumns();
969 for (auto &column : fAvailableColumns) {
970 // Only the first column of every representation can be a deferred column. In all column representations,
971 // larger column indexes are data columns of collections (string, streamer) and thus
972 // they have no elements on late model extension
973 auto firstElementIndex = (column->GetIndex() == 0) ? EntryToColumnElementIndex(firstEntry) : 0;
974 column->ConnectPageSink(fOnDiskId, pageSink, firstElementIndex);
975 }
976
977 if (HasExtraTypeInfo()) {
978 pageSink.RegisterOnCommitDatasetCallback(
979 [this](ROOT::Internal::RPageSink &sink) { sink.UpdateExtraTypeInfo(GetExtraTypeInfo()); });
980 }
981
982 fState = EState::kConnectedToSink;
983}
984
986{
987 if (dynamic_cast<ROOT::RFieldZero *>(this))
988 throw RException(R__FAIL("invalid attempt to connect zero field to page source"));
989 if (fState != EState::kUnconnected)
990 throw RException(R__FAIL("invalid attempt to connect an already connected field to a page source"));
991
992 if (!fColumnRepresentatives.empty())
993 throw RException(R__FAIL("fixed column representative only valid when connecting to a page sink"));
994 if (!fDescription.empty())
995 throw RException(R__FAIL("setting description only valid when connecting to a page sink"));
996
997 BeforeConnectPageSource(pageSource);
998
999 for (auto &f : fSubfields) {
1000 if (f->GetOnDiskId() == ROOT::kInvalidDescriptorId) {
1001 f->SetOnDiskId(pageSource.GetSharedDescriptorGuard()->FindFieldId(f->GetFieldName(), GetOnDiskId()));
1002 }
1003 f->ConnectPageSource(pageSource);
1004 }
1005
1006 // Do not generate columns nor set fColumnRepresentatives for artificial fields.
1007 if (!fIsArtificial) {
1008 const auto descriptorGuard = pageSource.GetSharedDescriptorGuard();
1009 const ROOT::RNTupleDescriptor &desc = descriptorGuard.GetRef();
1010 GenerateColumns(desc);
1011 if (fColumnRepresentatives.empty()) {
1012 // If we didn't get columns from the descriptor, ensure that we actually expect a field without columns
1013 for (const auto &t : GetColumnRepresentations().GetDeserializationTypes()) {
1014 if (t.empty()) {
1015 fColumnRepresentatives = {t};
1016 break;
1017 }
1018 }
1019 }
1020 R__ASSERT(!fColumnRepresentatives.empty());
1021 if (fOnDiskId != ROOT::kInvalidDescriptorId) {
1022 const auto &fieldDesc = desc.GetFieldDescriptor(fOnDiskId);
1023 fOnDiskTypeVersion = fieldDesc.GetTypeVersion();
1024 if (fieldDesc.GetTypeChecksum().has_value())
1025 fOnDiskTypeChecksum = *fieldDesc.GetTypeChecksum();
1026 }
1027 }
1028 for (auto &column : fAvailableColumns)
1029 column->ConnectPageSource(fOnDiskId, pageSource);
1030
1031 AfterConnectPageSource();
1032
1033 fState = EState::kConnectedToSource;
1034}
1035
1037{
1038 visitor.VisitField(*this);
1039}
size_t fValueSize
dim_t fSize
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
Definition RError.hxx:302
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:300
#define R__LOG_WARNING(...)
Definition RLogger.hxx:358
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 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 id
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 child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
Abstract base class for classes implementing the visitor design pattern.
static const char * GetColumnTypeName(ROOT::ENTupleColumnType type)
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Points to an array of objects with RNTuple I/O support, used for bulk reading.
std::unique_ptr< bool[]> fMaskAvail
Masks invalid values in the array.
std::unique_ptr< RFieldBase::RDeleter > fDeleter
void Reset(RNTupleLocalIndex firstIndex, std::size_t size)
Sets a new range for the bulk.
void * fValues
Cached deleter of fField.
RBulkValues & operator=(const RBulkValues &)=delete
RBulkValues(RFieldBase *field)
void AdoptBuffer(void *buf, std::size_t capacity)
The list of column representations a field can have.
std::vector< ColumnRepresentation_t > Selection_t
A list of column representations.
Selection_t fDeserializationTypes
The union of the serialization types and the deserialization extra types passed during construction.
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
void BindRawPtr(void *rawPtr)
A field translates read and write calls from/to underlying columns to/from tree values.
RSchemaIterator end()
void SetColumnRepresentatives(const RColumnRepresentations::Selection_t &representatives)
Fixes a column representative.
ROOT::Internal::RColumn * fPrincipalColumn
All fields that have columns have a distinct main column.
ROOT::NTupleSize_t EntryToColumnElementIndex(ROOT::NTupleSize_t globalIndex) const
Translate an entry index to a column element index of the principal column and vice versa.
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
virtual void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const
void FlushColumns()
Flushes data from active columns.
virtual void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to)
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
bool fIsSimple
A field qualifies as simple if it is mappable (which implies it has a single principal column),...
RConstSchemaIterator cbegin() const
void AutoAdjustColumnTypes(const ROOT::RNTupleWriteOptions &options)
When connecting a field to a page sink, the field's default column representation is subject to adjus...
std::vector< const RFieldBase * > GetConstSubfields() const
void SetOnDiskId(ROOT::DescriptorId_t id)
void RemoveReadCallback(size_t idx)
std::vector< RFieldBase * > GetMutableSubfields()
static std::vector< RCheckResult > Check(const std::string &fieldName, const std::string &typeName)
Checks if the given type is supported by RNTuple.
RSchemaIterator begin()
size_t AddReadCallback(ReadCallback_t func)
Set a user-defined function to be called after reading a value, giving a chance to inspect and/or mod...
RConstSchemaIterator cend() const
std::size_t fNRepetitions
For fixed sized arrays, the array length.
std::function< void(void *)> ReadCallback_t
std::size_t Append(const void *from)
Write the given value into columns.
RValue CreateValue()
Generates an object of the field's type, wraps it in a shared pointer and returns it as an RValue con...
const ColumnRepresentation_t & EnsureCompatibleColumnTypes(const ROOT::RNTupleDescriptor &desc, std::uint16_t representationIndex) const
Returns the on-disk column types found in the provided descriptor for fOnDiskId and the given represe...
virtual std::vector< RValue > SplitValue(const RValue &value) const
Creates the list of direct child values given an existing value for this field.
std::string GetQualifiedFieldName() const
Returns the field name and parent field names separated by dots (grandparent.parent....
RBulkValues CreateBulk()
Creates a new, initially empty bulk.
void ConnectPageSink(ROOT::Internal::RPageSink &pageSink, ROOT::NTupleSize_t firstEntry=0)
Fields and their columns live in the void until connected to a physical page storage.
std::size_t ReadBulk(const RBulkSpec &bulkSpec)
Returns the number of newly available values, that is the number of bools in bulkSpec....
std::vector< ROOT::ENTupleColumnType > ColumnRepresentation_t
virtual void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to)
std::uint32_t fTraits
Properties of the type that allow for optimizations of collections of that type.
virtual std::size_t AppendImpl(const void *from)
Operations on values of complex types, e.g.
RFieldBase * fParent
Subfields point to their mother field.
RFieldBase(std::string_view name, std::string_view type, ROOT::ENTupleStructure structure, bool isSimple, std::size_t nRepetitions=0)
The constructor creates the underlying column objects and connects them to either a sink or a source.
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
Factory method to resurrect a field from the stored on-disk type information.
std::string fType
The C++ type captured by this field.
RColumnRepresentations::Selection_t GetColumnRepresentatives() const
Returns the fColumnRepresentative pointee or, if unset (always the case for artificial fields),...
@ kTraitTriviallyDestructible
The type is cleaned up just by freeing its memory. I.e. the destructor performs a no-op.
@ kTraitTriviallyConstructible
No constructor needs to be called, i.e.
@ kTraitMappable
A field of a fundamental type that can be directly mapped via RField<T>::Map(), i....
@ kTraitInvalidField
This field is an instance of RInvalidField and can be safely static_cast to it.
ROOT::ENTupleStructure fStructure
The role of this field in the data model structure.
RValue BindValue(std::shared_ptr< void > objPtr)
Creates a value from a memory location with an already constructed object.
void SetDescription(std::string_view description)
std::unique_ptr< RFieldBase > Clone(std::string_view newName) const
Copies the field and its subfields using a possibly new name and a new, unconnected set of columns.
std::string fName
The field name relative to its parent field.
void CommitCluster()
Flushes data from active columns to disk and calls CommitClusterImpl()
void ConnectPageSource(ROOT::Internal::RPageSource &pageSource)
Connects the field and its subfield tree to the given page source.
void * CreateObjectRawPtr() const
Factory method for the field's type. The caller owns the returned pointer.
virtual std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec)
General implementation of bulk read.
The container field for an ntuple model, which itself has no physical representation.
Definition RField.hxx:54
Used in RFieldBase::Check() to record field creation failures.
Definition RField.hxx:72
@ kGeneric
Generic unrecoverable error.
@ kUnknownType
The type given to RFieldBase::Create was unknown.
@ kTypeError
The type given to RFieldBase::Create was invalid.
The on-storage metadata of an RNTuple.
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
RColumnDescriptorIterable GetColumnIterable() const
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Common user-tunable settings for storing RNTuples.
std::uint32_t GetCompression() const
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:198
@ kInterpreted
Definition TClass.h:129
@ kForwardDeclared
Definition TClass.h:127
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2974
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition TEnum.cxx:182
std::vector< std::string > TokenizeTypeList(std::string_view templateType, std::size_t maxArgs=0)
Used in RFieldBase::Create() in order to get the comma-separated list of template types E....
std::unique_ptr< RFieldBase > CreateEmulatedVectorField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField, std::string_view emulatedFromType)
Definition RField.cxx:521
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.
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
void CallCommitClusterOnField(RFieldBase &)
void CallConnectPageSourceOnField(RFieldBase &, ROOT::Internal::RPageSource &)
unsigned long long ParseUIntTypeToken(const std::string &uintToken)
std::unique_ptr< RFieldBase > CreateEmulatedRecordField(std::string_view fieldName, std::vector< std::unique_ptr< RFieldBase > > itemFields, std::string_view emulatedFromType)
Definition RField.cxx:513
ROOT::RResult< std::unique_ptr< ROOT::RFieldBase > > CallFieldBaseCreate(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
ERNTupleSerializationMode GetRNTupleSerializationMode(TClass *cl)
auto MakeAliasedSharedPtr(T *rawPtr)
std::string GetCanonicalTypePrefix(const std::string &typeName)
Applies RNTuple specific type name normalization rules (see specs) that help the string parsing in RF...
void CallFlushColumnsOnField(RFieldBase &)
std::string GetNormalizedUnresolvedTypeName(const std::string &origName)
Applies all RNTuple type normalization rules except typedef resolution.
void CallConnectPageSinkOnField(RFieldBase &, ROOT::Internal::RPageSink &, ROOT::NTupleSize_t firstEntry=0)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
ENTupleStructure
The fields in the RNTuple data model tree can carry different structural information about the type s...
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
Input parameter to RFieldBase::ReadBulk() and RFieldBase::ReadBulkImpl().
Used in the return value of the Check() method.