51#include <unordered_set>
73 " cannot be constructed from a class that's not at least Interpreted"));
84 "use RProxiedCollectionField instead"));
95 R__FAIL(field.
GetTypeName() +
" has streamer mode enforced, not supported as native RNTuple class"));
105 if (realMember->GetStreamer()) {
107 " with a custom streamer; not supported natively in RNTuple"));
112TEnum *EnsureValidEnum(std::string_view enumName)
121void EnsureValidAlignment(std::size_t
alignment)
130std::string GetTypeList(std::span<std::unique_ptr<ROOT::RFieldBase>> itemFields,
bool useTypeAliases)
133 for (
size_t i = 0; i < itemFields.size(); ++i) {
134 if (useTypeAliases && !itemFields[i]->GetTypeAlias().empty()) {
135 result += itemFields[i]->GetTypeAlias();
137 result += itemFields[i]->GetTypeName();
153 std::string typePrefix;
172 if (
const auto pairField =
dynamic_cast<const ROOT::RPairField *
>(innerField)) {
173 std::string typePrefix;
181 const auto &items = pairField->GetConstSubfields();
182 std::string
type = typePrefix;
183 for (
int i : {0, 1}) {
184 if (useTypeAliases && !items[i]->GetTypeAlias().empty()) {
185 type += items[i]->GetTypeAlias();
187 type += items[i]->GetTypeName();
209 auto idSourceMember = desc.
FindFieldId(memberName, classFieldId);
211 return idSourceMember;
214 const auto &subFieldName = subFieldDesc.GetFieldName();
215 if (subFieldName.length() > 2 && subFieldName[0] ==
':' && subFieldName[1] ==
'_') {
216 idSourceMember = LookupMember(desc, memberName, subFieldDesc.GetId());
218 return idSourceMember;
228 if (classVersion != GetTypeVersion() ||
className != GetTypeName()) {
230 if (!fStagingClass) {
238 R__ASSERT(
static_cast<unsigned int>(fStagingClass->GetClassVersion()) == classVersion);
245 std::size_t stagingAreaSize = 0;
246 for (
const auto rule : rules) {
248 auto [itr, isNew] = fStagingItems.emplace(source->GetName(),
RStagingItem());
255 const auto memberFieldId = LookupMember(desc, source->
GetName(), classFieldDesc.
GetId());
257 throw RException(
R__FAIL(std::string(
"cannot find on disk rule source member ") + GetTypeName() +
"." +
261 auto memberType = source->GetTypeForDeclaration() + source->GetDimensions();
262 auto memberField = Create(
"" , std::string(memberType)).Unwrap();
263 memberField->SetOnDiskId(memberFieldId);
264 auto fieldZero = std::make_unique<RFieldZero>();
266 fieldZero->Attach(std::move(memberField));
267 stagingItem.
fField = std::move(fieldZero);
269 stagingItem.
fOffset = fStagingClass->GetDataMemberOffset(source->GetName());
273 stagingAreaSize = std::max(stagingAreaSize, stagingItem.
fOffset + stagingItem.
fField->begin()->GetValueSize());
277 if (stagingAreaSize) {
278 R__ASSERT(
static_cast<Int_t>(stagingAreaSize) <= fStagingClass->Size());
280 fStagingArea = std::make_unique<unsigned char[]>(stagingAreaSize);
282 for (
const auto &[
_, si] : fStagingItems) {
283 const auto &memberField = *si.fField->cbegin();
284 if (!(memberField.GetTraits() & kTraitTriviallyConstructible)) {
285 CallConstructValueOn(memberField, fStagingArea.get() + si.fOffset);
295 const auto ruleset =
fClass->GetSchemaRules();
302 rules = ruleset->FindRules(
fClass->GetName(),
fClass->GetClassVersion(),
fClass->GetCheckSum());
305 std::string normalizedName;
312 rules = ruleset->FindRules(normalizedName, fieldDesc->
GetTypeVersion());
318 std::unordered_map<std::string, std::string> sourceNameAndType;
319 std::size_t nskip = 0;
320 for (
auto itr = rules.begin(); itr != rules.end() - nskip;) {
321 const auto rule = *itr;
326 <<
"ignoring I/O customization rule with unsupported type: " << rule->GetRuleType();
327 itr = rules.erase(itr);
331 bool hasConflictingSourceMembers =
false;
333 auto memberType = source->GetTypeForDeclaration() + source->GetDimensions();
334 auto [itrSrc, isNew] = sourceNameAndType.emplace(source->GetName(), memberType);
335 if (!isNew && (itrSrc->second != memberType)) {
337 <<
"ignoring I/O customization rule due to conflicting source member type: " << itrSrc->second <<
" vs. "
338 << memberType <<
" for member " << source->GetName();
339 hasConflictingSourceMembers =
true;
343 if (hasConflictingSourceMembers) {
344 itr = rules.erase(itr);
349 if (rule->GetTarget() ==
nullptr) {
351 if (itr != rules.end() - nskip)
352 std::iter_swap(itr++, rules.end() - nskip);
365 if (func ==
nullptr) {
369 fRuleFuncs.emplace_back(
370 [func, subObjectOffset, stagingClass = fStagingClass, stagingArea = fStagingArea.get()](
void *
target) {
371 TVirtualObject onfileObj{nullptr};
372 onfileObj.fClass = stagingClass;
373 onfileObj.fObject = stagingArea;
374 func(
static_cast<char *
>(
target) + subObjectOffset, &onfileObj);
375 onfileObj.fObject =
nullptr;
381 for (
const auto &func : fRuleFuncs)
389 fSubfieldsInfo(source.fSubfieldsInfo)
405 EnsureValidUserClass(
fClass, *
this,
"RClassField");
416 std::string renormalizedAlias;
424 if (baseClass->GetDelta() < 0) {
426 " virtually inherits from " + baseClass->GetName()));
428 TClass *
c = baseClass->GetClassPointer();
431 fTraits &= subField->GetTraits();
440 if (!dataMember->IsPersistent()) {
449 std::string typeName{dataMember->GetTrueTypeName()};
452 if (dataMember->Property() &
kIsArray) {
453 for (
int dim = 0,
n = dataMember->GetArrayDim(); dim <
n; ++dim) {
454 typeName +=
"[" + std::to_string(dataMember->GetMaxIndex(dim)) +
"]";
460 fTraits &= subField->GetTraits();
469 for (
const auto &[
_, si] : fStagingItems) {
470 if (!(si.fField->GetTraits() & kTraitTriviallyDestructible)) {
471 auto deleter = GetDeleterOf(*si.fField);
472 deleter->operator()(fStagingArea.get() + si.fOffset,
true );
480 fSubfieldsInfo.push_back(info);
486 return std::unique_ptr<RClassField>(
new RClassField(newName, *
this));
491 std::size_t nbytes = 0;
492 for (
unsigned i = 0; i < fSubfields.size(); i++) {
493 nbytes += CallAppendOn(*fSubfields[i],
static_cast<const unsigned char *
>(from) + fSubfieldsInfo[i].fOffset);
500 for (
const auto &[
_, si] : fStagingItems) {
501 CallReadOn(*si.fField, globalIndex, fStagingArea.get() + si.fOffset);
503 for (
unsigned i = 0; i < fSubfields.size(); i++) {
504 CallReadOn(*fSubfields[i], globalIndex,
static_cast<unsigned char *
>(to) + fSubfieldsInfo[i].fOffset);
511 for (
const auto &[
_, si] : fStagingItems) {
512 CallReadOn(*si.fField, localIndex, fStagingArea.get() + si.fOffset);
514 for (
unsigned i = 0; i < fSubfields.size(); i++) {
515 CallReadOn(*fSubfields[i], localIndex,
static_cast<unsigned char *
>(to) + fSubfieldsInfo[i].fOffset);
522 std::vector<const TSchemaRule *> rules;
525 std::unordered_set<std::string> regularSubfields;
528 int nOnDiskBaseClasses = 0;
532 rules = FindRules(
nullptr);
534 SetStagingClass(GetTypeName(), GetTypeVersion());
543 auto substitute = std::make_unique<RStreamerField>(GetFieldName(), GetTypeName());
544 substitute->SetOnDiskId(GetOnDiskId());
548 for (
auto linkId : fieldDesc.GetLinkIds()) {
550 regularSubfields.insert(subFieldDesc.GetFieldName());
551 if (!subFieldDesc.GetFieldName().empty() && subFieldDesc.GetFieldName()[0] ==
':')
552 nOnDiskBaseClasses++;
555 rules = FindRules(&fieldDesc);
564 if (GetTypeName() != descTypeName) {
565 throw RException(
R__FAIL(
"incompatible type name for field " + GetFieldName() +
": " + GetTypeName() +
566 " vs. " + descTypeName));
570 const bool hasSources = std::any_of(rules.begin(), rules.end(), [](
const auto &
r) {
571 return r->GetSource() && (r->GetSource()->GetEntries() > 0);
580 std::uint32_t assignedVersionForOnDiskLayout = fieldDesc.GetTypeVersion();
582 if (fieldDesc.GetTypeVersion() != GetTypeVersion() || *fieldDesc.GetTypeChecksum() !=
fClass->GetCheckSum() ||
583 fieldDesc.GetTypeName() != GetTypeName()) {
586 auto onDiskStreamerInfo = oldCl->FindStreamerInfo(*fieldDesc.GetTypeChecksum());
588 assignedVersionForOnDiskLayout = onDiskStreamerInfo->GetClassVersion();
590 SetStagingClass(fieldDesc.GetTypeName(), assignedVersionForOnDiskLayout);
591 PrepareStagingArea(rules, desc, fieldDesc);
592 for (
auto &[
_, si] : fStagingItems) {
599 for (
const auto rule : rules) {
600 if (!rule->GetTarget())
604 regularSubfields.erase(std::string(
target->GetString()));
609 for (
const auto rule : rules) {
610 AddFuncsFromIORule(rule);
614 int nInMemoryBaseClasses = 0;
615 for (
auto &field : fSubfields) {
617 if (regularSubfields.count(fieldName) == 0) {
618 CallSetArtificialOn(*field);
620 if (!fieldName.empty() && fieldName[0] ==
':')
621 nInMemoryBaseClasses++;
624 if (nInMemoryBaseClasses != 0 && nOnDiskBaseClasses != 0 && nInMemoryBaseClasses != nOnDiskBaseClasses) {
626 R__FAIL(std::string(
"incompatible number of base classes for field ") + GetFieldName() +
": " + GetTypeName() +
627 ", " + std::to_string(nInMemoryBaseClasses) +
628 " base classes in memory "
630 std::to_string(nOnDiskBaseClasses) +
" base classes on-disk\n" +
639 EnsureMatchingOnDiskField(desc, kDiffTypeVersion | kDiffTypeName).ThrowOnError();
652 RDeleter::operator()(objPtr, dtorOnly);
657 std::vector<RValue>
result;
658 auto valuePtr =
value.GetPtr<
void>();
659 auto charPtr =
static_cast<unsigned char *
>(valuePtr.get());
661 for (
unsigned i = 0; i <
fSubfields.size(); i++) {
676 EnsureValidAlignment(align);
708 fSoAMemberOffsets(source.fSoAMemberOffsets)
725 const RSoAField &nestedSoA, std::size_t offsetInParent,
726 const std::function<
RFieldBase *(
const std::string &)> &fnRecordFieldFinder)
747 const auto lenPrefix = nestedSoA.
GetFieldName().length() + strlen(
"._0.");
749 for (std::size_t i = 0; i < nNestedRecordMemberFields; ++i) {
750 const auto fieldNameForMatching =
753 fRecordMemberFields.emplace_back(fnRecordFieldFinder(fieldNameForMatching));
767 std::vector<RFieldBase *> realRecordMemberFields;
769 std::unordered_map<std::string, std::size_t> recordFieldNameToIdx;
772 unsigned int nDirectRecordSubfields = 0;
773 unsigned int nDirectRecordBases = 0;
775 for (
auto itr = fSubfields[0]->begin(), iEnd = fSubfields[0]->end(); itr != iEnd; ++itr) {
776 if (itr->GetParent() == fSubfields[0].get()) {
777 if (itr->GetFieldName()[0] ==
':') {
778 nDirectRecordBases++;
780 nDirectRecordSubfields++;
785 auto qualifiedName = itr->GetFieldName();
786 auto parent = itr->GetParent();
787 while (parent != fSubfields[0].get()) {
788 qualifiedName = parent->GetFieldName() +
"." + qualifiedName;
789 parent = parent->GetParent();
791 recordFieldNameToIdx[qualifiedName] = realRecordMemberFields.size();
793 realRecordMemberFields.emplace_back(&(*itr));
797 const auto *soaBases =
fClass->GetListOfBases();
798 if (soaBases->GetSize() !=
static_cast<Int_t>(nDirectRecordBases)) {
799 throw RException(
R__FAIL(std::string(
"number of base classes don't match between SoA class ") + GetFieldName() +
800 " and its underlying record type"));
802 unsigned int baseIdx = 0;
804 if (base->GetDelta() < 0) {
805 throw RException(
R__FAIL(std::string(
"virtual inheritance is not supported: ") + GetTypeName() +
806 " virtually inherits from " + base->GetName()));
808 TClass *cl = base->GetClassPointer();
810 const auto baseFieldName = std::string(
":_") + std::to_string(baseIdx);
815 auto recordBaseField = realRecordMemberFields[recordFieldNameToIdx[baseFieldName]];
816 if (underlyingBaseTypeName != recordBaseField->GetTypeName()) {
817 throw RException(
R__FAIL(std::string(
"inheritance of SoA class ") + GetFieldName() +
818 " does not match its underlying record type"));
821 std::unique_ptr<RSoAField> soaBaseField;
823 soaBaseField = std::make_unique<RSoAField>(baseFieldName, cl->
GetName());
826 GetFieldName() +
" (" +
e.what() +
")"));
829 GraftNestedMemberFields(*soaBaseField, base->GetDelta(), [&](
const std::string &
name) {
830 return realRecordMemberFields[recordFieldNameToIdx[name]];
833 for (
const RRule &
r : soaBaseField->fRules) {
834 fRules.emplace_back(
r);
835 fRules.back().fOffset += base->GetDelta();
841 unsigned int nMembers = 0;
846 if ((dataMember->Property() &
kIsStatic) || !dataMember->IsPersistent())
849 if (dataMember->Property() &
kIsArray) {
850 throw RException(
R__FAIL(std::string(
"unsupported array type in SoA class: ") + dataMember->GetName()));
853 const std::string typeName{dataMember->GetTrueTypeName()};
856 auto itr = recordFieldNameToIdx.find(dmField->GetFieldName());
857 if (itr == recordFieldNameToIdx.end()) {
858 throw RException(
R__FAIL(std::string(
"unexpected SoA member: ") + dmField->GetFieldName()));
860 auto underlyingField = realRecordMemberFields[itr->second];
861 assert(dmField->GetFieldName() == underlyingField->GetFieldName());
863 if (
auto soaField =
dynamic_cast<RSoAField *
>(dmField.get())) {
865 throw RException(
R__FAIL(std::string(
"nested SoA field ") + soaField->GetQualifiedFieldName() +
" [" +
866 soaField->GetTypeName() +
"] does not match underlying type " +
867 underlyingField->GetTypeName()));
870 GraftNestedMemberFields(*soaField, dataMember->GetOffset(), [&](
const std::string &
name) {
871 return realRecordMemberFields[recordFieldNameToIdx[name]];
874 for (
const RRule &
r : soaField->fRules) {
875 fRules.emplace_back(
r);
876 fRules.back().fOffset += dataMember->GetOffset();
878 }
else if (
auto vecField =
dynamic_cast<RRVecField *
>(dmField.get())) {
879 if (vecField->begin()->GetTypeName() != underlyingField->GetTypeName() ||
880 vecField->begin()->GetTypeAlias() != underlyingField->GetTypeAlias()) {
881 const std::string leftType =
882 vecField->begin()->GetTypeName() +
883 (vecField->begin()->GetTypeAlias().empty() ?
"" :
" [" + vecField->begin()->GetTypeAlias() +
"]");
884 const std::string rightType =
885 underlyingField->GetTypeName() +
886 (underlyingField->GetTypeAlias().empty() ?
"" :
" [" + underlyingField->GetTypeAlias() +
"]");
887 throw RException(
R__FAIL(std::string(
"SoA member type mismatch: ") + vecField->GetFieldName() +
" (" +
888 leftType +
" vs. " + rightType +
")"));
891 fRecordMemberFields.emplace_back(underlyingField);
892 fRecordMemberDeleters.emplace_back(GetDeleterOf(*underlyingField));
893 fSoAMemberOffsets.emplace_back(dataMember->GetOffset());
895 throw RException(
R__FAIL(
"invalid field type in SoA class: " + dmField->GetTypeName()));
900 if (nDirectRecordSubfields != nMembers) {
904 auto schemaRules = FindRules(
nullptr);
905 for (
const auto &
r : schemaRules)
906 fRules.emplace_back(
RRule{
r, 0});
912 EnsureValidUserClass(
fClass, *
this,
"RSoAField");
914 if (recordTypeName.empty()) {
916 " is not marked with the rntupleSoARecord "
917 "dictionary option; cannot create corresponding RSoAField."));
920 Attach(std::make_unique<ROOT::RClassField>(
"_0", recordTypeName));
928 throw RException(
R__FAIL(std::string(
"version mismatch between SoA type and underlying record type: ") +
930 std::to_string(
fSubfields[0]->GetTypeVersion())));
935 std::string renormalizedAlias;
945 return std::unique_ptr<RSoAField>(
new RSoAField(newName, *
this));
955 return representations;
960 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
965 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
970 const std::size_t nSoAMembers = fSoAMemberOffsets.size();
973 for (std::size_t i = 0; i < nSoAMembers; ++i) {
974 const void *rvecPtr =
static_cast<const unsigned char *
>(from) + fSoAMemberOffsets[i];
976 assert(*sizePtr >= 0);
980 if (
static_cast<std::size_t
>(*sizePtr) !=
N) {
981 const auto f = fRecordMemberFields[i];
982 throw RException(
R__FAIL(
"SoA length mismatch for " +
f->GetFieldName() +
": " + std::to_string(*sizePtr) +
983 " vs. " + std::to_string(
N) +
" (expected)"));
988 std::size_t nbytes = 0;
990 for (std::size_t i = 0; i < nSoAMembers; ++i) {
991 const void *rvecPtr =
static_cast<const unsigned char *
>(from) + fSoAMemberOffsets[i];
993 RFieldBase *memberField = fRecordMemberFields[i];
995 GetPrincipalColumnOf(*memberField)->ForWriting()->AppendV(*beginPtr,
N);
996 nbytes +=
N * GetPrincipalColumnOf(*memberField)->GetElement()->GetPackedSize();
998 for (std::size_t j = 0; j <
N; ++j) {
999 nbytes += CallAppendOn(*memberField, *beginPtr + j * memberField->
GetValueSize());
1006 fPrincipalColumn->ForWriting()->Append(&fNWritten);
1007 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1015 fPrincipalColumn->ForReading()->GetCollectionInfo(globalIndex, &collectionStart, &
N);
1017 const auto nSoAMembers = fSoAMemberOffsets.size();
1018 for (std::size_t i = 0; i < nSoAMembers; ++i) {
1019 RFieldBase *memberField = fRecordMemberFields[i];
1021 void *rvecPtr =
static_cast<unsigned char *
>(to) + fSoAMemberOffsets[i];
1028 GetPrincipalColumnOf(*memberField)->ForReading()->ReadV(collectionStart,
N, begin);
1036 if (memberField->
GetTraits() & kTraitTriviallyConstructible) {
1037 std::memset(begin, 0,
N * memberSize);
1040 for (std::size_t j = 0; j <
N; ++j) {
1041 CallReadOn(*memberField, collectionStart + j, begin + (j * memberSize));
1047 InvokeRuleFuncs(to);
1059 const bool hasSources = std::any_of(fRules.begin(), fRules.end(), [](
const auto &
r) {
1060 return r.fRule->GetSource() && (r.fRule->GetSource()->GetEntries() > 0);
1062 const bool hasTargets =
1063 std::any_of(fRules.begin(), fRules.end(), [](
const auto &
r) { return r.fRule->GetTarget(); });
1066 throw RException(
R__FAIL(
"I/O customization rules with sources are currently unsupported for SoA fields (" +
1067 GetTypeName() +
")"));
1071 throw RException(
R__FAIL(
"I/O customization rules with targets are currently unsupported for SoA fields (" +
1072 GetTypeName() +
")"));
1075 for (
const auto &
r : fRules) {
1076 AddFuncsFromIORule(
r.fRule,
r.fOffset);
1084 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1096 fSoAClass->Destructor(objPtr,
true );
1097 RDeleter::operator()(objPtr, dtorOnly);
1106 fSplitFields = std::make_unique<std::vector<std::unique_ptr<ROOT::RFieldBase>>>();
1107 fSplitOffsets = std::make_unique<std::vector<std::size_t>>();
1109 unsigned int baseIdx = 0;
1111 TClass *cl = base->GetClassPointer();
1119 if ((dataMember->Property() &
kIsStatic) || !dataMember->IsPersistent())
1122 const std::string typeName{dataMember->GetTrueTypeName()};
1134 auto valuePtr =
value.GetPtr<
void>();
1135 auto soaPtr =
static_cast<unsigned char *
>(valuePtr.get());
1136 std::vector<RValue> values;
1137 values.reserve(nSplitFields);
1138 for (std::size_t i = 0; i < nSplitFields; ++i) {
1162 EnsureValidAlignment(align);
1184 std::string_view emulatedFromType,
1185 std::string_view underlyingIntType)
1187 return std::unique_ptr<RFieldBase>(
new REnumField(fieldName, emulatedFromType, underlyingIntType));
1191 :
REnumField(fieldName, EnsureValidEnum(enumName))
1223 std::unique_ptr<RFieldBase> intField)
1226 Attach(std::move(intField));
1231 std::string_view underlyingIntType)
1234 auto intField =
Create(
"_0", std::string(underlyingIntType)).Unwrap();
1235 Attach(std::move(intField));
1241 auto newIntField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
1242 return std::unique_ptr<REnumField>(
new REnumField(newName, GetTypeName(), std::move(newIntField)));
1248 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1253 std::vector<RValue>
result;
1254 result.emplace_back(fSubfields[0]->BindValue(
value.GetPtr<
void>()));
1266 :
ROOT::
RRecordField(fieldName,
"std::pair<" + GetTypeList(itemFields, false ) +
">")
1270 const std::string typeAlias =
"std::pair<" + GetTypeList(itemFields,
true ) +
">";
1288 auto firstElem =
c->GetRealData(
"first");
1291 fOffsets.push_back(firstElem->GetThisOffset());
1293 auto secondElem =
c->GetRealData(
"second");
1296 fOffsets.push_back(secondElem->GetThisOffset());
1301 std::array<std::unique_ptr<RFieldBase>, 2> itemClones = {fSubfields[0]->Clone(fSubfields[0]->GetFieldName()),
1302 fSubfields[1]->Clone(fSubfields[1]->GetFieldName())};
1303 return std::unique_ptr<RPairField>(
new RPairField(newName, std::move(itemClones)));
1308 static const std::vector<std::string> prefixes = {
"std::pair<",
"std::tuple<"};
1310 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1311 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
1314 const auto nOnDiskSubfields = fieldDesc.
GetLinkIds().size();
1315 if (nOnDiskSubfields != 2) {
1317 std::to_string(nOnDiskSubfields) +
"\n" +
1333 (ifuncs.
fNext !=
nullptr));
1345 static const std::vector<std::string> supportedStdTypes = {
1346 "std::set<",
"std::unordered_set<",
"std::multiset<",
"std::unordered_multiset<",
1347 "std::map<",
"std::unordered_map<",
"std::multimap<",
"std::unordered_multimap<"};
1348 bool isSupported =
false;
1349 for (
const auto &tn : supportedStdTypes) {
1359 std::string renormalizedAlias;
1366 if (
fProxy->HasPointers())
1367 throw RException(
R__FAIL(
"collection proxies whose value type is a pointer are not supported"));
1378 throw RException(
R__FAIL(
"custom associative collection proxies not supported"));
1380 std::unique_ptr<ROOT::RFieldBase> itemField;
1382 if (
auto valueClass =
fProxy->GetValueClass()) {
1386 switch (
fProxy->GetType()) {
1391 case EDataType::kInt_t: itemField = std::make_unique<RField<Int_t>>(
"_0");
break;
1405 Attach(std::move(itemField));
1412 clone->fItemSize = fItemSize;
1413 clone->Attach(fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1419 std::size_t nbytes = 0;
1423 (fCollectionType ==
kSTLvector ? fItemSize : 0U)}) {
1424 nbytes += CallAppendOn(*fSubfields[0], ptr);
1429 fPrincipalColumn->ForWriting()->Append(&fNWritten);
1430 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1437 fPrincipalColumn->ForReading()->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1445 (fCollectionType ==
kSTLvector || obj != to ? fItemSize : 0U)}) {
1446 CallReadOn(*fSubfields[0], collectionStart + (i++), elementPtr);
1449 fProxy->Commit(obj);
1459 return representations;
1464 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
1469 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
1474 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1485 std::size_t itemSize = fCollectionType ==
kSTLvector ? fItemSize : 0U;
1486 return std::make_unique<RProxiedCollectionDeleter>(fProxy, GetDeleterOf(*fSubfields[0]), itemSize);
1488 return std::make_unique<RProxiedCollectionDeleter>(fProxy);
1492 std::shared_ptr<TVirtualCollectionProxy> proxy)
1493 :
RDeleter(proxy->GetCollectionClass()->GetClassAlignment()), fProxy(std::move(proxy))
1498 std::shared_ptr<TVirtualCollectionProxy> proxy, std::unique_ptr<RDeleter> itemDeleter,
size_t itemSize)
1499 :
RDeleter(proxy->GetCollectionClass()->GetClassAlignment()),
1500 fProxy(std::move(proxy)),
1501 fItemDeleter(std::move(itemDeleter)),
1512 fItemDeleter->operator()(ptr,
true );
1515 fProxy->Destructor(objPtr,
true );
1516 RDeleter::operator()(objPtr, dtorOnly);
1521 std::vector<RValue>
result;
1522 auto valueRawPtr =
value.GetPtr<
void>().get();
1538 const auto align =
fProxy->GetCollectionClass()->GetClassAlignment();
1539 EnsureValidAlignment(align);
1552 EnsureValidClass(BuildMapTypeName(mapType, itemField.get(), false ))),
1556 if (!itemField->GetTypeAlias().empty())
1557 SetTypeAlias(BuildMapTypeName(mapType, itemField.get(),
true ));
1559 auto *itemClass =
fProxy->GetValueClass();
1562 Attach(std::move(itemField),
"_0");
1567 return std::make_unique<RMapField>(newName, fMapType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1572 static const std::vector<std::string> prefixesRegular = {
"std::map<",
"std::unordered_map<"};
1574 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1577 case EMapType::kMap:
1578 case EMapType::kUnorderedMap: EnsureMatchingTypePrefix(desc, prefixesRegular).ThrowOnError();
break;
1589 EnsureValidClass(BuildSetTypeName(setType, *itemField, false ))),
1592 if (!itemField->GetTypeAlias().empty())
1593 SetTypeAlias(BuildSetTypeName(setType, *itemField,
true ));
1597 Attach(std::move(itemField),
"_0");
1602 return std::make_unique<RSetField>(newName, fSetType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1607 static const std::vector<std::string> prefixesRegular = {
"std::set<",
"std::unordered_set<",
"std::map<",
1608 "std::unordered_map<"};
1610 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1613 case ESetType::kSet:
1614 case ESetType::kUnorderedSet: EnsureMatchingTypePrefix(desc, prefixesRegular).ThrowOnError();
break;
1631 RCallbackStreamerInfo fCallbackStreamerInfo;
1635 :
TBufferFile(
mode, bufsize), fCallbackStreamerInfo(std::move(callbackStreamerInfo))
1659 std::string renormalizedAlias;
1683 fClass->Streamer(
const_cast<void *
>(from), buffer);
1685 auto nbytes = buffer.Length();
1686 fAuxiliaryColumn->ForWriting()->AppendV(buffer.Buffer(), buffer.Length());
1688 fPrincipalColumn->ForWriting()->Append(&fIndex);
1689 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1696 fPrincipalColumn->ForReading()->GetCollectionInfo(globalIndex, &collectionStart, &nbytes);
1699 fAuxiliaryColumn->ForReading()->ReadV(collectionStart, nbytes, buffer.
Buffer());
1700 fClass->Streamer(to, buffer);
1710 return representations;
1715 GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>();
1720 GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>(desc);
1731 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1747 RDeleter::operator()(objPtr, dtorOnly);
1763 EnsureValidAlignment(align);
1792 return dataMember->GetOffset();
1817 return std::unique_ptr<RField<TObject>>(
new RField<TObject>(newName, *
this));
1824 auto *obj =
static_cast<const TObject *
>(from);
1829 std::size_t nbytes = 0;
1830 nbytes += CallAppendOn(*fSubfields[0],
reinterpret_cast<const unsigned char *
>(from) + GetOffsetUniqueID());
1832 UInt_t bits = *
reinterpret_cast<const UInt_t *
>(
reinterpret_cast<const unsigned char *
>(from) + GetOffsetBits());
1834 nbytes += CallAppendOn(*fSubfields[1], &bits);
1843 auto *obj =
static_cast<TObject *
>(to);
1848 *
reinterpret_cast<UInt_t *
>(
reinterpret_cast<unsigned char *
>(to) + GetOffsetUniqueID()) = uniqueID;
1852 *
reinterpret_cast<UInt_t *
>(
reinterpret_cast<unsigned char *
>(to) + GetOffsetBits()) = bits;
1858 CallReadOn(*fSubfields[0], globalIndex, &uniqueID);
1859 CallReadOn(*fSubfields[1], globalIndex, &bits);
1860 ReadTObject(to, uniqueID, bits);
1866 CallReadOn(*fSubfields[0], localIndex, &uniqueID);
1867 CallReadOn(*fSubfields[1], localIndex, &bits);
1868 ReadTObject(to, uniqueID, bits);
1888 std::vector<RValue>
result;
1891 auto charPtr =
static_cast<unsigned char *
>(ptr.get());
1892 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(ptr, charPtr + GetOffsetUniqueID())));
1893 result.emplace_back(fSubfields[1]->BindValue(std::shared_ptr<void>(ptr, charPtr + GetOffsetBits())));
1915 :
ROOT::
RRecordField(fieldName,
"std::tuple<" + GetTypeList(itemFields, false ) +
">")
1917 for (
const auto &
f : itemFields) {
1920 const std::string typeAlias =
"std::tuple<" + GetTypeList(itemFields,
true ) +
">";
1936 for (
unsigned i = 0; i <
fSubfields.size(); ++i) {
1937 std::string memberName(
"_" + std::to_string(i));
1938 auto member =
c->GetRealData(memberName.c_str());
1941 fOffsets.push_back(member->GetThisOffset());
1947 std::vector<std::unique_ptr<RFieldBase>> itemClones;
1948 itemClones.reserve(fSubfields.size());
1949 for (
const auto &
f : fSubfields) {
1950 itemClones.emplace_back(
f->Clone(
f->GetFieldName()));
1952 return std::unique_ptr<RTupleField>(
new RTupleField(newName, std::move(itemClones)));
1957 static const std::vector<std::string> prefixes = {
"std::pair<",
"std::tuple<"};
1959 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1960 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
1963 const auto nOnDiskSubfields = fieldDesc.
GetLinkIds().size();
1964 const auto nSubfields = fSubfields.size();
1965 if (nOnDiskSubfields != nSubfields) {
1967 std::to_string(nOnDiskSubfields) +
" vs. " + std::to_string(nSubfields) +
"\n" +
1977constexpr std::size_t GetVariantTagSize()
1980 std::variant<char> t;
1981 constexpr auto sizeOfT =
sizeof(t);
1983 static_assert(sizeOfT == 2 || sizeOfT == 8,
"unsupported std::variant layout");
1984 return sizeOfT == 2 ? 1 : 4;
1987template <std::
size_t VariantSizeT>
1989 using ValueType_t =
typename std::conditional_t<VariantSizeT == 1, std::uint8_t,
1990 typename std::conditional_t<VariantSizeT == 4, std::uint32_t, void>>;
1997 fMaxItemSize(source.fMaxItemSize),
1998 fMaxAlignment(source.fMaxAlignment),
1999 fTagOffset(source.fTagOffset),
2000 fVariantOffset(source.fVariantOffset),
2001 fNWritten(source.fNWritten.
size(), 0)
2004 Attach(
f->Clone(
f->GetFieldName()));
2009 :
ROOT::
RFieldBase(fieldName,
"std::variant<" + GetTypeList(itemFields, false ) +
">",
2012 for (
const auto &
f : itemFields) {
2018 const std::string typeAlias =
"std::variant<" + GetTypeList(itemFields,
true ) +
">";
2022 auto nFields = itemFields.size();
2027 for (
unsigned int i = 0; i < nFields; ++i) {
2030 fTraits &= itemFields[i]->GetTraits();
2031 Attach(std::move(itemFields[i]),
"_" + std::to_string(i));
2042 const auto tagSize = GetVariantTagSize();
2043 const auto padding = tagSize - (
fMaxItemSize % tagSize);
2049 return std::unique_ptr<RVariantField>(
new RVariantField(newName, *
this));
2054 using TagType_t = RVariantTag<GetVariantTagSize()>::ValueType_t;
2055 auto tag = *
reinterpret_cast<const TagType_t *
>(
reinterpret_cast<const unsigned char *
>(variantPtr) + tagOffset);
2056 return (tag == TagType_t(-1)) ? 0 : tag + 1;
2061 using TagType_t = RVariantTag<GetVariantTagSize()>::ValueType_t;
2062 auto tagPtr =
reinterpret_cast<TagType_t *
>(
reinterpret_cast<unsigned char *
>(variantPtr) + tagOffset);
2063 *tagPtr = (tag == 0) ? TagType_t(-1) :
static_cast<TagType_t
>(tag - 1);
2068 auto tag = GetTag(from, fTagOffset);
2069 std::size_t nbytes = 0;
2072 nbytes += CallAppendOn(*fSubfields[tag - 1],
reinterpret_cast<const unsigned char *
>(from) + fVariantOffset);
2073 index = fNWritten[tag - 1]++;
2076 fPrincipalColumn->ForWriting()->Append(&varSwitch);
2084 fPrincipalColumn->ForReading()->GetSwitchInfo(globalIndex, &variantIndex, &tag);
2091 void *varPtr =
reinterpret_cast<unsigned char *
>(to) + fVariantOffset;
2092 CallConstructValueOn(*fSubfields[tag - 1], varPtr);
2093 CallReadOn(*fSubfields[tag - 1], variantIndex, varPtr);
2095 SetTag(to, fTagOffset, tag);
2101 return representations;
2106 GenerateColumnsImpl<ROOT::Internal::RColumnSwitch>();
2111 GenerateColumnsImpl<ROOT::Internal::RColumnSwitch>(desc);
2116 static const std::vector<std::string> prefixes = {
"std::variant<"};
2118 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
2119 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
2122 if (fSubfields.size() != fieldDesc.GetLinkIds().size()) {
2123 throw RException(
R__FAIL(
"number of variants on-disk do not match for " + GetQualifiedFieldName() +
"\n" +
2130 memset(where, 0, GetValueSize());
2131 CallConstructValueOn(*fSubfields[0],
reinterpret_cast<unsigned char *
>(where) + fVariantOffset);
2132 SetTag(where, fTagOffset, 1);
2137 auto tag = GetTag(objPtr, fTagOffset);
2139 fItemDeleters[tag - 1]->operator()(
reinterpret_cast<unsigned char *
>(objPtr) + fVariantOffset,
true );
2141 RDeleter::operator()(objPtr, dtorOnly);
2146 std::vector<std::unique_ptr<RDeleter>> itemDeleters;
2147 itemDeleters.reserve(fSubfields.size());
2148 for (
const auto &
f : fSubfields) {
2149 itemDeleters.emplace_back(GetDeleterOf(*
f));
2151 return std::make_unique<RVariantDeleter>(fTagOffset, fVariantOffset, GetAlignment(), std::move(itemDeleters));
2156 return std::max(fMaxAlignment,
alignof(RVariantTag<GetVariantTagSize()>::ValueType_t));
2162 const auto actualSize = fTagOffset + GetVariantTagSize();
2164 return actualSize + ((padding ==
alignment) ? 0 : padding);
2169 std::fill(fNWritten.begin(), fNWritten.end(), 0);
interop::TCppScope_t fClass
#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.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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 mode
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
Abstract base class for classes implementing the visitor design pattern.
virtual void VisitSoAField(const ROOT::RSoAField &field)
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)
Holds the index and the tag of a kSwitch column.
static std::string SerializeStreamerInfos(const StreamerInfoMap_t &infos)
const ROOT::RNTupleDescriptor & GetConstRef() const
Abstract interface to read data from an ntuple.
void RegisterStreamerInfos()
Builds the streamer info records from the descriptor's extra type info section.
RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
void operator()(void *objPtr, bool dtorOnly) final
RClassDeleter(TClass *cl)
The field for a class with dictionary.
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
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 GetAlignment() const final
What alignof(T) for this type returns.
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
Additional information kept for each entry in fSubfields
void Attach(std::unique_ptr< RFieldBase > child, RSubfieldInfo info)
std::size_t GetValueSize() const final
What sizeof(T) for this type returns.
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
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.
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.
The field for an unscoped or scoped enum with dictionary.
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.
A functor to release the memory acquired by CreateValue() (memory and constructor).
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
A field translates read and write calls from/to underlying columns to/from tree values.
virtual size_t GetValueSize() const =0
What sizeof(T) for this type returns.
void Attach(std::unique_ptr< RFieldBase > child, std::string_view expectedChildName="")
Add a new subfield to the list of nested fields.
std::vector< std::unique_ptr< RFieldBase > > fSubfields
Collections and classes own subfields.
std::vector< const RFieldBase * > GetConstSubfields() const
void SetTypeAlias(std::string_view typeAlias)
Can only be set on unconnected fields.
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
const std::string & GetFieldName() const
@ kTraitEmulatedField
This field is a user defined type that was missing dictionaries and was reconstructed from the on-dis...
@ 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.
@ kTraitSoACollection
The field represents a collection in SoA layout.
@ kTraitTypeChecksum
The TClass checksum is set and valid.
const std::string & GetTypeAlias() const
std::uint32_t fTraits
Properties of the type that allow for optimizations of collections of that type.
bool IsArtificial() const
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
RValue BindValue(std::shared_ptr< void > objPtr)
Creates a value from a memory location with an already constructed object.
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
The container field for an ntuple model, which itself has no physical representation.
std::vector< std::unique_ptr< RFieldBase > > ReleaseSubfields()
Moves all subfields into the returned vector.
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
const std::string & GetName() 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
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy)
void operator()(void *objPtr, bool dtorOnly) final
The field for a class representing a collection of elements via TVirtualCollectionProxy.
std::size_t GetValueSize() const final
What sizeof(T) for this type returns.
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
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::size_t GetAlignment() const final
What alignof(T) for this type returns.
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.
static unsigned char * ResizeRVec(void *rvec, std::size_t nItems, std::size_t itemSize, const RFieldBase *itemField, RDeleter *itemDeleter)
The field for an untyped record.
void AttachItemFields(ContainerT &&itemFields)
std::vector< std::size_t > fOffsets
Base class for fields that are subject to I/O customization rules. Used by the class field and the So...
std::vector< const TSchemaRule * > FindRules(const ROOT::RFieldDescriptor *fieldDesc) const
Given the on-disk information from the page source, find all the I/O customization rules that apply t...
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
ROOT::DescriptorId_t LookupMember(const ROOT::RNTupleDescriptor &desc, std::string_view memberName, ROOT::DescriptorId_t classFieldId) const
Returns the id of member 'name' in the class field given by 'fieldId', or kInvalidDescriptorId if no ...
void AddFuncsFromIORule(const TSchemaRule *rule, std::size_t subObjectOffset=0)
Register post-read functions corresponding to a ROOT I/O customization rules.
RRuleField(std::string_view name, std::string_view type, TClass *classp, ROOT::ENTupleStructure structure)
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...
TClass * fClass
Set by derived class to the TClass instance representing the current in-memory layout.
void InvokeRuleFuncs(void *target)
Apply the I/O rules to the provided in-memory object.
void SetStagingClass(const std::string &className, unsigned int classVersion)
Sets fStagingClass according to the given name and version.
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
The SoA field provides I/O for an in-memory SoA layout linked to an on-disk collection of the underly...
std::unique_ptr< std::mutex > fLockSplitFields
protects the fSplitFields member.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
const std::type_info * GetPolymorphicTypeInfo() const
For polymorphic classes (that declare or inherit at least one virtual method), return the expected dy...
std::vector< RFieldBase * > fRecordMemberFields
Direct access to the member fields of the underlying record.
size_t GetValueSize() const final
What sizeof(T) for this type returns.
std::vector< std::unique_ptr< RDeleter > > fRecordMemberDeleters
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
void CollectRecordMemberFields()
Called during construction, picks up the (nested) member fields of the underlying record type(s) and ...
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReconstructSplitFields() const
std::vector< std::size_t > fSoAMemberOffsets
The offset of the RVec members in the SoA type in the same order as fRecordMemberFields.
RSoAField(std::string_view fieldName, const RSoAField &source)
Used by CloneImpl.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
std::unique_ptr< std::vector< std::size_t > > fSplitOffsets
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 ...
size_t GetAlignment() const final
What alignof(T) for this type returns.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
std::unique_ptr< std::vector< std::unique_ptr< ROOT::RFieldBase > > > fSplitFields
For reading and writing, the RVecs of the SoA class do not have a dedicated field.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
std::uint32_t GetTypeChecksum() const final
Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
void GraftNestedMemberFields(const RSoAField &nestedSoA, std::size_t offsetInParent, const std::function< RFieldBase *(const std::string &)> &fnRecordFieldFinder)
For a nested SoA struct (either as a member of as a base class), use their fRecordMemberFields in thi...
void operator()(void *objPtr, bool dtorOnly) final
RStreamerFieldDeleter(TClass *cl)
The field for a class using ROOT standard streaming.
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...
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
What alignof(T) for this type returns.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
size_t GetValueSize() const final
What sizeof(T) for this type returns.
Template specializations for C++ std::tuple.
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.
void operator()(void *objPtr, bool dtorOnly) final
Template specializations for C++ std::variant.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::size_t GetAlignment() const final
What alignof(T) for this type returns.
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.
std::size_t GetValueSize() const final
What sizeof(T) for this type returns.
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 Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
size_t GetClassAlignment() const
Return the alignment requirement (in bytes) for objects of this class.
void BuildRealData(void *pointer=nullptr, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
const std::type_info * GetTypeInfo() const
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.
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a 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).
Int_t GetClassSize() const
Long_t ClassProperty() const
Return the C++ property of this class, eg.
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)
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
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
The TRealData class manages the effective list of all data members for a given class.
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 TVirtualStreamerInfo * GenerateInfoForPair(const std::string &pairclassname, bool silent, size_t hint_pair_offset, size_t hint_pair_size)=0
Generate the TClass and TStreamerInfo for the requested pair.
virtual Int_t GetNumber() const =0
static TVirtualStreamerInfo * Factory()
Static function returning a pointer to a new TVirtualStreamerInfo object.
virtual TClass * GetClass() 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.
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 ...
std::unique_ptr< RFieldBase > CreateEmulatedEnumField(std::string_view fieldName, std::string_view emulatedFromType, std::string_view underlyingIntType)
ERNTupleSerializationMode GetRNTupleSerializationMode(const TClass *cl)
void EnsureTypedChildField(const RFieldBase &child, const RFieldBase &parent)
Makes sure that the type name is not empty. Used to prevent untyped fields as C++ inner types.
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
constexpr bool IsValidAlignment(std::size_t align) noexcept
Return true if align is a valid C++ alignment value: strictly positive and a power of two.
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.
TVirtualCollectionProxy::Next_t fNext
TVirtualCollectionProxy::CreateIterators_t fCreateIterators
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators
std::unique_ptr< RFieldBase > fField
The field used to read the on-disk data.
std::size_t fOffset
offset in fStagingArea