49#include <unordered_set>
57TClass *EnsureValidClass(std::string_view className)
71 " cannot be constructed from a class that's not at least Interpreted"));
82 "use RProxiedCollectionField instead"));
93 R__FAIL(field.
GetTypeName() +
" has streamer mode enforced, not supported as native RNTuple class"));
103 if (realMember->GetStreamer()) {
105 " with a custom streamer; not supported natively in RNTuple"));
110TEnum *EnsureValidEnum(std::string_view enumName)
122std::string GetTypeList(std::span<std::unique_ptr<ROOT::RFieldBase>> itemFields,
bool useTypeAliases)
125 for (
size_t i = 0; i < itemFields.size(); ++i) {
126 if (useTypeAliases && !itemFields[i]->GetTypeAlias().empty()) {
127 result += itemFields[i]->GetTypeAlias();
129 result += itemFields[i]->GetTypeName();
131 result.push_back(
',');
133 if (result.empty()) {
142 std::string typePrefix;
158 if (
const auto pairField =
dynamic_cast<const ROOT::RPairField *
>(innerField)) {
159 std::string typePrefix;
167 const auto &items = pairField->GetConstSubfields();
168 std::string
type = typePrefix;
169 for (
int i : {0, 1}) {
170 if (useTypeAliases && !items[i]->GetTypeAlias().empty()) {
171 type += items[i]->GetTypeAlias();
173 type += items[i]->GetTypeName();
193 RFieldBase::Attach(f->Clone(f->GetFieldName()));
199 :
RClassField(fieldName, EnsureValidClass(className))
208 EnsureValidUserClass(
fClass, *
this,
"RClassField");
219 std::string renormalizedAlias;
224 const auto *bases =
fClass->GetListOfBases();
227 if (baseClass->GetDelta() < 0) {
229 " virtually inherits from " + baseClass->GetName()));
234 fTraits &= subField->GetTraits();
243 if (!dataMember->IsPersistent()) {
252 std::string typeName{dataMember->GetTrueTypeName()};
255 if (dataMember->Property() &
kIsArray) {
256 for (
int dim = 0,
n = dataMember->GetArrayDim();
dim <
n; ++
dim) {
257 typeName +=
"[" + std::to_string(dataMember->GetMaxIndex(
dim)) +
"]";
263 fTraits &= subField->GetTraits();
275 deleter->operator()(
fStagingArea.get() + si.fOffset,
true );
291 const auto ruleset =
fClass->GetSchemaRules();
298 rules = ruleset->FindRules(
fClass->GetName(),
fClass->GetClassVersion(),
fClass->GetCheckSum());
301 std::string normalizedName;
308 rules = ruleset->FindRules(normalizedName, fieldDesc->
GetTypeVersion());
314 std::unordered_map<std::string, std::string> sourceNameAndType;
315 std::size_t nskip = 0;
316 for (
auto itr = rules.begin(); itr != rules.end() - nskip;) {
317 const auto rule = *itr;
322 <<
"ignoring I/O customization rule with unsupported type: " << rule->GetRuleType();
323 itr = rules.erase(itr);
327 bool hasConflictingSourceMembers =
false;
329 auto memberType = source->GetTypeForDeclaration() + source->GetDimensions();
330 auto [itrSrc, isNew] = sourceNameAndType.emplace(source->GetName(), memberType);
331 if (!isNew && (itrSrc->second != memberType)) {
333 <<
"ignoring I/O customization rule due to conflicting source member type: " << itrSrc->second <<
" vs. "
334 << memberType <<
" for member " << source->GetName();
335 hasConflictingSourceMembers =
true;
339 if (hasConflictingSourceMembers) {
340 itr = rules.erase(itr);
345 if (rule->GetTarget() ==
nullptr) {
347 if (itr != rules.end() - nskip)
348 std::iter_swap(itr++, rules.end() - nskip);
360 return std::unique_ptr<RClassField>(
new RClassField(newName, *
this));
365 std::size_t nbytes = 0;
366 for (
unsigned i = 0; i <
fSubfields.size(); i++) {
377 for (
unsigned i = 0; i <
fSubfields.size(); i++) {
387 for (
unsigned i = 0; i <
fSubfields.size(); i++) {
395 auto idSourceMember = desc.
FindFieldId(memberName, classFieldId);
397 return idSourceMember;
400 const auto subFieldName = subFieldDesc.GetFieldName();
401 if (subFieldName.length() > 2 && subFieldName[0] ==
':' && subFieldName[1] ==
'_') {
402 idSourceMember =
LookupMember(desc, memberName, subFieldDesc.GetId());
404 return idSourceMember;
431 std::size_t stagingAreaSize = 0;
432 for (
const auto rule : rules) {
441 const auto memberFieldId =
LookupMember(desc, source->GetName(), classFieldDesc.
GetId());
447 auto memberType = source->GetTypeForDeclaration() + source->GetDimensions();
448 auto memberField =
Create(
"" , std::string(memberType)).Unwrap();
449 memberField->SetOnDiskId(memberFieldId);
450 auto fieldZero = std::make_unique<RFieldZero>();
452 fieldZero->Attach(std::move(memberField));
453 stagingItem.
fField = std::move(fieldZero);
459 stagingAreaSize = std::max(stagingAreaSize, stagingItem.
fOffset + stagingItem.
fField->begin()->GetValueSize());
463 if (stagingAreaSize) {
466 fStagingArea = std::make_unique<unsigned char[]>(stagingAreaSize);
469 const auto &memberField = *si.fField->cbegin();
480 if (func ==
nullptr) {
485 TVirtualObject onfileObj{nullptr};
486 onfileObj.fClass = stagingClass;
487 onfileObj.fObject = stagingArea;
488 func(
static_cast<char *
>(target), &onfileObj);
489 onfileObj.fObject =
nullptr;
495 std::vector<const TSchemaRule *> rules;
498 std::unordered_set<std::string> regularSubfields;
501 int nOnDiskBaseClasses = 0;
521 for (
auto linkId : fieldDesc.GetLinkIds()) {
523 regularSubfields.insert(subFieldDesc.GetFieldName());
524 if (!subFieldDesc.GetFieldName().empty() && subFieldDesc.GetFieldName()[0] ==
':')
525 nOnDiskBaseClasses++;
539 " vs. " + descTypeName));
543 const bool hasSources = std::any_of(rules.begin(), rules.end(), [](
const auto &
r) {
544 return r->GetSource() && (r->GetSource()->GetEntries() > 0);
554 si.fField = std::move(
static_cast<RFieldZero *
>(si.fField.get())->ReleaseSubfields()[0]);
559 for (
const auto rule : rules) {
560 if (!rule->GetTarget())
564 regularSubfields.erase(std::string(target->GetString()));
569 for (
const auto rule : rules) {
574 int nInMemoryBaseClasses = 0;
577 if (regularSubfields.count(fieldName) == 0) {
580 if (!fieldName.empty() && fieldName[0] ==
':')
581 nInMemoryBaseClasses++;
584 if (nInMemoryBaseClasses != 0 && nOnDiskBaseClasses != 0 && nInMemoryBaseClasses != nOnDiskBaseClasses) {
586 GetTypeName() +
", " + std::to_string(nInMemoryBaseClasses) +
587 " base classes in memory "
589 std::to_string(nOnDiskBaseClasses) +
" base classes on-disk\n" +
608 fClass->Destructor(objPtr,
true );
609 RDeleter::operator()(objPtr, dtorOnly);
614 std::vector<RValue> result;
615 auto valuePtr = value.
GetPtr<
void>();
616 auto charPtr =
static_cast<unsigned char *
>(valuePtr.get());
618 for (
unsigned i = 0; i <
fSubfields.size(); i++) {
627 return fClass->GetClassSize();
632 return fClass->GetClassVersion();
637 return fClass->GetCheckSum();
646 return fClass->GetTypeInfo();
668 :
RSoAField(fieldName, EnsureValidClass(className))
677 static std::once_flag once;
678 std::call_once(once, []() {
682 EnsureValidUserClass(
fSoAClass, *
this,
"RSoAField");
684 if (recordTypeName.empty()) {
686 " is not marked with the rntupleSoARecord "
687 "dictionary option; cannot create corresponding RSoAField."));
690 Attach(std::make_unique<ROOT::RClassField>(
"_0", recordTypeName));
695 if (
static_cast<std::uint32_t
>(
fSoAClass->GetClassVersion()) !=
fSubfields[0]->GetTypeVersion()) {
696 throw RException(
R__FAIL(std::string(
"version mismatch between SoA type and underlying record type: ") +
697 std::to_string(
fSoAClass->GetClassVersion()) +
" vs. " +
698 std::to_string(
fSubfields[0]->GetTypeVersion())));
702 std::unordered_map<std::string, std::size_t> recordFieldNameToIdx;
705 assert(!
f->GetFieldName().empty());
706 if (
f->GetFieldName()[0] ==
':') {
707 throw RException(
R__FAIL(
"SoA fields with inheritance are currently unsupported"));
709 recordFieldNameToIdx[
f->GetFieldName()] = i;
712 const auto *bases =
fSoAClass->GetListOfBases();
715 if (baseClass->GetDelta() < 0) {
717 " virtually inherits from " + baseClass->GetName()));
720 throw RException(
R__FAIL(
"SoA fields with inheritance are currently unsupported"));
724 unsigned int nMembers = 0;
726 if ((dataMember->Property() &
kIsStatic) || !dataMember->IsPersistent())
729 if (dataMember->Property() &
kIsArray) {
730 throw RException(
R__FAIL(std::string(
"unsupported array type in SoA class: ") + dataMember->GetName()));
733 const std::string typeName{dataMember->GetTrueTypeName()};
735 auto vecFieldPtr =
dynamic_cast<RRVecField *
>(subField.get());
737 throw RException(
R__FAIL(
"invalid field type in SoA class: " + subField->GetTypeName()));
740 auto vecField = std::unique_ptr<RRVecField>(vecFieldPtr);
742 auto itr = recordFieldNameToIdx.find(vecField->GetFieldName());
743 if (itr == recordFieldNameToIdx.end()) {
744 throw RException(
R__FAIL(std::string(
"unexpected SoA member: ") + vecField->GetFieldName()));
747 if (vecField->begin()->GetTypeName() != memberField->
GetTypeName() ||
748 vecField->begin()->GetTypeAlias() != memberField->
GetTypeAlias()) {
749 const std::string leftType =
750 vecField->begin()->GetTypeName() +
751 (vecField->begin()->
GetTypeAlias().empty() ?
"" :
" [" + vecField->begin()->GetTypeAlias() +
"]");
752 const std::string rightType =
755 throw RException(
R__FAIL(std::string(
"SoA member type mismatch: ") + vecField->GetFieldName() +
" (" +
756 leftType +
" vs. " + rightType +
")"));
765 if (recordFieldNameToIdx.size() != nMembers) {
769 std::string renormalizedAlias;
778 return std::unique_ptr<RSoAField>(
new RSoAField(newName, *
this));
788 return representations;
806 for (std::size_t i = 0; i < nSoAMembers; ++i) {
807 const void *rvecPtr =
static_cast<const unsigned char *
>(from) +
fSoAMemberOffsets[i];
809 assert(*sizePtr >= 0);
813 if (
static_cast<std::size_t
>(*sizePtr) !=
N) {
815 throw RException(
R__FAIL(
"SoA length mismatch for " +
f->GetFieldName() +
": " + std::to_string(*sizePtr) +
816 " vs. " + std::to_string(
N) +
" (expected)"));
821 std::size_t nbytes = 0;
823 for (std::size_t i = 0; i < nSoAMembers; ++i) {
824 const void *rvecPtr =
static_cast<const unsigned char *
>(from) +
fSoAMemberOffsets[i];
831 for (std::size_t j = 0; j <
N; ++j) {
856 RDeleter::operator()(objPtr, dtorOnly);
862 return std::vector<RValue>();
893 :
REnumField(fieldName, EnsureValidEnum(enumName))
903 throw RException(R__FAIL(GetTypeName() +
" is not supported"));
907 case kBool_t: Attach(std::make_unique<RField<Bool_t>>(
"_0")); break;
908 case kChar_t: Attach(std::make_unique<RField<Char_t>>(
"_0")); break;
909 case kUChar_t: Attach(std::make_unique<RField<UChar_t>>(
"_0")); break;
910 case kShort_t: Attach(std::make_unique<RField<Short_t>>(
"_0")); break;
911 case kUShort_t: Attach(std::make_unique<RField<UShort_t>>(
"_0")); break;
912 case kInt_t: Attach(std::make_unique<RField<Int_t>>(
"_0")); break;
913 case kUInt_t: Attach(std::make_unique<RField<UInt_t>>(
"_0")); break;
914 case kLong_t: Attach(std::make_unique<RField<Long_t>>(
"_0")); break;
915 case kLong64_t: Attach(std::make_unique<RField<Long64_t>>(
"_0")); break;
916 case kULong_t: Attach(std::make_unique<RField<ULong_t>>(
"_0")); break;
917 case kULong64_t: Attach(std::make_unique<RField<ULong64_t>>(
"_0")); break;
918 default: throw RException(R__FAIL(
"Unsupported underlying integral type for enum type " + GetTypeName()));
925 std::unique_ptr<RFieldBase> intField)
928 Attach(std::move(intField));
946 std::vector<RValue> result;
959 :
ROOT::
RRecordField(fieldName,
"std::pair<" + GetTypeList(itemFields, false ) +
">")
961 const std::string typeAlias =
"std::pair<" + GetTypeList(itemFields,
true ) +
">";
973 auto firstElem =
c->GetRealData(
"first");
976 fOffsets.push_back(firstElem->GetThisOffset());
978 auto secondElem =
c->GetRealData(
"second");
981 fOffsets.push_back(secondElem->GetThisOffset());
988 return std::unique_ptr<RPairField>(
new RPairField(newName, std::move(itemClones)));
993 static const std::vector<std::string> prefixes = {
"std::pair<",
"std::tuple<"};
999 const auto nOnDiskSubfields = fieldDesc.
GetLinkIds().size();
1000 if (nOnDiskSubfields != 2) {
1002 std::to_string(nOnDiskSubfields) +
"\n" +
1018 (ifuncs.
fNext !=
nullptr));
1030 static const std::vector<std::string> supportedStdTypes = {
1031 "std::set<",
"std::unordered_set<",
"std::multiset<",
"std::unordered_multiset<",
1032 "std::map<",
"std::unordered_map<",
"std::multimap<",
"std::unordered_multimap<"};
1033 bool isSupported =
false;
1034 for (
const auto &tn : supportedStdTypes) {
1044 std::string renormalizedAlias;
1046 fTypeAlias = renormalizedAlias;
1049 fProperties = fProxy->GetProperties();
1050 fCollectionType = fProxy->GetCollectionType();
1051 if (fProxy->HasPointers())
1052 throw RException(
R__FAIL(
"collection proxies whose value type is a pointer are not supported"));
1054 fIFuncsRead = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(),
true );
1055 fIFuncsWrite = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(),
false );
1063 throw RException(
R__FAIL(
"custom associative collection proxies not supported"));
1065 std::unique_ptr<ROOT::RFieldBase> itemField;
1067 if (
auto valueClass =
fProxy->GetValueClass()) {
1069 itemField = RFieldBase::Create(
"_0", valueClass->GetName()).Unwrap();
1071 switch (fProxy->GetType()) {
1072 case EDataType::kChar_t: itemField = std::make_unique<RField<Char_t>>(
"_0"); break;
1073 case EDataType::kUChar_t: itemField = std::make_unique<RField<UChar_t>>(
"_0"); break;
1074 case EDataType::kShort_t: itemField = std::make_unique<RField<Short_t>>(
"_0"); break;
1075 case EDataType::kUShort_t: itemField = std::make_unique<RField<UShort_t>>(
"_0"); break;
1076 case EDataType::kInt_t: itemField = std::make_unique<RField<Int_t>>(
"_0"); break;
1077 case EDataType::kUInt_t: itemField = std::make_unique<RField<UInt_t>>(
"_0"); break;
1078 case EDataType::kLong_t: itemField = std::make_unique<RField<Long_t>>(
"_0"); break;
1079 case EDataType::kLong64_t: itemField = std::make_unique<RField<Long64_t>>(
"_0"); break;
1080 case EDataType::kULong_t: itemField = std::make_unique<RField<ULong_t>>(
"_0"); break;
1081 case EDataType::kULong64_t: itemField = std::make_unique<RField<ULong64_t>>(
"_0"); break;
1082 case EDataType::kFloat_t: itemField = std::make_unique<RField<Float_t>>(
"_0"); break;
1083 case EDataType::kDouble_t: itemField = std::make_unique<RField<Double_t>>(
"_0"); break;
1084 case EDataType::kBool_t: itemField = std::make_unique<RField<Bool_t>>(
"_0"); break;
1085 default: throw RException(R__FAIL(
"unsupported value type: " + std::to_string(fProxy->GetType())));
1089 fItemSize = itemField->GetValueSize();
1090 Attach(std::move(itemField));
1104 std::size_t nbytes = 0;
1122 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1144 return representations;
1173 return std::make_unique<RProxiedCollectionDeleter>(
fProxy);
1184 fProxy->Destructor(objPtr,
true );
1185 RDeleter::operator()(objPtr, dtorOnly);
1190 std::vector<RValue> result;
1191 auto valueRawPtr = value.
GetPtr<
void>().get();
1209 EnsureValidClass(BuildMapTypeName(mapType, itemField.get(), false ))),
1212 if (!itemField->GetTypeAlias().empty())
1213 fTypeAlias = BuildMapTypeName(mapType, itemField.get(),
true );
1215 auto *itemClass =
fProxy->GetValueClass();
1218 Attach(std::move(itemField),
"_0");
1228 static const std::vector<std::string> prefixesRegular = {
"std::map<",
"std::unordered_map<"};
1245 EnsureValidClass(BuildSetTypeName(setType, *itemField, false ))),
1248 if (!itemField->GetTypeAlias().empty())
1249 fTypeAlias = BuildSetTypeName(setType, *itemField,
true );
1253 Attach(std::move(itemField),
"_0");
1263 static const std::vector<std::string> prefixesRegular = {
"std::set<",
"std::unordered_set<",
"std::map<",
1264 "std::unordered_map<"};
1287 RCallbackStreamerInfo fCallbackStreamerInfo;
1290 TBufferRecStreamer(
TBuffer::EMode mode,
Int_t bufsize, RCallbackStreamerInfo callbackStreamerInfo)
1291 :
TBufferFile(mode, bufsize), fCallbackStreamerInfo(callbackStreamerInfo)
1310 std::string renormalizedAlias;
1333 fClass->Streamer(
const_cast<void *
>(from), buffer);
1335 auto nbytes = buffer.Length();
1346 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nbytes);
1350 fClass->Streamer(to, buffer);
1360 return representations;
1391 fClass->Destructor(objPtr,
true );
1392 RDeleter::operator()(objPtr, dtorOnly);
1407 return std::min(
alignof(std::max_align_t),
GetValueSize());
1412 return fClass->GetClassSize();
1417 return fClass->GetClassVersion();
1422 return fClass->GetCheckSum();
1435 return dataMember->GetOffset();
1460 return std::unique_ptr<RField<TObject>>(
new RField<TObject>(newName, *
this));
1467 auto *obj =
static_cast<const TObject *
>(from);
1472 std::size_t nbytes = 0;
1486 auto *obj =
static_cast<TObject *
>(to);
1495 *
reinterpret_cast<UInt_t *
>(
reinterpret_cast<unsigned char *
>(to) +
GetOffsetBits()) = bits;
1531 std::vector<RValue> result;
1534 auto charPtr =
static_cast<unsigned char *
>(ptr.get());
1558 :
ROOT::
RRecordField(fieldName,
"std::tuple<" + GetTypeList(itemFields, false ) +
">")
1560 const std::string typeAlias =
"std::tuple<" + GetTypeList(itemFields,
true ) +
">";
1576 for (
unsigned i = 0; i <
fSubfields.size(); ++i) {
1577 std::string memberName(
"_" + std::to_string(i));
1578 auto member =
c->GetRealData(memberName.c_str());
1581 fOffsets.push_back(member->GetThisOffset());
1587 std::vector<std::unique_ptr<RFieldBase>> itemClones;
1590 itemClones.emplace_back(
f->Clone(
f->GetFieldName()));
1592 return std::unique_ptr<RTupleField>(
new RTupleField(newName, std::move(itemClones)));
1597 static const std::vector<std::string> prefixes = {
"std::pair<",
"std::tuple<"};
1603 const auto nOnDiskSubfields = fieldDesc.
GetLinkIds().size();
1605 if (nOnDiskSubfields != nSubfields) {
1607 std::to_string(nOnDiskSubfields) +
" vs. " + std::to_string(nSubfields) +
"\n" +
1617constexpr std::size_t GetVariantTagSize()
1620 std::variant<char> t;
1621 constexpr auto sizeOfT =
sizeof(t);
1623 static_assert(sizeOfT == 2 || sizeOfT == 8,
"unsupported std::variant layout");
1624 return sizeOfT == 2 ? 1 : 4;
1627template <std::
size_t VariantSizeT>
1629 using ValueType_t =
typename std::conditional_t<VariantSizeT == 1, std::uint8_t,
1630 typename std::conditional_t<VariantSizeT == 4, std::uint32_t, void>>;
1644 Attach(
f->Clone(
f->GetFieldName()));
1649 :
ROOT::
RFieldBase(fieldName,
"std::variant<" + GetTypeList(itemFields, false ) +
">",
1655 const std::string typeAlias =
"std::variant<" + GetTypeList(itemFields,
true ) +
">";
1659 auto nFields = itemFields.size();
1664 for (
unsigned int i = 0; i < nFields; ++i) {
1667 fTraits &= itemFields[i]->GetTraits();
1668 Attach(std::move(itemFields[i]),
"_" + std::to_string(i));
1679 const auto tagSize = GetVariantTagSize();
1680 const auto padding = tagSize - (
fMaxItemSize % tagSize);
1686 return std::unique_ptr<RVariantField>(
new RVariantField(newName, *
this));
1691 using TagType_t = RVariantTag<GetVariantTagSize()>::ValueType_t;
1692 auto tag = *
reinterpret_cast<const TagType_t *
>(
reinterpret_cast<const unsigned char *
>(variantPtr) + tagOffset);
1693 return (tag == TagType_t(-1)) ? 0 : tag + 1;
1698 using TagType_t = RVariantTag<GetVariantTagSize()>::ValueType_t;
1699 auto tagPtr =
reinterpret_cast<TagType_t *
>(
reinterpret_cast<unsigned char *
>(variantPtr) + tagOffset);
1700 *tagPtr = (tag == 0) ? TagType_t(-1) :
static_cast<TagType_t
>(tag - 1);
1706 std::size_t nbytes = 0;
1728 void *varPtr =
reinterpret_cast<unsigned char *
>(to) +
fVariantOffset;
1738 return representations;
1753 static const std::vector<std::string> prefixes = {
"std::variant<"};
1759 if (
fSubfields.size() != fieldDesc.GetLinkIds().size()) {
1778 RDeleter::operator()(objPtr, dtorOnly);
1783 std::vector<std::unique_ptr<RDeleter>> itemDeleters;
1793 return std::max(
fMaxAlignment,
alignof(RVariantTag<GetVariantTagSize()>::ValueType_t));
1799 const auto actualSize =
fTagOffset + GetVariantTagSize();
1801 return actualSize + ((padding ==
alignment) ? 0 : padding);
#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
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
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.
Abstract base class for classes implementing the visitor design pattern.
virtual void VisitProxiedCollectionField(const ROOT::RProxiedCollectionField &field)
virtual void VisitTObjectField(const ROOT::RField< TObject > &field)
virtual void VisitStreamerField(const ROOT::RStreamerField &field)
virtual void VisitEnumField(const ROOT::REnumField &field)
virtual void VisitClassField(const ROOT::RClassField &field)
void operator()(void *objPtr, bool dtorOnly) final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
std::vector< std::size_t > fSoAMemberOffsets
The offset of the RVec members in the SoA type in the order of subfields of the underlying record typ...
const std::type_info * GetPolymorphicTypeInfo() const
For polymorphic classes (that declare or inherit at least one virtual method), return the expected dy...
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
std::vector< RFieldBase * > fRecordMemberFields
Direct access to the member fields of the underlying record.
RSoAField(std::string_view fieldName, const RSoAField &source)
Used by CloneImpl.
std::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
std::size_t fMaxAlignment
std::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
ROOT::Internal::RColumnIndex fNWritten
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Holds the index and the tag of a kSwitch column.
static std::string SerializeStreamerInfos(const StreamerInfoMap_t &infos)
const ROOT::RNTupleDescriptor & GetRef() const
Abstract interface to read data from an ntuple.
void RegisterStreamerInfos()
Builds the streamer info records from the descriptor's extra type info section.
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
void operator()(void *objPtr, bool dtorOnly) final
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
void AddReadCallbacksFromIORule(const TSchemaRule *rule)
Register post-read callback corresponding to a ROOT I/O customization rules.
TClass * fStagingClass
The TClass instance that corresponds to the staging area.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::size_t fMaxAlignment
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::vector< RSubfieldInfo > fSubfieldsInfo
void Attach(std::unique_ptr< RFieldBase > child, RSubfieldInfo info)
std::unique_ptr< unsigned char[]> fStagingArea
The staging area stores inputs to I/O rules according to the offsets given by the streamer info of "T...
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
std::vector< const TSchemaRule * > FindRules(const ROOT::RFieldDescriptor *fieldDesc)
Given the on-disk information from the page source, find all the I/O customization rules that apply t...
ROOT::DescriptorId_t LookupMember(const ROOT::RNTupleDescriptor &desc, std::string_view memberName, ROOT::DescriptorId_t classFieldId)
Returns the id of member 'name' in the class field given by 'fieldId', or kInvalidDescriptorId if no ...
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
std::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
RClassField(std::string_view fieldName, const RClassField &source)
Used by CloneImpl.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void PrepareStagingArea(const std::vector< const TSchemaRule * > &rules, const ROOT::RNTupleDescriptor &desc, const ROOT::RFieldDescriptor &classFieldId)
If there are rules with inputs (source members), create the staging area according to the TClass inst...
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
const std::type_info * GetPolymorphicTypeInfo() const
For polymorphic classes (that declare or inherit at least one virtual method), return the expected dy...
std::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
std::unordered_map< std::string, RStagingItem > fStagingItems
Lookup staging items by member name.
static constexpr const char * kPrefixInherited
void SetStagingClass(const std::string &className, unsigned int classVersion)
Sets fStagingClass according to the given name and version.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
REnumField(std::string_view fieldName, TEnum *enump)
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
Base class for all ROOT issued exceptions.
The list of column representations a field can have.
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
std::shared_ptr< T > GetPtr() const
A field translates read and write calls from/to underlying columns to/from tree values.
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.
ROOT::Internal::RColumn * fPrincipalColumn
All fields that have columns have a distinct main column.
std::vector< std::unique_ptr< RFieldBase > > fSubfields
Collections and classes own subfields.
std::vector< const RFieldBase * > GetConstSubfields() const
@ kTraitTriviallyDestructible
@ kTraitTriviallyConstructible
@ kTraitSoACollection
The field represents a collection in SoA layout.
@ kTraitTypeChecksum
The TClass checksum is set and valid.
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
static ROOT::Internal::RColumn * GetPrincipalColumnOf(const RFieldBase &other)
Fields may need direct access to the principal column of their subfields, e.g. in RRVecField::ReadBul...
ROOT::Internal::RColumn * fAuxiliaryColumn
Some fields have a second column in its column representation.
RResult< void > EnsureMatchingOnDiskCollection(const RNTupleDescriptor &desc) const
Convenience wrapper for the common case of calling EnsureMatchinOnDiskField() for collections.
static void CallSetArtificialOn(RFieldBase &other)
Allow parents to mark their childs as artificial fields (used in class and record fields).
std::string GetQualifiedFieldName() const
Returns the field name and parent field names separated by dots (grandparent.parent....
const std::string & GetFieldName() const
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.
const std::string & GetTypeAlias() const
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append() and Read() on other (sub)fields.
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::uint32_t GetTraits() const
const std::string & GetTypeName() const
void GenerateColumnsImpl(const ColumnRepresentation_t &representation, std::uint16_t representationIndex)
Helpers for generating columns.
RValue BindValue(std::shared_ptr< void > objPtr)
Creates a value from a memory location with an already constructed object.
static void CallReadOn(RFieldBase &other, RNTupleLocalIndex localIndex, void *to)
ROOT::DescriptorId_t GetOnDiskId() const
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.
static void CallConstructValueOn(const RFieldBase &other, void *where)
Allow derived classes to call ConstructValue(void *) and GetDeleter() on other (sub)fields.
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.
@ 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.
Metadata stored for every field of an RNTuple.
ROOT::DescriptorId_t GetId() const
const std::vector< ROOT::DescriptorId_t > & GetLinkIds() const
std::optional< std::uint32_t > GetTypeChecksum() const
std::uint32_t GetTypeVersion() const
const std::string & GetTypeName() const
void ReadTObject(void *to, UInt_t uniqueID, UInt_t bits)
RField(std::string_view fieldName, const RField< TObject > &source)
Used by CloneImpl().
static std::size_t GetOffsetBits()
static std::size_t GetOffsetUniqueID()
Classes with dictionaries that can be inspected by TClass.
RField(std::string_view name)
RMapField(std::string_view fieldName, EMapType mapType, std::unique_ptr< RFieldBase > itemField)
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
The on-storage metadata of an RNTuple.
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
std::string GetTypeNameForComparison(const RFieldDescriptor &fieldDesc) const
Adjust the type name of the passed RFieldDescriptor for comparison with another renormalized type nam...
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...
Template specializations for C++ std::pair.
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
RPairField(std::string_view fieldName, std::array< std::unique_ptr< RFieldBase >, 2 > itemFields)
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Allows for iterating over the elements of a proxied collection.
static RIteratorFuncs GetIteratorFuncs(TVirtualCollectionProxy *proxy, bool readFromDisk)
std::shared_ptr< TVirtualCollectionProxy > fProxy
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
std::unique_ptr< RDeleter > fItemDeleter
void operator()(void *objPtr, bool dtorOnly) final
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
RProxiedCollectionField(std::string_view fieldName, TClass *classp)
Constructor used when the value type of the collection is not known in advance, i....
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
ROOT::Internal::RColumnIndex fNWritten
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
RCollectionIterableOnce::RIteratorFuncs fIFuncsRead
Two sets of functions to operate on iterators, to be used depending on the access type.
std::shared_ptr< TVirtualCollectionProxy > fProxy
The collection proxy is needed by the deleters and thus defined as a shared pointer.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RDeleter > GetDeleter() const final
void ReconcileOnDiskField(const RNTupleDescriptor &desc) override
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
Template specializations for ROOT's RVec.
RRecordField(std::string_view name, const RRecordField &source)
void AttachItemFields(ContainerT &&itemFields)
std::vector< std::size_t > fOffsets
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RSetField(std::string_view fieldName, ESetType setType, std::unique_ptr< RFieldBase > itemField)
void operator()(void *objPtr, bool dtorOnly) final
ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo() const final
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfos
streamer info records seen during writing
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
ROOT::Internal::RColumnIndex fIndex
number of bytes written in the current cluster
std::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &source) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
RStreamerField(std::string_view fieldName, TClass *classp)
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
RTupleField(std::string_view fieldName, std::vector< std::unique_ptr< RFieldBase > > itemFields)
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
std::size_t fVariantOffset
void operator()(void *objPtr, bool dtorOnly) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
static constexpr std::size_t kMaxVariants
std::vector< ROOT::Internal::RColumnIndex::ValueType > fNWritten
static std::uint8_t GetTag(const void *variantPtr, std::size_t tagOffset)
Extracts the index from an std::variant and transforms it into the 1-based index used for the switch ...
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
size_t fVariantOffset
In the std::variant memory layout, the actual union of types may start at an offset > 0.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RDeleter > GetDeleter() const final
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
size_t fTagOffset
In the std::variant memory layout, at which byte number is the index stored.
RVariantField(std::string_view name, const RVariantField &source)
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
static void SetTag(void *variantPtr, std::size_t tagOffset, std::uint8_t tag)
void CommitClusterImpl() final
ReadFuncPtr_t GetReadFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a read rule).
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
TClass instances represent classes, structs and namespaces in the ROOT type system.
UInt_t GetCheckSum(ECheckSum code=kCurrentCheckSum) const
Call GetCheckSum with validity check.
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
void BuildRealData(void *pointer=nullptr, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
TList * GetListOfRealData() const
Int_t Size() const
Return size of object of this class.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Version_t GetClassVersion() const
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.
All ROOT classes may have RTTI (run time type identification) support added.
The TEnum class implements the enum type.
EDataType GetUnderlyingType() const
Get the underlying integer type of the enum: enum E { kOne }; // ==> int enum F: long; // ==> long Re...
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
@ kIsOnHeap
object is on heap
@ kNotDeleted
object has not been deleted
@ kIsReferenced
if object is referenced by a TRef or TRefArray
RAII helper class that ensures that PushProxy() / PopProxy() are called when entering / leaving a C++...
Defines a common interface to inspect/change the contents of an object that represents a collection.
@ kNeedDelete
The collection contains directly or indirectly (via other collection) some pointers that need explici...
virtual Next_t GetFunctionNext(Bool_t read=kTRUE)=0
Return a pointer to a function that can advance an iterator (see Next_t).
virtual DeleteTwoIterators_t GetFunctionDeleteTwoIterators(Bool_t read=kTRUE)=0
virtual TVirtualCollectionProxy * Generate() const =0
Returns a clean object of the actual class that derives from TVirtualCollectionProxy.
virtual CreateIterators_t GetFunctionCreateIterators(Bool_t read=kTRUE)=0
Return a pointer to a function that can create an iterator pair, where each iterator points to the be...
Abstract Interface class describing Streamer information for one class.
virtual Int_t GetNumber() const =0
TRangeCast< T, false > TRangeStaticCast
TRangeStaticCast is an adapter class that allows the typed iteration through a TCollection.
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
std::tuple< unsigned char **, std::int32_t *, std::int32_t * > GetRVecDataMembers(void *rvecPtr)
Retrieve the addresses of the data members of a generic RVec from a pointer to the beginning of the R...
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
if(pos!=-1) leafTypeName.Remove(pos)
void CallConnectPageSourceOnField(RFieldBase &, ROOT::Internal::RPageSource &)
std::string GetRNTupleSoARecord(const TClass *cl)
Checks if the "rntuple.SoARecord" class attribute is set in the dictionary.
bool NeedsMetaNameAsAlias(const std::string &metaNormalizedName, std::string &renormalizedAlias, bool isArgInTemplatedUserClass=false)
Checks if the meta normalized name is different from the RNTuple normalized name in a way that would ...
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 ...
ERNTupleSerializationMode GetRNTupleSerializationMode(const TClass *cl)
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
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...
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
std::size_t fOffset
offset in fStagingArea
std::unique_ptr< RFieldBase > fField
The field used to read the on-disk data.
TVirtualCollectionProxy::Next_t fNext
TVirtualCollectionProxy::CreateIterators_t fCreateIterators
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators