51#include <unordered_set>
59TClass *EnsureValidClass(std::string_view className)
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()) {
229 fStagingClass =
TClass::GetClass((className + std::string(
"@@") + std::to_string(classVersion)).c_str());
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 fReadCallbacks.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;
383 fSubfieldsInfo(source.fSubfieldsInfo)
392 :
RClassField(fieldName, EnsureValidClass(className))
399 EnsureValidUserClass(
fClass, *
this,
"RClassField");
410 std::string renormalizedAlias;
418 if (baseClass->GetDelta() < 0) {
420 " virtually inherits from " + baseClass->GetName()));
422 TClass *
c = baseClass->GetClassPointer();
425 fTraits &= subField->GetTraits();
434 if (!dataMember->IsPersistent()) {
443 std::string typeName{dataMember->GetTrueTypeName()};
446 if (dataMember->Property() &
kIsArray) {
447 for (
int dim = 0,
n = dataMember->GetArrayDim(); dim <
n; ++dim) {
448 typeName +=
"[" + std::to_string(dataMember->GetMaxIndex(dim)) +
"]";
454 fTraits &= subField->GetTraits();
463 for (
const auto &[
_, si] : fStagingItems) {
464 if (!(si.fField->GetTraits() & kTraitTriviallyDestructible)) {
465 auto deleter = GetDeleterOf(*si.fField);
466 deleter->operator()(fStagingArea.get() + si.fOffset,
true );
474 fSubfieldsInfo.push_back(info);
480 return std::unique_ptr<RClassField>(
new RClassField(newName, *
this));
485 std::size_t nbytes = 0;
486 for (
unsigned i = 0; i < fSubfields.size(); i++) {
487 nbytes += CallAppendOn(*fSubfields[i],
static_cast<const unsigned char *
>(from) + fSubfieldsInfo[i].fOffset);
494 for (
const auto &[
_, si] : fStagingItems) {
495 CallReadOn(*si.fField, globalIndex, fStagingArea.get() + si.fOffset);
497 for (
unsigned i = 0; i < fSubfields.size(); i++) {
498 CallReadOn(*fSubfields[i], globalIndex,
static_cast<unsigned char *
>(to) + fSubfieldsInfo[i].fOffset);
504 for (
const auto &[
_, si] : fStagingItems) {
505 CallReadOn(*si.fField, localIndex, fStagingArea.get() + si.fOffset);
507 for (
unsigned i = 0; i < fSubfields.size(); i++) {
508 CallReadOn(*fSubfields[i], localIndex,
static_cast<unsigned char *
>(to) + fSubfieldsInfo[i].fOffset);
514 std::vector<const TSchemaRule *> rules;
517 std::unordered_set<std::string> regularSubfields;
520 int nOnDiskBaseClasses = 0;
524 rules = FindRules(
nullptr);
526 SetStagingClass(GetTypeName(), GetTypeVersion());
535 auto substitute = std::make_unique<RStreamerField>(GetFieldName(), GetTypeName());
536 substitute->SetOnDiskId(GetOnDiskId());
540 for (
auto linkId : fieldDesc.GetLinkIds()) {
542 regularSubfields.insert(subFieldDesc.GetFieldName());
543 if (!subFieldDesc.GetFieldName().empty() && subFieldDesc.GetFieldName()[0] ==
':')
544 nOnDiskBaseClasses++;
547 rules = FindRules(&fieldDesc);
556 if (GetTypeName() != descTypeName) {
557 throw RException(
R__FAIL(
"incompatible type name for field " + GetFieldName() +
": " + GetTypeName() +
558 " vs. " + descTypeName));
562 const bool hasSources = std::any_of(rules.begin(), rules.end(), [](
const auto &
r) {
563 return r->GetSource() && (r->GetSource()->GetEntries() > 0);
572 std::uint32_t assignedVersionForOnDiskLayout = fieldDesc.GetTypeVersion();
574 if (fieldDesc.GetTypeVersion() != GetTypeVersion() || *fieldDesc.GetTypeChecksum() !=
fClass->GetCheckSum() ||
575 fieldDesc.GetTypeName() != GetTypeName()) {
578 auto onDiskStreamerInfo = oldCl->FindStreamerInfo(*fieldDesc.GetTypeChecksum());
580 assignedVersionForOnDiskLayout = onDiskStreamerInfo->GetClassVersion();
582 SetStagingClass(fieldDesc.GetTypeName(), assignedVersionForOnDiskLayout);
583 PrepareStagingArea(rules, desc, fieldDesc);
584 for (
auto &[
_, si] : fStagingItems) {
591 for (
const auto rule : rules) {
592 if (!rule->GetTarget())
596 regularSubfields.erase(std::string(
target->GetString()));
601 for (
const auto rule : rules) {
602 AddReadCallbacksFromIORule(rule);
606 int nInMemoryBaseClasses = 0;
607 for (
auto &field : fSubfields) {
609 if (regularSubfields.count(fieldName) == 0) {
610 CallSetArtificialOn(*field);
612 if (!fieldName.empty() && fieldName[0] ==
':')
613 nInMemoryBaseClasses++;
616 if (nInMemoryBaseClasses != 0 && nOnDiskBaseClasses != 0 && nInMemoryBaseClasses != nOnDiskBaseClasses) {
618 R__FAIL(std::string(
"incompatible number of base classes for field ") + GetFieldName() +
": " + GetTypeName() +
619 ", " + std::to_string(nInMemoryBaseClasses) +
620 " base classes in memory "
622 std::to_string(nOnDiskBaseClasses) +
" base classes on-disk\n" +
631 EnsureMatchingOnDiskField(desc, kDiffTypeVersion | kDiffTypeName).ThrowOnError();
644 RDeleter::operator()(objPtr, dtorOnly);
649 std::vector<RValue>
result;
650 auto valuePtr =
value.GetPtr<
void>();
651 auto charPtr =
static_cast<unsigned char *
>(valuePtr.get());
653 for (
unsigned i = 0; i <
fSubfields.size(); i++) {
668 EnsureValidAlignment(align);
700 fSoAMemberOffsets(source.fSoAMemberOffsets)
712 :
RSoAField(fieldName, EnsureValidClass(className))
717 const RSoAField &nestedSoA, std::size_t offsetInParent,
718 const std::function<
RFieldBase *(
const std::string &)> &fnRecordFieldFinder)
739 const auto lenPrefix = nestedSoA.
GetFieldName().length() + strlen(
"._0.");
741 for (std::size_t i = 0; i < nNestedRecordMemberFields; ++i) {
742 const auto fieldNameForMatching =
745 fRecordMemberFields.emplace_back(fnRecordFieldFinder(fieldNameForMatching));
759 std::vector<RFieldBase *> realRecordMemberFields;
761 std::unordered_map<std::string, std::size_t> recordFieldNameToIdx;
764 unsigned int nDirectRecordSubfields = 0;
765 unsigned int nDirectRecordBases = 0;
767 for (
auto itr = fSubfields[0]->begin(), iEnd = fSubfields[0]->end(); itr != iEnd; ++itr) {
768 if (itr->GetParent() == fSubfields[0].get()) {
769 if (itr->GetFieldName()[0] ==
':') {
770 nDirectRecordBases++;
772 nDirectRecordSubfields++;
777 auto qualifiedName = itr->GetFieldName();
778 auto parent = itr->GetParent();
779 while (parent != fSubfields[0].get()) {
780 qualifiedName = parent->GetFieldName() +
"." + qualifiedName;
781 parent = parent->GetParent();
783 recordFieldNameToIdx[qualifiedName] = realRecordMemberFields.size();
785 realRecordMemberFields.emplace_back(&(*itr));
789 const auto *soaBases =
fClass->GetListOfBases();
790 if (soaBases->GetSize() !=
static_cast<Int_t>(nDirectRecordBases)) {
791 throw RException(
R__FAIL(std::string(
"number of base classes don't match between SoA class ") + GetFieldName() +
792 " and its underlying record type"));
794 unsigned int baseIdx = 0;
796 if (base->GetDelta() < 0) {
797 throw RException(
R__FAIL(std::string(
"virtual inheritance is not supported: ") + GetTypeName() +
798 " virtually inherits from " + base->GetName()));
800 TClass *cl = base->GetClassPointer();
802 const auto baseFieldName = std::string(
":_") + std::to_string(baseIdx);
807 auto recordBaseField = realRecordMemberFields[recordFieldNameToIdx[baseFieldName]];
808 if (underlyingBaseTypeName != recordBaseField->GetTypeName()) {
809 throw RException(
R__FAIL(std::string(
"inheritance of SoA class ") + GetFieldName() +
810 " does not match its underlying record type"));
813 std::unique_ptr<RSoAField> soaBaseField;
815 soaBaseField = std::make_unique<RSoAField>(baseFieldName, cl->
GetName());
818 GetFieldName() +
" (" +
e.what() +
")"));
821 GraftNestedMemberFields(*soaBaseField, base->GetDelta(), [&](
const std::string &
name) {
822 return realRecordMemberFields[recordFieldNameToIdx[name]];
825 for (
const RRule &
r : soaBaseField->fRules) {
826 fRules.emplace_back(
r);
827 fRules.back().fOffset += base->GetDelta();
833 unsigned int nMembers = 0;
838 if ((dataMember->Property() &
kIsStatic) || !dataMember->IsPersistent())
841 if (dataMember->Property() &
kIsArray) {
842 throw RException(
R__FAIL(std::string(
"unsupported array type in SoA class: ") + dataMember->GetName()));
845 const std::string typeName{dataMember->GetTrueTypeName()};
848 auto itr = recordFieldNameToIdx.find(dmField->GetFieldName());
849 if (itr == recordFieldNameToIdx.end()) {
850 throw RException(
R__FAIL(std::string(
"unexpected SoA member: ") + dmField->GetFieldName()));
852 auto underlyingField = realRecordMemberFields[itr->second];
853 assert(dmField->GetFieldName() == underlyingField->GetFieldName());
855 if (
auto soaField =
dynamic_cast<RSoAField *
>(dmField.get())) {
857 throw RException(
R__FAIL(std::string(
"nested SoA field ") + soaField->GetQualifiedFieldName() +
" [" +
858 soaField->GetTypeName() +
"] does not match underlying type " +
859 underlyingField->GetTypeName()));
862 GraftNestedMemberFields(*soaField, dataMember->GetOffset(), [&](
const std::string &
name) {
863 return realRecordMemberFields[recordFieldNameToIdx[name]];
866 for (
const RRule &
r : soaField->fRules) {
867 fRules.emplace_back(
r);
868 fRules.back().fOffset += dataMember->GetOffset();
870 }
else if (
auto vecField =
dynamic_cast<RRVecField *
>(dmField.get())) {
871 if (vecField->begin()->GetTypeName() != underlyingField->GetTypeName() ||
872 vecField->begin()->GetTypeAlias() != underlyingField->GetTypeAlias()) {
873 const std::string leftType =
874 vecField->begin()->GetTypeName() +
875 (vecField->begin()->GetTypeAlias().empty() ?
"" :
" [" + vecField->begin()->GetTypeAlias() +
"]");
876 const std::string rightType =
877 underlyingField->GetTypeName() +
878 (underlyingField->GetTypeAlias().empty() ?
"" :
" [" + underlyingField->GetTypeAlias() +
"]");
879 throw RException(
R__FAIL(std::string(
"SoA member type mismatch: ") + vecField->GetFieldName() +
" (" +
880 leftType +
" vs. " + rightType +
")"));
883 fRecordMemberFields.emplace_back(underlyingField);
884 fRecordMemberDeleters.emplace_back(GetDeleterOf(*underlyingField));
885 fSoAMemberOffsets.emplace_back(dataMember->GetOffset());
887 throw RException(
R__FAIL(
"invalid field type in SoA class: " + dmField->GetTypeName()));
892 if (nDirectRecordSubfields != nMembers) {
896 auto schemaRules = FindRules(
nullptr);
897 for (
const auto &
r : schemaRules)
898 fRules.emplace_back(
RRule{
r, 0});
904 EnsureValidUserClass(
fClass, *
this,
"RSoAField");
906 if (recordTypeName.empty()) {
908 " is not marked with the rntupleSoARecord "
909 "dictionary option; cannot create corresponding RSoAField."));
912 Attach(std::make_unique<ROOT::RClassField>(
"_0", recordTypeName));
920 throw RException(
R__FAIL(std::string(
"version mismatch between SoA type and underlying record type: ") +
922 std::to_string(
fSubfields[0]->GetTypeVersion())));
927 std::string renormalizedAlias;
937 return std::unique_ptr<RSoAField>(
new RSoAField(newName, *
this));
947 return representations;
952 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
957 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
962 const std::size_t nSoAMembers = fSoAMemberOffsets.size();
965 for (std::size_t i = 0; i < nSoAMembers; ++i) {
966 const void *rvecPtr =
static_cast<const unsigned char *
>(from) + fSoAMemberOffsets[i];
968 assert(*sizePtr >= 0);
972 if (
static_cast<std::size_t
>(*sizePtr) !=
N) {
973 const auto f = fRecordMemberFields[i];
974 throw RException(
R__FAIL(
"SoA length mismatch for " +
f->GetFieldName() +
": " + std::to_string(*sizePtr) +
975 " vs. " + std::to_string(
N) +
" (expected)"));
980 std::size_t nbytes = 0;
982 for (std::size_t i = 0; i < nSoAMembers; ++i) {
983 const void *rvecPtr =
static_cast<const unsigned char *
>(from) + fSoAMemberOffsets[i];
985 RFieldBase *memberField = fRecordMemberFields[i];
987 GetPrincipalColumnOf(*memberField)->AppendV(*beginPtr,
N);
988 nbytes +=
N * GetPrincipalColumnOf(*memberField)->GetElement()->GetPackedSize();
990 for (std::size_t j = 0; j <
N; ++j) {
991 nbytes += CallAppendOn(*memberField, *beginPtr + j * memberField->
GetValueSize());
998 fPrincipalColumn->Append(&fNWritten);
999 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1007 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &
N);
1009 const auto nSoAMembers = fSoAMemberOffsets.size();
1010 for (std::size_t i = 0; i < nSoAMembers; ++i) {
1011 RFieldBase *memberField = fRecordMemberFields[i];
1013 void *rvecPtr =
static_cast<unsigned char *
>(to) + fSoAMemberOffsets[i];
1020 GetPrincipalColumnOf(*memberField)->ReadV(collectionStart,
N, begin);
1028 if (memberField->
GetTraits() & kTraitTriviallyConstructible) {
1029 std::memset(begin, 0,
N * memberSize);
1032 for (std::size_t j = 0; j <
N; ++j) {
1033 CallReadOn(*memberField, collectionStart + j, begin + (j * memberSize));
1049 const bool hasSources = std::any_of(fRules.begin(), fRules.end(), [](
const auto &
r) {
1050 return r.fRule->GetSource() && (r.fRule->GetSource()->GetEntries() > 0);
1052 const bool hasTargets =
1053 std::any_of(fRules.begin(), fRules.end(), [](
const auto &
r) { return r.fRule->GetTarget(); });
1056 throw RException(
R__FAIL(
"I/O customization rules with sources are currently unsupported for SoA fields (" +
1057 GetTypeName() +
")"));
1061 throw RException(
R__FAIL(
"I/O customization rules with targets are currently unsupported for SoA fields (" +
1062 GetTypeName() +
")"));
1065 for (
const auto &
r : fRules) {
1066 AddReadCallbacksFromIORule(
r.fRule,
r.fOffset);
1074 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1086 fSoAClass->Destructor(objPtr,
true );
1087 RDeleter::operator()(objPtr, dtorOnly);
1096 fSplitFields = std::make_unique<std::vector<std::unique_ptr<ROOT::RFieldBase>>>();
1097 fSplitOffsets = std::make_unique<std::vector<std::size_t>>();
1099 unsigned int baseIdx = 0;
1101 TClass *cl = base->GetClassPointer();
1109 if ((dataMember->Property() &
kIsStatic) || !dataMember->IsPersistent())
1112 const std::string typeName{dataMember->GetTrueTypeName()};
1124 auto valuePtr =
value.GetPtr<
void>();
1125 auto soaPtr =
static_cast<unsigned char *
>(valuePtr.get());
1126 std::vector<RValue> values;
1127 values.reserve(nSplitFields);
1128 for (std::size_t i = 0; i < nSplitFields; ++i) {
1152 EnsureValidAlignment(align);
1174 std::string_view emulatedFromType,
1175 std::string_view underlyingIntType)
1177 return std::unique_ptr<RFieldBase>(
new REnumField(fieldName, emulatedFromType, underlyingIntType));
1181 :
REnumField(fieldName, EnsureValidEnum(enumName))
1213 std::unique_ptr<RFieldBase> intField)
1216 Attach(std::move(intField));
1221 std::string_view underlyingIntType)
1224 auto intField =
Create(
"_0", std::string(underlyingIntType)).Unwrap();
1225 Attach(std::move(intField));
1231 auto newIntField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
1232 return std::unique_ptr<REnumField>(
new REnumField(newName, GetTypeName(), std::move(newIntField)));
1238 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1243 std::vector<RValue>
result;
1244 result.emplace_back(fSubfields[0]->BindValue(
value.GetPtr<
void>()));
1256 :
ROOT::
RRecordField(fieldName,
"std::pair<" + GetTypeList(itemFields, false ) +
">")
1260 const std::string typeAlias =
"std::pair<" + GetTypeList(itemFields,
true ) +
">";
1278 auto firstElem =
c->GetRealData(
"first");
1281 fOffsets.push_back(firstElem->GetThisOffset());
1283 auto secondElem =
c->GetRealData(
"second");
1286 fOffsets.push_back(secondElem->GetThisOffset());
1291 std::array<std::unique_ptr<RFieldBase>, 2> itemClones = {fSubfields[0]->Clone(fSubfields[0]->GetFieldName()),
1292 fSubfields[1]->Clone(fSubfields[1]->GetFieldName())};
1293 return std::unique_ptr<RPairField>(
new RPairField(newName, std::move(itemClones)));
1298 static const std::vector<std::string> prefixes = {
"std::pair<",
"std::tuple<"};
1300 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1301 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
1304 const auto nOnDiskSubfields = fieldDesc.
GetLinkIds().size();
1305 if (nOnDiskSubfields != 2) {
1307 std::to_string(nOnDiskSubfields) +
"\n" +
1323 (ifuncs.
fNext !=
nullptr));
1335 static const std::vector<std::string> supportedStdTypes = {
1336 "std::set<",
"std::unordered_set<",
"std::multiset<",
"std::unordered_multiset<",
1337 "std::map<",
"std::unordered_map<",
"std::multimap<",
"std::unordered_multimap<"};
1338 bool isSupported =
false;
1339 for (
const auto &tn : supportedStdTypes) {
1349 std::string renormalizedAlias;
1356 if (
fProxy->HasPointers())
1357 throw RException(
R__FAIL(
"collection proxies whose value type is a pointer are not supported"));
1368 throw RException(
R__FAIL(
"custom associative collection proxies not supported"));
1370 std::unique_ptr<ROOT::RFieldBase> itemField;
1372 if (
auto valueClass =
fProxy->GetValueClass()) {
1376 switch (
fProxy->GetType()) {
1381 case EDataType::kInt_t: itemField = std::make_unique<RField<Int_t>>(
"_0");
break;
1395 Attach(std::move(itemField));
1402 clone->fItemSize = fItemSize;
1403 clone->Attach(fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1409 std::size_t nbytes = 0;
1413 (fCollectionType ==
kSTLvector ? fItemSize : 0U)}) {
1414 nbytes += CallAppendOn(*fSubfields[0], ptr);
1419 fPrincipalColumn->Append(&fNWritten);
1420 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1427 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1435 (fCollectionType ==
kSTLvector || obj != to ? fItemSize : 0U)}) {
1436 CallReadOn(*fSubfields[0], collectionStart + (i++), elementPtr);
1439 fProxy->Commit(obj);
1449 return representations;
1454 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
1459 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
1464 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1475 std::size_t itemSize = fCollectionType ==
kSTLvector ? fItemSize : 0U;
1476 return std::make_unique<RProxiedCollectionDeleter>(fProxy, GetDeleterOf(*fSubfields[0]), itemSize);
1478 return std::make_unique<RProxiedCollectionDeleter>(fProxy);
1482 std::shared_ptr<TVirtualCollectionProxy> proxy)
1483 :
RDeleter(proxy->GetCollectionClass()->GetClassAlignment()), fProxy(std::move(proxy))
1488 std::shared_ptr<TVirtualCollectionProxy> proxy, std::unique_ptr<RDeleter> itemDeleter,
size_t itemSize)
1489 :
RDeleter(proxy->GetCollectionClass()->GetClassAlignment()),
1490 fProxy(std::move(proxy)),
1491 fItemDeleter(std::move(itemDeleter)),
1502 fItemDeleter->operator()(ptr,
true );
1505 fProxy->Destructor(objPtr,
true );
1506 RDeleter::operator()(objPtr, dtorOnly);
1511 std::vector<RValue>
result;
1512 auto valueRawPtr =
value.GetPtr<
void>().get();
1528 const auto align =
fProxy->GetCollectionClass()->GetClassAlignment();
1529 EnsureValidAlignment(align);
1542 EnsureValidClass(BuildMapTypeName(mapType, itemField.get(), false ))),
1546 if (!itemField->GetTypeAlias().empty())
1547 fTypeAlias = BuildMapTypeName(mapType, itemField.get(),
true );
1549 auto *itemClass =
fProxy->GetValueClass();
1552 Attach(std::move(itemField),
"_0");
1557 return std::make_unique<RMapField>(newName, fMapType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1562 static const std::vector<std::string> prefixesRegular = {
"std::map<",
"std::unordered_map<"};
1564 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1567 case EMapType::kMap:
1568 case EMapType::kUnorderedMap: EnsureMatchingTypePrefix(desc, prefixesRegular).ThrowOnError();
break;
1579 EnsureValidClass(BuildSetTypeName(setType, *itemField, false ))),
1582 if (!itemField->GetTypeAlias().empty())
1583 fTypeAlias = BuildSetTypeName(setType, *itemField,
true );
1587 Attach(std::move(itemField),
"_0");
1592 return std::make_unique<RSetField>(newName, fSetType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1597 static const std::vector<std::string> prefixesRegular = {
"std::set<",
"std::unordered_set<",
"std::map<",
1598 "std::unordered_map<"};
1600 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1603 case ESetType::kSet:
1604 case ESetType::kUnorderedSet: EnsureMatchingTypePrefix(desc, prefixesRegular).ThrowOnError();
break;
1621 RCallbackStreamerInfo fCallbackStreamerInfo;
1625 :
TBufferFile(
mode, bufsize), fCallbackStreamerInfo(std::move(callbackStreamerInfo))
1649 std::string renormalizedAlias;
1673 fClass->Streamer(
const_cast<void *
>(from), buffer);
1675 auto nbytes = buffer.Length();
1676 fAuxiliaryColumn->AppendV(buffer.Buffer(), buffer.Length());
1678 fPrincipalColumn->Append(&fIndex);
1679 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1686 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nbytes);
1689 fAuxiliaryColumn->ReadV(collectionStart, nbytes, buffer.
Buffer());
1690 fClass->Streamer(to, buffer);
1700 return representations;
1705 GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>();
1710 GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>(desc);
1721 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1737 RDeleter::operator()(objPtr, dtorOnly);
1753 EnsureValidAlignment(align);
1782 return dataMember->GetOffset();
1807 return std::unique_ptr<RField<TObject>>(
new RField<TObject>(newName, *
this));
1814 auto *obj =
static_cast<const TObject *
>(from);
1819 std::size_t nbytes = 0;
1820 nbytes += CallAppendOn(*fSubfields[0],
reinterpret_cast<const unsigned char *
>(from) + GetOffsetUniqueID());
1822 UInt_t bits = *
reinterpret_cast<const UInt_t *
>(
reinterpret_cast<const unsigned char *
>(from) + GetOffsetBits());
1824 nbytes += CallAppendOn(*fSubfields[1], &bits);
1833 auto *obj =
static_cast<TObject *
>(to);
1838 *
reinterpret_cast<UInt_t *
>(
reinterpret_cast<unsigned char *
>(to) + GetOffsetUniqueID()) = uniqueID;
1842 *
reinterpret_cast<UInt_t *
>(
reinterpret_cast<unsigned char *
>(to) + GetOffsetBits()) = bits;
1848 CallReadOn(*fSubfields[0], globalIndex, &uniqueID);
1849 CallReadOn(*fSubfields[1], globalIndex, &bits);
1850 ReadTObject(to, uniqueID, bits);
1856 CallReadOn(*fSubfields[0], localIndex, &uniqueID);
1857 CallReadOn(*fSubfields[1], localIndex, &bits);
1858 ReadTObject(to, uniqueID, bits);
1878 std::vector<RValue>
result;
1881 auto charPtr =
static_cast<unsigned char *
>(ptr.get());
1882 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(ptr, charPtr + GetOffsetUniqueID())));
1883 result.emplace_back(fSubfields[1]->BindValue(std::shared_ptr<void>(ptr, charPtr + GetOffsetBits())));
1905 :
ROOT::
RRecordField(fieldName,
"std::tuple<" + GetTypeList(itemFields, false ) +
">")
1907 for (
const auto &
f : itemFields) {
1910 const std::string typeAlias =
"std::tuple<" + GetTypeList(itemFields,
true ) +
">";
1926 for (
unsigned i = 0; i <
fSubfields.size(); ++i) {
1927 std::string memberName(
"_" + std::to_string(i));
1928 auto member =
c->GetRealData(memberName.c_str());
1931 fOffsets.push_back(member->GetThisOffset());
1937 std::vector<std::unique_ptr<RFieldBase>> itemClones;
1938 itemClones.reserve(fSubfields.size());
1939 for (
const auto &
f : fSubfields) {
1940 itemClones.emplace_back(
f->Clone(
f->GetFieldName()));
1942 return std::unique_ptr<RTupleField>(
new RTupleField(newName, std::move(itemClones)));
1947 static const std::vector<std::string> prefixes = {
"std::pair<",
"std::tuple<"};
1949 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1950 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
1953 const auto nOnDiskSubfields = fieldDesc.
GetLinkIds().size();
1954 const auto nSubfields = fSubfields.size();
1955 if (nOnDiskSubfields != nSubfields) {
1957 std::to_string(nOnDiskSubfields) +
" vs. " + std::to_string(nSubfields) +
"\n" +
1967constexpr std::size_t GetVariantTagSize()
1970 std::variant<char> t;
1971 constexpr auto sizeOfT =
sizeof(t);
1973 static_assert(sizeOfT == 2 || sizeOfT == 8,
"unsupported std::variant layout");
1974 return sizeOfT == 2 ? 1 : 4;
1977template <std::
size_t VariantSizeT>
1979 using ValueType_t =
typename std::conditional_t<VariantSizeT == 1, std::uint8_t,
1980 typename std::conditional_t<VariantSizeT == 4, std::uint32_t, void>>;
1987 fMaxItemSize(source.fMaxItemSize),
1988 fMaxAlignment(source.fMaxAlignment),
1989 fTagOffset(source.fTagOffset),
1990 fVariantOffset(source.fVariantOffset),
1991 fNWritten(source.fNWritten.
size(), 0)
1994 Attach(
f->Clone(
f->GetFieldName()));
1999 :
ROOT::
RFieldBase(fieldName,
"std::variant<" + GetTypeList(itemFields, false ) +
">",
2002 for (
const auto &
f : itemFields) {
2008 const std::string typeAlias =
"std::variant<" + GetTypeList(itemFields,
true ) +
">";
2012 auto nFields = itemFields.size();
2017 for (
unsigned int i = 0; i < nFields; ++i) {
2020 fTraits &= itemFields[i]->GetTraits();
2021 Attach(std::move(itemFields[i]),
"_" + std::to_string(i));
2032 const auto tagSize = GetVariantTagSize();
2033 const auto padding = tagSize - (
fMaxItemSize % tagSize);
2039 return std::unique_ptr<RVariantField>(
new RVariantField(newName, *
this));
2044 using TagType_t = RVariantTag<GetVariantTagSize()>::ValueType_t;
2045 auto tag = *
reinterpret_cast<const TagType_t *
>(
reinterpret_cast<const unsigned char *
>(variantPtr) + tagOffset);
2046 return (tag == TagType_t(-1)) ? 0 : tag + 1;
2051 using TagType_t = RVariantTag<GetVariantTagSize()>::ValueType_t;
2052 auto tagPtr =
reinterpret_cast<TagType_t *
>(
reinterpret_cast<unsigned char *
>(variantPtr) + tagOffset);
2053 *tagPtr = (tag == 0) ? TagType_t(-1) :
static_cast<TagType_t
>(tag - 1);
2058 auto tag = GetTag(from, fTagOffset);
2059 std::size_t nbytes = 0;
2062 nbytes += CallAppendOn(*fSubfields[tag - 1],
reinterpret_cast<const unsigned char *
>(from) + fVariantOffset);
2063 index = fNWritten[tag - 1]++;
2066 fPrincipalColumn->Append(&varSwitch);
2074 fPrincipalColumn->GetSwitchInfo(globalIndex, &variantIndex, &tag);
2081 void *varPtr =
reinterpret_cast<unsigned char *
>(to) + fVariantOffset;
2082 CallConstructValueOn(*fSubfields[tag - 1], varPtr);
2083 CallReadOn(*fSubfields[tag - 1], variantIndex, varPtr);
2085 SetTag(to, fTagOffset, tag);
2091 return representations;
2096 GenerateColumnsImpl<ROOT::Internal::RColumnSwitch>();
2101 GenerateColumnsImpl<ROOT::Internal::RColumnSwitch>(desc);
2106 static const std::vector<std::string> prefixes = {
"std::variant<"};
2108 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
2109 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
2112 if (fSubfields.size() != fieldDesc.GetLinkIds().size()) {
2113 throw RException(
R__FAIL(
"number of variants on-disk do not match for " + GetQualifiedFieldName() +
"\n" +
2120 memset(where, 0, GetValueSize());
2121 CallConstructValueOn(*fSubfields[0],
reinterpret_cast<unsigned char *
>(where) + fVariantOffset);
2122 SetTag(where, fTagOffset, 1);
2127 auto tag = GetTag(objPtr, fTagOffset);
2129 fItemDeleters[tag - 1]->operator()(
reinterpret_cast<unsigned char *
>(objPtr) + fVariantOffset,
true );
2131 RDeleter::operator()(objPtr, dtorOnly);
2136 std::vector<std::unique_ptr<RDeleter>> itemDeleters;
2137 itemDeleters.reserve(fSubfields.size());
2138 for (
const auto &
f : fSubfields) {
2139 itemDeleters.emplace_back(GetDeleterOf(*
f));
2141 return std::make_unique<RVariantDeleter>(fTagOffset, fVariantOffset, GetAlignment(), std::move(itemDeleters));
2146 return std::max(fMaxAlignment,
alignof(RVariantTag<GetVariantTagSize()>::ValueType_t));
2152 const auto actualSize = fTagOffset + GetVariantTagSize();
2154 return actualSize + ((padding ==
alignment) ? 0 : padding);
2159 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
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
@ 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 & GetFieldName() const
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::string fTypeAlias
A typedef or using name that was used when creating the field.
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 ...
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...
void AddReadCallbacksFromIORule(const TSchemaRule *rule, std::size_t subObjectOffset=0)
Register post-read callback corresponding to a ROOT I/O customization rules.
TClass * fClass
Set by derived class to the TClass instance representing the current in-memory layout.
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