23class CreateContextGuard;
25 friend class CreateContextGuard;
27 std::vector<std::string> fClassesOnStack;
30 bool fContinueOnError =
false;
33 CreateContext() =
default;
34 bool GetContinueOnError()
const {
return fContinueOnError; }
38class CreateContextGuard {
39 CreateContext &fCreateContext;
40 std::size_t fNOriginalClassesOnStack;
41 bool fOriginalContinueOnError;
44 CreateContextGuard(CreateContext &ctx)
45 : fCreateContext(ctx),
46 fNOriginalClassesOnStack(ctx.fClassesOnStack.
size()),
47 fOriginalContinueOnError(ctx.fContinueOnError)
52 fCreateContext.fClassesOnStack.resize(fNOriginalClassesOnStack);
53 fCreateContext.fContinueOnError = fOriginalContinueOnError;
56 void AddClassToStack(
const std::string &cl)
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));
62 fCreateContext.fClassesOnStack.emplace_back(cl);
65 void SetContinueOnError(
bool value) { fCreateContext.fContinueOnError = value; }
110 deserializationExtraTypes.end());
133 std::swap(
fDeleter, other.fDeleter);
134 std::swap(
fValues, other.fValues);
140 std::swap(
fField, other.fField);
141 std::swap(
fDeleter, other.fDeleter);
142 std::swap(
fValues, other.fValues);
145 std::swap(
fSize, other.fSize);
165 for (std::size_t i = 0; i <
fCapacity; ++i) {
177 throw RException(
R__FAIL(
"invalid attempt to bulk read beyond the adopted buffer"));
183 for (std::size_t i = 0; i <
size; ++i) {
206 fMaskAvail = std::make_unique<bool[]>(capacity);
221std::unique_ptr<void, typename ROOT::RFieldBase::RCreateObjectDeleter<void>::deleter>
225 return std::unique_ptr<void, RCreateObjectDeleter<void>::deleter>(
CreateObjectRawPtr(), gDeleter);
231 bool isSimple, std::size_t nRepetitions)
248 while (parent && !parent->GetFieldName().empty()) {
249 result = parent->GetFieldName() +
"." + result;
250 parent = parent->GetParent();
262std::vector<ROOT::RFieldBase::RCheckResult>
271 std::vector<RCheckResult> result;
272 for (
const auto &
f : fieldZero) {
279 RCheckResult{invalidField.GetQualifiedFieldName(), invalidField.GetTypeName(), invalidField.GetError()});
294 thread_local CreateContext createContext;
295 CreateContextGuard createContextGuard(createContext);
297 createContextGuard.SetContinueOnError(
true);
299 auto fnFail = [&fieldName,
300 &resolvedType](
const std::string &errMsg,
303 if (createContext.GetContinueOnError()) {
304 return std::unique_ptr<RFieldBase>(std::make_unique<RInvalidField>(fieldName, resolvedType, errMsg, cat));
310 if (resolvedType.empty())
311 return R__FORWARD_RESULT(fnFail(
"no type name specified for field '" + fieldName +
"'"));
313 std::unique_ptr<ROOT::RFieldBase> result;
315 const auto maybeGetChildId = [desc, fieldId](
int childId) {
327 if (resolvedType ==
"bool") {
328 result = std::make_unique<RField<bool>>(fieldName);
329 }
else if (resolvedType ==
"char") {
330 result = std::make_unique<RField<char>>(fieldName);
331 }
else if (resolvedType ==
"std::byte") {
332 result = std::make_unique<RField<std::byte>>(fieldName);
333 }
else if (resolvedType ==
"std::int8_t") {
334 result = std::make_unique<RField<std::int8_t>>(fieldName);
335 }
else if (resolvedType ==
"std::uint8_t") {
336 result = std::make_unique<RField<std::uint8_t>>(fieldName);
337 }
else if (resolvedType ==
"std::int16_t") {
338 result = std::make_unique<RField<std::int16_t>>(fieldName);
339 }
else if (resolvedType ==
"std::uint16_t") {
340 result = std::make_unique<RField<std::uint16_t>>(fieldName);
341 }
else if (resolvedType ==
"std::int32_t") {
342 result = std::make_unique<RField<std::int32_t>>(fieldName);
343 }
else if (resolvedType ==
"std::uint32_t") {
344 result = std::make_unique<RField<std::uint32_t>>(fieldName);
345 }
else if (resolvedType ==
"std::int64_t") {
346 result = std::make_unique<RField<std::int64_t>>(fieldName);
347 }
else if (resolvedType ==
"std::uint64_t") {
348 result = std::make_unique<RField<std::uint64_t>>(fieldName);
349 }
else if (resolvedType ==
"float") {
350 result = std::make_unique<RField<float>>(fieldName);
351 }
else if (resolvedType ==
"double") {
352 result = std::make_unique<RField<double>>(fieldName);
353 }
else if (resolvedType ==
"Double32_t") {
354 result = std::make_unique<RField<double>>(fieldName);
358 }
else if (resolvedType ==
"std::string") {
359 result = std::make_unique<RField<std::string>>(fieldName);
360 }
else if (resolvedType ==
"TObject") {
361 result = std::make_unique<RField<TObject>>(fieldName);
362 }
else if (resolvedType ==
"std::vector<bool>") {
363 result = std::make_unique<RField<std::vector<bool>>>(fieldName);
364 }
else if (resolvedType.substr(0, 12) ==
"std::vector<") {
365 std::string itemTypeName = resolvedType.substr(12, resolvedType.length() - 13);
366 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0));
367 result = std::make_unique<RVectorField>(fieldName, itemField.Unwrap());
368 }
else if (resolvedType.substr(0, 19) ==
"ROOT::VecOps::RVec<") {
369 std::string itemTypeName = resolvedType.substr(19, resolvedType.length() - 20);
370 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0));
371 result = std::make_unique<RRVecField>(fieldName, itemField.Unwrap());
372 }
else if (resolvedType.substr(0, 11) ==
"std::array<") {
373 auto arrayDef =
TokenizeTypeList(resolvedType.substr(11, resolvedType.length() - 12));
374 if (arrayDef.size() != 2) {
375 return R__FORWARD_RESULT(fnFail(
"the template list for std::array must have exactly two elements"));
378 auto itemField = Create(
"_0", arrayDef[0], options, desc, maybeGetChildId(0));
379 result = std::make_unique<RArrayField>(fieldName, itemField.Unwrap(), arrayLength);
380 }
else if (resolvedType.substr(0, 13) ==
"std::variant<") {
381 auto innerTypes =
TokenizeTypeList(resolvedType.substr(13, resolvedType.length() - 14));
382 std::vector<std::unique_ptr<RFieldBase>> items;
383 items.reserve(innerTypes.size());
384 for (
unsigned int i = 0; i < innerTypes.size(); ++i) {
386 Create(
"_" + std::to_string(i), innerTypes[i], options, desc, maybeGetChildId(i)).Unwrap());
388 result = std::make_unique<RVariantField>(fieldName, std::move(items));
389 }
else if (resolvedType.substr(0, 10) ==
"std::pair<") {
390 auto innerTypes =
TokenizeTypeList(resolvedType.substr(10, resolvedType.length() - 11));
391 if (innerTypes.size() != 2) {
392 return R__FORWARD_RESULT(fnFail(
"the type list for std::pair must have exactly two elements"));
394 std::array<std::unique_ptr<RFieldBase>, 2> items{
395 Create(
"_0", innerTypes[0], options, desc, maybeGetChildId(0)).Unwrap(),
396 Create(
"_1", innerTypes[1], options, desc, maybeGetChildId(1)).Unwrap()};
397 result = std::make_unique<RPairField>(fieldName, std::move(items));
398 }
else if (resolvedType.substr(0, 11) ==
"std::tuple<") {
399 auto innerTypes =
TokenizeTypeList(resolvedType.substr(11, resolvedType.length() - 12));
400 std::vector<std::unique_ptr<RFieldBase>> items;
401 items.reserve(innerTypes.size());
402 for (
unsigned int i = 0; i < innerTypes.size(); ++i) {
404 Create(
"_" + std::to_string(i), innerTypes[i], options, desc, maybeGetChildId(i)).Unwrap());
406 result = std::make_unique<RTupleField>(fieldName, std::move(items));
407 }
else if (resolvedType.substr(0, 12) ==
"std::bitset<") {
409 result = std::make_unique<RBitsetField>(fieldName,
size);
410 }
else if (resolvedType.substr(0, 16) ==
"std::unique_ptr<") {
411 std::string itemTypeName = resolvedType.substr(16, resolvedType.length() - 17);
412 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
413 result = std::make_unique<RUniquePtrField>(fieldName, std::move(itemField));
414 }
else if (resolvedType.substr(0, 14) ==
"std::optional<") {
415 std::string itemTypeName = resolvedType.substr(14, resolvedType.length() - 15);
416 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
417 result = std::make_unique<ROptionalField>(fieldName, std::move(itemField));
418 }
else if (resolvedType.substr(0, 9) ==
"std::set<") {
419 std::string itemTypeName = resolvedType.substr(9, resolvedType.length() - 10);
420 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
422 }
else if (resolvedType.substr(0, 19) ==
"std::unordered_set<") {
423 std::string itemTypeName = resolvedType.substr(19, resolvedType.length() - 20);
424 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
426 }
else if (resolvedType.substr(0, 14) ==
"std::multiset<") {
427 std::string itemTypeName = resolvedType.substr(14, resolvedType.length() - 15);
428 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
430 }
else if (resolvedType.substr(0, 24) ==
"std::unordered_multiset<") {
431 std::string itemTypeName = resolvedType.substr(24, resolvedType.length() - 25);
432 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
433 auto normalizedInnerTypeName = itemField->GetTypeName();
435 }
else if (resolvedType.substr(0, 9) ==
"std::map<") {
437 if (innerTypes.size() != 2) {
438 return R__FORWARD_RESULT(fnFail(
"the type list for std::map must have exactly two elements"));
441 Create(
"_0",
"std::pair<" + innerTypes[0] +
"," + innerTypes[1] +
">", options, desc, maybeGetChildId(0))
444 }
else if (resolvedType.substr(0, 19) ==
"std::unordered_map<") {
445 auto innerTypes =
TokenizeTypeList(resolvedType.substr(19, resolvedType.length() - 20));
446 if (innerTypes.size() != 2)
447 return R__FORWARD_RESULT(fnFail(
"the type list for std::unordered_map must have exactly two elements"));
449 Create(
"_0",
"std::pair<" + innerTypes[0] +
"," + innerTypes[1] +
">", options, desc, maybeGetChildId(0))
452 }
else if (resolvedType.substr(0, 14) ==
"std::multimap<") {
453 auto innerTypes =
TokenizeTypeList(resolvedType.substr(14, resolvedType.length() - 15));
454 if (innerTypes.size() != 2)
455 return R__FORWARD_RESULT(fnFail(
"the type list for std::multimap must have exactly two elements"));
457 Create(
"_0",
"std::pair<" + innerTypes[0] +
"," + innerTypes[1] +
">", options, desc, maybeGetChildId(0))
460 }
else if (resolvedType.substr(0, 24) ==
"std::unordered_multimap<") {
461 auto innerTypes =
TokenizeTypeList(resolvedType.substr(24, resolvedType.length() - 25));
462 if (innerTypes.size() != 2)
464 fnFail(
"the type list for std::unordered_multimap must have exactly two elements"));
466 Create(
"_0",
"std::pair<" + innerTypes[0] +
"," + innerTypes[1] +
">", options, desc, maybeGetChildId(0))
469 }
else if (resolvedType.substr(0, 12) ==
"std::atomic<") {
470 std::string itemTypeName = resolvedType.substr(12, resolvedType.length() - 13);
471 auto itemField = Create(
"_0", itemTypeName, options, desc, maybeGetChildId(0)).Unwrap();
472 result = std::make_unique<RAtomicField>(fieldName, std::move(itemField));
473 }
else if (resolvedType.substr(0, 25) ==
"ROOT::RNTupleCardinality<") {
474 auto innerTypes =
TokenizeTypeList(resolvedType.substr(25, resolvedType.length() - 26));
475 if (innerTypes.size() != 1)
476 return R__FORWARD_RESULT(fnFail(
"invalid cardinality template: " + resolvedType));
478 if (canonicalInnerType ==
"std::uint32_t") {
479 result = std::make_unique<RField<RNTupleCardinality<std::uint32_t>>>(fieldName);
480 }
else if (canonicalInnerType ==
"std::uint64_t") {
481 result = std::make_unique<RField<RNTupleCardinality<std::uint64_t>>>(fieldName);
483 return R__FORWARD_RESULT(fnFail(
"invalid cardinality template: " + resolvedType));
491 createContextGuard.AddClassToStack(resolvedType);
492 if (cl->GetCollectionProxy()) {
493 result = std::make_unique<RProxiedCollectionField>(fieldName, typeName);
501 result = std::make_unique<ROOT::Experimental::RSoAField>(fieldName, typeName);
504 result = std::make_unique<RStreamerField>(fieldName, typeName);
506 result = std::make_unique<RClassField>(fieldName, typeName);
517 std::vector<std::unique_ptr<RFieldBase>> memberFields;
518 memberFields.reserve(fieldDesc.GetLinkIds().size());
519 for (
auto id : fieldDesc.GetLinkIds()) {
521 auto field =
Create(memberDesc.GetFieldName(), memberDesc.GetTypeName(), options, desc,
id).Unwrap();
522 memberFields.emplace_back(std::move(field));
524 R__ASSERT(typeName == fieldDesc.GetTypeName());
527 recordField->fTypeAlias = fieldDesc.GetTypeAlias();
530 if (fieldDesc.GetLinkIds().size() != 1)
533 auto itemFieldId = fieldDesc.GetLinkIds()[0];
536 Create(itemFieldDesc.GetFieldName(), itemFieldDesc.GetTypeName(), options, desc, itemFieldId)
540 vecField->fTypeAlias = fieldDesc.GetTypeAlias();
549 result = std::make_unique<REnumField>(fieldName, typeName);
553 auto error =
e.GetError();
554 if (createContext.GetContinueOnError()) {
555 return std::unique_ptr<RFieldBase>(std::make_unique<RInvalidField>(fieldName, typeName, error.GetReport(),
560 }
catch (
const std::logic_error &
e) {
562 if (createContext.GetContinueOnError()) {
563 return std::unique_ptr<RFieldBase>(
572 if (normOrigType != result->GetTypeName()) {
573 result->fTypeAlias = normOrigType;
583 return representations;
599 R__ASSERT(
false &&
"A non-simple RField must implement its own AppendImpl");
616 std::size_t nRead = 0;
617 for (std::size_t i = 0; i < bulkSpec.
fCount; ++i) {
649 return std::vector<RValue>();
657 throw RException(
R__FAIL(
"invalid attempt to attach subfield to already connected, non-extensible field"));
659 if (!expectedChildName.empty() && child->GetFieldName() != expectedChildName) {
661 " expected: " + std::string(expectedChildName)));
664 child->fParent =
this;
665 fSubfields.emplace_back(std::move(child));
670 std::size_t result = globalIndex;
671 for (
auto f =
this;
f !=
nullptr;
f =
f->GetParent()) {
672 auto parent =
f->GetParent();
677 result *= std::max(
f->GetNRepetitions(), std::size_t{1U});
684 std::vector<RFieldBase *> result;
687 result.emplace_back(
f.get());
694 std::vector<const RFieldBase *> result;
697 result.emplace_back(
f.get());
705 const auto activeRepresentationIndex =
fPrincipalColumn->GetRepresentationIndex();
707 if (column->GetRepresentationIndex() == activeRepresentationIndex) {
717 const auto activeRepresentationIndex =
fPrincipalColumn->GetRepresentationIndex();
719 if (column->GetRepresentationIndex() == activeRepresentationIndex) {
722 column->CommitSuppressed();
732 throw RException(
R__FAIL(
"cannot set field description once field is connected"));
761 return RValue(
this, objPtr);
820 result.emplace_back(
r.get());
828 throw RException(
R__FAIL(
"cannot set column representative once field is connected"));
832 for (
const auto &
r : representatives) {
833 auto itRepresentative = std::find(validTypes.begin(), validTypes.end(),
r);
834 if (itRepresentative == std::end(validTypes))
846 std::uint16_t representationIndex)
const
855 if (
c.GetRepresentationIndex() == representationIndex)
856 onDiskTypes.emplace_back(
c.GetType());
858 if (onDiskTypes.empty()) {
859 if (representationIndex == 0) {
866 if (t == onDiskTypes)
870 std::string columnTypeNames;
871 for (
const auto &t : onDiskTypes) {
872 if (!columnTypeNames.empty())
873 columnTypeNames +=
", ";
877 "` cannot be matched to its in-memory type `" +
GetTypeName() +
"` " +
878 "(representation index: " + std::to_string(representationIndex) +
")"));
898 for (
auto &colType : rep) {
925 throw RException(
R__FAIL(
"invalid attempt to connect an already connected field to a page sink"));
935 column->ConnectPageSink(
fOnDiskId, pageSink, firstElementIndex);
950 f->ConnectPageSource(pageSource);
955 throw RException(
R__FAIL(
"invalid attempt to connect an already connected field to a page source"));
958 throw RException(
R__FAIL(
"fixed column representative only valid when connecting to a page sink"));
960 throw RException(
R__FAIL(
"setting description only valid when connecting to a page sink"));
981 if (
typeid(*itr) ==
typeid(
RFieldZero) &&
static_cast<const RFieldZero *
>(itr)->GetAllowFieldSubstitutions()) {
982 for (
auto &
f :
fParent->fSubfields) {
986 f = std::move(substitute);
987 f->ConnectPageSource(pageSource);
1005 f->ConnectPageSource(pageSource);
1026 if (fieldDesc.GetTypeChecksum().has_value())
1031 column->ConnectPageSource(
fOnDiskId, pageSource);
1051 std::ostringstream errMsg;
1053 <<
"with on-disk field " << fieldDesc.GetFieldName() <<
":";
1055 errMsg <<
" field version " <<
GetFieldVersion() <<
" vs. " << fieldDesc.GetFieldVersion() <<
";";
1058 errMsg <<
" type version " <<
GetTypeVersion() <<
" vs. " << fieldDesc.GetTypeVersion() <<
";";
1061 errMsg <<
" structural role " <<
GetStructure() <<
" vs. " << fieldDesc.GetStructure() <<
";";
1064 errMsg <<
" incompatible on-disk type name " << fieldDesc.GetTypeName() <<
";";
1067 errMsg <<
" repetition count " <<
GetNRepetitions() <<
" vs. " << fieldDesc.GetNRepetitions() <<
";";
1081 const std::vector<std::string> &prefixes)
const
1084 for (
const auto &p : prefixes) {
1085 if (fieldDesc.GetTypeName().rfind(p, 0) == 0)
1094 std::uint32_t diffBits = 0;
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Abstract base class for classes implementing the visitor design pattern.
virtual void VisitField(const ROOT::RFieldBase &field)=0
static const char * GetColumnTypeName(ROOT::ENTupleColumnType type)
Abstract interface to write data into an ntuple.
void RegisterOnCommitDatasetCallback(Callback_t callback)
The registered callback is executed at the beginning of CommitDataset();.
const ROOT::RNTupleWriteOptions & GetWriteOptions() const
Returns the sink's write options.
virtual void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &extraTypeInfo)=0
Adds an extra type information record to schema.
const ROOT::RNTupleDescriptor & GetRef() const
Abstract interface to read data from an ntuple.
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
Template specializations for C++ std::atomic.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
void ConstructValue(void *where) const final
size_t GetValueSize() const final
std::unique_ptr< RDeleter > GetDeleter() const final
Base class for all ROOT issued exceptions.
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 * GetValuePtrAt(std::size_t idx) const
std::size_t fNValidValues
The sum of non-zero elements in the fMask.
bool fIsAdopted
True if the user provides the memory buffer for fValues.
void Reset(RNTupleLocalIndex firstIndex, std::size_t size)
Sets a new range for the bulk.
void * fValues
Cached deleter of fField.
std::size_t fCapacity
The size of the array memory block in number of values.
std::size_t fValueSize
Cached copy of RFieldBase::GetValueSize().
RFieldBase * fField
The field that created the array of values.
RBulkValues & operator=(const RBulkValues &)=delete
RBulkValues(RFieldBase *field)
std::size_t fSize
The number of available values in the array (provided their mask is set).
void AdoptBuffer(void *buf, std::size_t capacity)
RNTupleLocalIndex fFirstIndex
Index of the first value of the array.
The list of column representations a field can have.
Selection_t fSerializationTypes
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.
std::shared_ptr< void > fObjPtr
Set by Bind() or by RFieldBase::CreateValue(), RFieldBase::SplitValue() or RFieldBase::BindValue().
void BindRawPtr(void *rawPtr)
A field translates read and write calls from/to underlying columns to/from tree values.
ROOT::DescriptorId_t fOnDiskId
ROOT::ENTupleStructure GetStructure() const
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
void Attach(std::unique_ptr< RFieldBase > child, std::string_view expectedChildName="")
Add a new subfield to the list of nested fields.
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.
virtual void ReconcileOnDiskField(const RNTupleDescriptor &desc)
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
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.
virtual void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const
void FlushColumns()
Flushes data from active columns.
virtual void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to)
std::vector< std::unique_ptr< RFieldBase > > fSubfields
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
std::unique_ptr< T, typename RCreateObjectDeleter< T >::deleter > CreateObject() const
Generates an object of the field type and allocates new initialized memory according to the type.
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)
@ 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.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponding to the field type ...
const RFieldBase * GetParent() const
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.
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...
RResult< void > EnsureMatchingOnDiskCollection(const RNTupleDescriptor &desc) const
Convenience wrapper for the common case of calling EnsureMatchinOnDiskField() for collections.
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...
RSchemaIteratorTemplate< false > RSchemaIterator
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.
const std::string & GetFieldName() const
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
std::vector< ReadCallback_t > fReadCallbacks
List of functions to be called after reading a value.
RResult< void > EnsureMatchingOnDiskField(const RNTupleDescriptor &desc, std::uint32_t ignoreBits=0) const
Compares the field to the corresponding on-disk field information in the provided descriptor.
virtual void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to)
virtual void CommitClusterImpl()
std::vector< std::reference_wrapper< const ColumnRepresentation_t > > fColumnRepresentatives
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.
std::vector< std::unique_ptr< ROOT::Internal::RColumn > > fAvailableColumns
The columns are connected either to a sink or to a source (not to both); they are owned by the 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.
virtual std::uint32_t GetFieldVersion() const
Indicates an evolution of the mapping scheme from C++ type to columns.
virtual std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &)
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
std::uint32_t CompareOnDiskField(const RFieldDescriptor &fieldDesc, std::uint32_t ignoreBits) const
Returns a combination of kDiff... flags, indicating peroperties that are different between the field ...
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),...
RSchemaIteratorTemplate< true > RConstSchemaIterator
std::size_t GetNRepetitions() const
std::uint32_t fOnDiskTypeChecksum
TClass checksum cached from the descriptor after a call to ConnectPageSource().
const std::string & GetTypeName() const
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)
ROOT::DescriptorId_t GetOnDiskId() const
std::uint32_t fOnDiskTypeVersion
C++ type version cached from the descriptor after a call to ConnectPageSource().
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.
RResult< void > EnsureMatchingTypePrefix(const RNTupleDescriptor &desc, const std::vector< std::string > &prefixes) const
Many fields accept a range of type prefixes for schema evolution, e.g.
virtual ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo() const
virtual std::uint32_t GetTypeVersion() const
Indicates an evolution of the C++ type itself.
void * CreateObjectRawPtr() const
Factory method for the field's type. The caller owns the returned pointer.
void Read(ROOT::NTupleSize_t globalIndex, void *to)
virtual bool HasExtraTypeInfo() const
bool fIsArtificial
A field that is not backed on disk but computed, e.g.
virtual std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec)
General implementation of bulk read.
bool HasDefaultColumnRepresentative() const
Whether or not an explicit column representative was set.
@ kDiffStructure
The in-memory field and the on-disk field differ in their structural roles.
@ kDiffTypeName
The in-memory field and the on-disk field have different type names.
@ kDiffTypeVersion
The in-memory field and the on-disk field differ in the type version.
@ kDiffFieldVersion
The in-memory field and the on-disk field differ in the field version.
@ kDiffNRepetitions
The in-memory field and the on-disk field have different repetition counts.
Metadata stored for every field of an RNTuple.
std::uint32_t GetFieldVersion() const
ROOT::ENTupleStructure GetStructure() const
const std::vector< ROOT::DescriptorId_t > & GetLinkIds() const
std::uint64_t GetNRepetitions() const
std::uint32_t GetTypeVersion() const
const std::string & GetTypeName() const
The container field for an ntuple model, which itself has no physical representation.
void Attach(std::unique_ptr< RFieldBase > child)
A public version of the Attach method that allows piece-wise construction of the zero field.
Classes with dictionaries that can be inspected by TClass.
Used in RFieldBase::Check() to record field creation failures.
@ 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
ROOT::DescriptorId_t FindFieldId(std::string_view fieldName, ROOT::DescriptorId_t parentId) 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
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
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.
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
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)
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)
std::string GetRNTupleSoARecord(const TClass *cl)
Checks if the "rntuple.SoARecord" class attribute is set in the dictionary.
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)
std::string GetTypeTraceReport(const RFieldBase &field, const RNTupleDescriptor &desc)
Prints the hierarchy of types with their field names and field IDs for the given in-memory field and ...
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.
ERNTupleSerializationMode GetRNTupleSerializationMode(const TClass *cl)
bool IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc)
Tells if the field describes a std::atomic<T> type.
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)
void SetEmulateUnknownTypes(bool v)
void SetReturnInvalidOnError(bool v)
bool GetReturnInvalidOnError() const
bool GetEmulateUnknownTypes() const
Input parameter to RFieldBase::ReadBulk() and RFieldBase::ReadBulkImpl().
static const std::size_t kAllSet
Possible return value of ReadBulk() and ReadBulkImpl(), which indicates that the full bulk range was ...
RNTupleLocalIndex fFirstIndex
Start of the bulk range.
void * fValues
The destination area, which has to be an array of valid objects of the correct type large enough to h...
std::size_t fCount
Size of the bulk range.
bool * fMaskAvail
A bool array of size fCount, indicating the valid values in fValues.
const bool * fMaskReq
A bool array of size fCount, indicating the required values in the requested range.
Used in the return value of the Check() method.
RCreateObjectDeleter< void > deleter