Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RFieldMeta.cxx
Go to the documentation of this file.
1/// \file RFieldMeta.cxx
2/// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
3/// \date 2024-11-19
4
5// This file has concrete RField implementations that depend on ROOT Meta:
6// - RClassField
7// - RSoAField
8// - REnumField
9// - RPairField
10// - RTupleField
11// - RProxiedCollectionField
12// - RMapField
13// - RSetField
14// - RStreamerField
15// - RField<TObject>
16// - RVariantField
17
18#include <ROOT/BitUtils.hxx>
19#include <ROOT/RField.hxx>
20#include <ROOT/RFieldBase.hxx>
21#include <ROOT/RFieldUtils.hxx>
23#include <ROOT/RNTupleUtils.hxx>
24#include <ROOT/RSpan.hxx>
25
26#include <TBaseClass.h>
27#include <TBufferFile.h>
28#include <TClass.h>
29#include <TClassEdit.h>
30#include <TDataMember.h>
31#include <TEnum.h>
32#include <TObject.h>
33#include <TObjArray.h>
34#include <TObjString.h>
35#include <TRealData.h>
36#include <TSchemaRule.h>
37#include <TSchemaRuleSet.h>
38#include <TStreamerElement.h>
39#include <TVirtualObject.h>
41
42#include <algorithm>
43#include <array>
44#include <cstddef> // std::size_t
45#include <cstdint> // std::uint32_t et al.
46#include <cstring> // for memset
47#include <memory>
48#include <mutex>
49#include <string>
50#include <string_view>
51#include <unordered_set>
52#include <utility>
53#include <variant>
54
56
57namespace {
58
59TClass *EnsureValidClass(std::string_view className)
60{
61 auto cl = TClass::GetClass(std::string(className).c_str());
62 if (cl == nullptr) {
63 throw ROOT::RException(R__FAIL("RField: no I/O support for type " + std::string(className)));
64 }
65 return cl;
66}
67
68/// Common checks used both by RClassField and RSoAField
69void EnsureValidUserClass(TClass *cl, const ROOT::RFieldBase &field, std::string_view fieldType)
70{
71 if (cl->GetState() < TClass::kInterpreted) {
72 throw ROOT::RException(R__FAIL(std::string(fieldType) + " " + cl->GetName() +
73 " cannot be constructed from a class that's not at least Interpreted"));
74 }
75 // Avoid accidentally supporting std types through TClass.
76 if (cl->Property() & kIsDefinedInStd) {
77 throw ROOT::RException(R__FAIL(field.GetTypeName() + " is not supported"));
78 }
79 if (field.GetTypeName() == "TObject") {
80 throw ROOT::RException(R__FAIL("TObject is only supported through RField<TObject>"));
81 }
82 if (cl->GetCollectionProxy()) {
83 throw ROOT::RException(R__FAIL(field.GetTypeName() + " has an associated collection proxy; "
84 "use RProxiedCollectionField instead"));
85 }
86 // Classes with, e.g., custom streamers are not supported through this field. Empty classes, however, are.
87 // Can be overwritten with the "rntuple.streamerMode=true" class attribute
88 if (!cl->CanSplit() && cl->Size() > 1 &&
90 throw ROOT::RException(R__FAIL(field.GetTypeName() + " cannot be stored natively in RNTuple"));
91 }
94 throw ROOT::RException(
95 R__FAIL(field.GetTypeName() + " has streamer mode enforced, not supported as native RNTuple class"));
96 }
97 // Detect custom streamers set on individual members at runtime via
98 // TClass::SetMemberStreamer() or TClass::AdoptMemberStreamer().
99 // CanSplit() only checks for custom streamers set at compile time (fHasCustomStreamerMember),
100 // but runtime streamers are stored in TRealData and must be checked here.
101 if (!cl->GetListOfRealData()) {
102 cl->BuildRealData();
103 }
104 for (auto realMember : ROOT::Detail::TRangeStaticCast<TRealData>(*cl->GetListOfRealData())) {
105 if (realMember->GetStreamer()) {
106 throw ROOT::RException(R__FAIL(std::string(field.GetTypeName()) + " has member " + realMember->GetName() +
107 " with a custom streamer; not supported natively in RNTuple"));
108 }
109 }
110}
111
112TEnum *EnsureValidEnum(std::string_view enumName)
113{
114 auto e = TEnum::GetEnum(std::string(enumName).c_str());
115 if (e == nullptr) {
116 throw ROOT::RException(R__FAIL("RField: no I/O support for enum type " + std::string(enumName)));
117 }
118 return e;
119}
120
121void EnsureValidAlignment(std::size_t alignment)
122{
124 throw ROOT::RException(R__FAIL(std::string("invalid alignment: ") + std::to_string(alignment)));
125}
126
127/// Create a comma-separated list of type names from the given fields. Uses either the real type names or the
128/// type aliases (if there are any, otherwise the actual type name). Used to construct template argument lists
129/// for templated types such as std::pair<...>, std::tuple<...>, std::variant<...>.
130std::string GetTypeList(std::span<std::unique_ptr<ROOT::RFieldBase>> itemFields, bool useTypeAliases)
131{
132 std::string result;
133 for (size_t i = 0; i < itemFields.size(); ++i) {
134 if (useTypeAliases && !itemFields[i]->GetTypeAlias().empty()) {
135 result += itemFields[i]->GetTypeAlias();
136 } else {
137 result += itemFields[i]->GetTypeName();
138 }
139 result.push_back(',');
140 }
141 if (result.empty()) {
142 throw ROOT::RException(R__FAIL("invalid empty type list provided as template argument"));
143 }
144 result.pop_back(); // remove trailing comma
145 return result;
146}
147
148std::string BuildSetTypeName(ROOT::RSetField::ESetType setType, const ROOT::RFieldBase &innerField, bool useTypeAlias)
149{
150 if (innerField.GetTypeName().empty()) {
151 throw ROOT::RException(R__FAIL("invalid untyped inner field for outer set field"));
152 }
153 std::string typePrefix;
154 switch (setType) {
155 case ROOT::RSetField::ESetType::kSet: typePrefix = "std::set<"; break;
156 case ROOT::RSetField::ESetType::kUnorderedSet: typePrefix = "std::unordered_set<"; break;
157 case ROOT::RSetField::ESetType::kMultiSet: typePrefix = "std::multiset<"; break;
158 case ROOT::RSetField::ESetType::kUnorderedMultiSet: typePrefix = "std::unordered_multiset<"; break;
159 default: R__ASSERT(false);
160 }
161 return typePrefix +
162 ((useTypeAlias && !innerField.GetTypeAlias().empty()) ? innerField.GetTypeAlias()
163 : innerField.GetTypeName()) +
164 ">";
165}
166
167std::string BuildMapTypeName(ROOT::RMapField::EMapType mapType, const ROOT::RFieldBase *innerField, bool useTypeAliases)
168{
169 if (innerField->GetTypeName().empty()) {
170 throw ROOT::RException(R__FAIL("invalid untyped inner field for outer map field"));
171 }
172 if (const auto pairField = dynamic_cast<const ROOT::RPairField *>(innerField)) {
173 std::string typePrefix;
174 switch (mapType) {
175 case ROOT::RMapField::EMapType::kMap: typePrefix = "std::map<"; break;
176 case ROOT::RMapField::EMapType::kUnorderedMap: typePrefix = "std::unordered_map<"; break;
177 case ROOT::RMapField::EMapType::kMultiMap: typePrefix = "std::multimap<"; break;
178 case ROOT::RMapField::EMapType::kUnorderedMultiMap: typePrefix = "std::unordered_multimap<"; break;
179 default: R__ASSERT(false);
180 }
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();
186 } else {
187 type += items[i]->GetTypeName();
188 }
189 if (i == 0)
190 type.push_back(',');
191 }
192 return type + ">";
193 }
194
195 throw ROOT::RException(R__FAIL("RMapField inner field type must be of RPairField"));
196}
197
198} // anonymous namespace
199
200ROOT::RRuleField::RRuleField(std::string_view fieldName, std::string_view typeName, TClass *classp,
201 ROOT::ENTupleStructure structure)
202 : RFieldBase(fieldName, typeName, structure, false /* isSimple */), fClass(classp)
203{
204}
205
207 ROOT::DescriptorId_t classFieldId) const
208{
209 auto idSourceMember = desc.FindFieldId(memberName, classFieldId);
210 if (idSourceMember != ROOT::kInvalidDescriptorId)
211 return idSourceMember;
212
213 for (const auto &subFieldDesc : desc.GetFieldIterable(classFieldId)) {
214 const auto &subFieldName = subFieldDesc.GetFieldName();
215 if (subFieldName.length() > 2 && subFieldName[0] == ':' && subFieldName[1] == '_') {
216 idSourceMember = LookupMember(desc, memberName, subFieldDesc.GetId());
217 if (idSourceMember != ROOT::kInvalidDescriptorId)
218 return idSourceMember;
219 }
220 }
221
223}
224
225void ROOT::RRuleField::SetStagingClass(const std::string &className, unsigned int classVersion)
226{
227 TClass::GetClass(className.c_str())->GetStreamerInfo(classVersion);
228 if (classVersion != GetTypeVersion() || className != GetTypeName()) {
229 fStagingClass = TClass::GetClass((className + std::string("@@") + std::to_string(classVersion)).c_str());
230 if (!fStagingClass) {
231 // For a rename rule, we may simply ask for the old class name
232 fStagingClass = TClass::GetClass(className.c_str());
233 }
234 } else {
235 fStagingClass = fClass;
236 }
237 R__ASSERT(fStagingClass);
238 R__ASSERT(static_cast<unsigned int>(fStagingClass->GetClassVersion()) == classVersion);
239}
240
241void ROOT::RRuleField::PrepareStagingArea(const std::vector<const TSchemaRule *> &rules,
242 const ROOT::RNTupleDescriptor &desc,
243 const ROOT::RFieldDescriptor &classFieldDesc)
244{
245 std::size_t stagingAreaSize = 0;
246 for (const auto rule : rules) {
247 for (auto source : TRangeDynCast<TSchemaRule::TSources>(rule->GetSource())) {
248 auto [itr, isNew] = fStagingItems.emplace(source->GetName(), RStagingItem());
249 if (!isNew) {
250 // This source member has already been processed by another rule (and we only support one type per member)
251 continue;
252 }
253 RStagingItem &stagingItem = itr->second;
254
255 const auto memberFieldId = LookupMember(desc, source->GetName(), classFieldDesc.GetId());
256 if (memberFieldId == kInvalidDescriptorId) {
257 throw RException(R__FAIL(std::string("cannot find on disk rule source member ") + GetTypeName() + "." +
258 source->GetName()));
259 }
260
261 auto memberType = source->GetTypeForDeclaration() + source->GetDimensions();
262 auto memberField = Create("" /* we don't need a field name */, std::string(memberType)).Unwrap();
263 memberField->SetOnDiskId(memberFieldId);
264 auto fieldZero = std::make_unique<RFieldZero>();
265 Internal::SetAllowFieldSubstitutions(*fieldZero, true);
266 fieldZero->Attach(std::move(memberField));
267 stagingItem.fField = std::move(fieldZero);
268
269 stagingItem.fOffset = fStagingClass->GetDataMemberOffset(source->GetName());
270 // Since we successfully looked up the source member in the RNTuple on-disk metadata, we expect it
271 // to be present in the TClass instance, too.
273 stagingAreaSize = std::max(stagingAreaSize, stagingItem.fOffset + stagingItem.fField->begin()->GetValueSize());
274 }
275 }
276
277 if (stagingAreaSize) {
278 R__ASSERT(static_cast<Int_t>(stagingAreaSize) <= fStagingClass->Size()); // we may have removed rules
279 // We use std::make_unique instead of MakeUninitArray to zero-initialize the staging area.
280 fStagingArea = std::make_unique<unsigned char[]>(stagingAreaSize);
281
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);
286 }
287 }
288 }
289}
290
291std::vector<const ROOT::TSchemaRule *> ROOT::RRuleField::FindRules(const ROOT::RFieldDescriptor *fieldDesc) const
292{
294
295 const auto ruleset = fClass->GetSchemaRules();
296 if (!ruleset)
297 return rules;
298
299 if (!fieldDesc) {
300 // If we have no on-disk information for the field, we still process the rules on the current in-memory version
301 // of the class
302 rules = ruleset->FindRules(fClass->GetName(), fClass->GetClassVersion(), fClass->GetCheckSum());
303 } else {
304 // We need to change (back) the name normalization from RNTuple to ROOT Meta
305 std::string normalizedName;
306 TClassEdit::GetNormalizedName(normalizedName, fieldDesc->GetTypeName());
307 // We do have an on-disk field that correspond to the current RClassField instance. Ask for rules matching the
308 // on-disk version of the field.
309 if (fieldDesc->GetTypeChecksum()) {
310 rules = ruleset->FindRules(normalizedName, fieldDesc->GetTypeVersion(), *fieldDesc->GetTypeChecksum());
311 } else {
312 rules = ruleset->FindRules(normalizedName, fieldDesc->GetTypeVersion());
313 }
314 }
315
316 // Cleanup and sort rules
317 // Check that any given source member uses the same type in all rules
318 std::unordered_map<std::string, std::string> sourceNameAndType;
319 std::size_t nskip = 0; // skip whole-object-rules that were moved to the end of the rules vector
320 for (auto itr = rules.begin(); itr != rules.end() - nskip;) {
321 const auto rule = *itr;
322
323 // Erase unknown rule types
324 if (rule->GetRuleType() != ROOT::TSchemaRule::kReadRule) {
326 << "ignoring I/O customization rule with unsupported type: " << rule->GetRuleType();
327 itr = rules.erase(itr);
328 continue;
329 }
330
331 bool hasConflictingSourceMembers = false;
332 for (auto source : TRangeDynCast<TSchemaRule::TSources>(rule->GetSource())) {
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;
340 break;
341 }
342 }
343 if (hasConflictingSourceMembers) {
344 itr = rules.erase(itr);
345 continue;
346 }
347
348 // Rules targeting the entire object need to be executed at the end
349 if (rule->GetTarget() == nullptr) {
350 nskip++;
351 if (itr != rules.end() - nskip)
352 std::iter_swap(itr++, rules.end() - nskip);
353 continue;
354 }
355
356 ++itr;
357 }
358
359 return rules;
360}
361
362void ROOT::RRuleField::AddFuncsFromIORule(const TSchemaRule *rule, std::size_t subObjectOffset)
363{
364 auto func = rule->GetReadFunctionPointer();
365 if (func == nullptr) {
366 // Can happen for rename rules
367 return;
368 }
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; // TVirtualObject does not own the value
376 });
377}
378
380{
381 for (const auto &func : fRuleFuncs)
382 func(target);
383}
384
385//------------------------------------------------------------------------------
386
387ROOT::RClassField::RClassField(std::string_view fieldName, const RClassField &source)
388 : ROOT::RRuleField(fieldName, source.GetTypeName(), source.fClass, ROOT::ENTupleStructure::kRecord),
389 fSubfieldsInfo(source.fSubfieldsInfo)
390{
391 for (const auto &f : source.GetConstSubfields()) {
392 RFieldBase::Attach(f->Clone(f->GetFieldName()));
393 }
394 fTraits = source.GetTraits();
395}
396
397ROOT::RClassField::RClassField(std::string_view fieldName, std::string_view className)
398 : RClassField(fieldName, EnsureValidClass(className))
399{
400}
401
402ROOT::RClassField::RClassField(std::string_view fieldName, TClass *classp)
403 : ROOT::RRuleField(fieldName, GetRenormalizedTypeName(classp->GetName()), classp, ROOT::ENTupleStructure::kRecord)
404{
405 EnsureValidUserClass(fClass, *this, "RClassField");
406
408 throw ROOT::RException(R__FAIL(GetTypeName() + " is a SoA field and cannot be used through RClassField"));
409 }
410
415
416 std::string renormalizedAlias;
417 if (Internal::NeedsMetaNameAsAlias(classp->GetName(), renormalizedAlias))
418 SetTypeAlias(renormalizedAlias);
419
420 int i = 0;
421 const auto *bases = fClass->GetListOfBases();
422 assert(bases);
423 for (auto baseClass : ROOT::Detail::TRangeStaticCast<TBaseClass>(*bases)) {
424 if (baseClass->GetDelta() < 0) {
425 throw RException(R__FAIL(std::string("virtual inheritance is not supported: ") + GetTypeName() +
426 " virtually inherits from " + baseClass->GetName()));
427 }
428 TClass *c = baseClass->GetClassPointer();
429 auto subField =
430 RFieldBase::Create(std::string(kPrefixInherited) + "_" + std::to_string(i), c->GetName()).Unwrap();
431 fTraits &= subField->GetTraits();
432 Attach(std::move(subField), RSubfieldInfo{kBaseClass, static_cast<std::size_t>(baseClass->GetDelta())});
433 i++;
434 }
436 // Skip, for instance, unscoped enum constants defined in the class
437 if (dataMember->Property() & kIsStatic)
438 continue;
439 // Skip members explicitly marked as transient by user comment
440 if (!dataMember->IsPersistent()) {
441 // TODO(jblomer): we could do better
443 continue;
444 }
445
446 // NOTE: we use the already-resolved type name for the fields, otherwise TClass::GetClass may fail to resolve
447 // context-dependent types (e.g. typedefs defined in the class itself - which will not be fully qualified in
448 // the string returned by dataMember->GetFullTypeName())
449 std::string typeName{dataMember->GetTrueTypeName()};
450
451 // For C-style arrays, complete the type name with the size for each dimension, e.g. `int[4][2]`
452 if (dataMember->Property() & kIsArray) {
453 for (int dim = 0, n = dataMember->GetArrayDim(); dim < n; ++dim) {
454 typeName += "[" + std::to_string(dataMember->GetMaxIndex(dim)) + "]";
455 }
456 }
457
458 auto subField = RFieldBase::Create(dataMember->GetName(), typeName).Unwrap();
459
460 fTraits &= subField->GetTraits();
461 Attach(std::move(subField), RSubfieldInfo{kDataMember, static_cast<std::size_t>(dataMember->GetOffset())});
462 }
464}
465
467{
468 if (fStagingArea) {
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 /* dtorOnly */);
473 }
474 }
475 }
476}
477
478void ROOT::RClassField::Attach(std::unique_ptr<RFieldBase> child, RSubfieldInfo info)
479{
480 fSubfieldsInfo.push_back(info);
481 RFieldBase::Attach(std::move(child));
482}
483
484std::unique_ptr<ROOT::RFieldBase> ROOT::RClassField::CloneImpl(std::string_view newName) const
485{
486 return std::unique_ptr<RClassField>(new RClassField(newName, *this));
487}
488
489std::size_t ROOT::RClassField::AppendImpl(const void *from)
490{
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);
494 }
495 return nbytes;
496}
497
499{
500 for (const auto &[_, si] : fStagingItems) {
501 CallReadOn(*si.fField, globalIndex, fStagingArea.get() + si.fOffset);
502 }
503 for (unsigned i = 0; i < fSubfields.size(); i++) {
504 CallReadOn(*fSubfields[i], globalIndex, static_cast<unsigned char *>(to) + fSubfieldsInfo[i].fOffset);
505 }
506 InvokeRuleFuncs(to);
507}
508
510{
511 for (const auto &[_, si] : fStagingItems) {
512 CallReadOn(*si.fField, localIndex, fStagingArea.get() + si.fOffset);
513 }
514 for (unsigned i = 0; i < fSubfields.size(); i++) {
515 CallReadOn(*fSubfields[i], localIndex, static_cast<unsigned char *>(to) + fSubfieldsInfo[i].fOffset);
516 }
517 InvokeRuleFuncs(to);
518}
519
521{
522 std::vector<const TSchemaRule *> rules;
523 // On-disk members that are not targeted by an I/O rule; all other sub fields of the in-memory class
524 // will be marked as artificial (added member in a new class version or member set by rule).
525 std::unordered_set<std::string> regularSubfields;
526 // We generally don't support changing the number of base classes, with the exception of changing from/to zero
527 // base classes. The variable stores the number of on-disk base classes.
528 int nOnDiskBaseClasses = 0;
529
530 if (GetOnDiskId() == kInvalidDescriptorId) {
531 // This can happen for added base classes or added members of class type
532 rules = FindRules(nullptr);
533 if (!rules.empty())
534 SetStagingClass(GetTypeName(), GetTypeVersion());
535 } else {
536 const auto descriptorGuard = pageSource.GetSharedDescriptorGuard();
537 const ROOT::RNTupleDescriptor &desc = descriptorGuard.GetConstRef();
538 const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
539
540 if (fieldDesc.GetStructure() == ENTupleStructure::kStreamer) {
541 // Streamer field on disk but meanwhile the type can be represented as a class field; replace this field
542 // by a streamer field to read the data from disk.
543 auto substitute = std::make_unique<RStreamerField>(GetFieldName(), GetTypeName());
544 substitute->SetOnDiskId(GetOnDiskId());
545 return substitute;
546 }
547
548 for (auto linkId : fieldDesc.GetLinkIds()) {
549 const auto &subFieldDesc = desc.GetFieldDescriptor(linkId);
550 regularSubfields.insert(subFieldDesc.GetFieldName());
551 if (!subFieldDesc.GetFieldName().empty() && subFieldDesc.GetFieldName()[0] == ':')
552 nOnDiskBaseClasses++;
553 }
554
555 rules = FindRules(&fieldDesc);
556
557 // If we found a rule, we know it is valid to read on-disk data because we found the rule according to the on-disk
558 // (source) type name and version/checksum.
559 if (rules.empty()) {
560 // Otherwise we require compatible type names, after renormalization. GetTypeName() is already renormalized,
561 // but RNTuple data written with ROOT v6.34 might not have renormalized the field type name. Ask the
562 // RNTupleDescriptor, which knows about the spec version, for a fixed up type name.
563 std::string descTypeName = desc.GetTypeNameForComparison(fieldDesc);
564 if (GetTypeName() != descTypeName) {
565 throw RException(R__FAIL("incompatible type name for field " + GetFieldName() + ": " + GetTypeName() +
566 " vs. " + descTypeName));
567 }
568 }
569
570 const bool hasSources = std::any_of(rules.begin(), rules.end(), [](const auto &r) {
571 return r->GetSource() && (r->GetSource()->GetEntries() > 0);
572 });
573
574 // A staging class (conversion streamer info) only exists if there is at least one rule that has an
575 // on disk source member defined.
576 if (hasSources) {
577 // For unversioned classes, the in-memory layout may by chance have the same transient version number
578 // than the recorded (transient, at the time of writing) on-disk version. Therefore, we also need to compare
579 // the checksums to find out if we need a conversion streamer info.
580 std::uint32_t assignedVersionForOnDiskLayout = fieldDesc.GetTypeVersion();
581 R__ASSERT(fieldDesc.GetTypeChecksum());
582 if (fieldDesc.GetTypeVersion() != GetTypeVersion() || *fieldDesc.GetTypeChecksum() != fClass->GetCheckSum() ||
583 fieldDesc.GetTypeName() != GetTypeName()) {
584 auto oldCl = TClass::GetClass(fieldDesc.GetTypeName().c_str());
585 R__ASSERT(oldCl);
586 auto onDiskStreamerInfo = oldCl->FindStreamerInfo(*fieldDesc.GetTypeChecksum());
587 R__ASSERT(onDiskStreamerInfo);
588 assignedVersionForOnDiskLayout = onDiskStreamerInfo->GetClassVersion();
589 }
590 SetStagingClass(fieldDesc.GetTypeName(), assignedVersionForOnDiskLayout);
591 PrepareStagingArea(rules, desc, fieldDesc);
592 for (auto &[_, si] : fStagingItems) {
593 Internal::CallConnectPageSourceOnField(*si.fField, pageSource);
594 si.fField = std::move(static_cast<RFieldZero *>(si.fField.get())->ReleaseSubfields()[0]);
595 }
596 }
597
598 // Remove target member of read rules from the list of regular members of the underlying on-disk field
599 for (const auto rule : rules) {
600 if (!rule->GetTarget())
601 continue;
602
603 for (const auto target : ROOT::Detail::TRangeStaticCast<const TObjString>(*rule->GetTarget())) {
604 regularSubfields.erase(std::string(target->GetString()));
605 }
606 }
607 }
608
609 for (const auto rule : rules) {
610 AddFuncsFromIORule(rule);
611 }
612
613 // Iterate over all sub fields in memory and mark those as missing that are not in the descriptor.
614 int nInMemoryBaseClasses = 0;
615 for (auto &field : fSubfields) {
616 const auto &fieldName = field->GetFieldName();
617 if (regularSubfields.count(fieldName) == 0) {
618 CallSetArtificialOn(*field);
619 }
620 if (!fieldName.empty() && fieldName[0] == ':')
621 nInMemoryBaseClasses++;
622 }
623
624 if (nInMemoryBaseClasses != 0 && nOnDiskBaseClasses != 0 && nInMemoryBaseClasses != nOnDiskBaseClasses) {
625 throw RException(
626 R__FAIL(std::string("incompatible number of base classes for field ") + GetFieldName() + ": " + GetTypeName() +
627 ", " + std::to_string(nInMemoryBaseClasses) +
628 " base classes in memory "
629 " vs. " +
630 std::to_string(nOnDiskBaseClasses) + " base classes on-disk\n" +
632 }
633
634 return nullptr;
635}
636
638{
639 EnsureMatchingOnDiskField(desc, kDiffTypeVersion | kDiffTypeName).ThrowOnError();
640}
641
643{
644 fClass->New(where);
645}
646
648
649void ROOT::RClassField::RClassDeleter::operator()(void *objPtr, bool dtorOnly)
650{
651 fClass->Destructor(objPtr, true /* dtorOnly */);
652 RDeleter::operator()(objPtr, dtorOnly);
653}
654
655std::vector<ROOT::RFieldBase::RValue> ROOT::RClassField::SplitValue(const RValue &value) const
656{
657 std::vector<RValue> result;
658 auto valuePtr = value.GetPtr<void>();
659 auto charPtr = static_cast<unsigned char *>(valuePtr.get());
660 result.reserve(fSubfields.size());
661 for (unsigned i = 0; i < fSubfields.size(); i++) {
662 result.emplace_back(
663 fSubfields[i]->BindValue(std::shared_ptr<void>(valuePtr, charPtr + fSubfieldsInfo[i].fOffset)));
664 }
665 return result;
666}
667
669{
670 return fClass->GetClassSize();
671}
672
674{
675 const auto align = fClass->GetClassAlignment();
676 EnsureValidAlignment(align);
677 return align;
678}
679
681{
682 return fClass->GetClassVersion();
683}
684
686{
687 return fClass->GetCheckSum();
688}
689
690const std::type_info *ROOT::RClassField::GetPolymorphicTypeInfo() const
691{
692 bool polymorphic = fClass->ClassProperty() & kClassHasVirtual;
693 if (!polymorphic) {
694 return nullptr;
695 }
696 return fClass->GetTypeInfo();
697}
698
700{
701 visitor.VisitClassField(*this);
702}
703
704//------------------------------------------------------------------------------
705
706ROOT::RSoAField::RSoAField(std::string_view fieldName, const RSoAField &source)
707 : ROOT::RRuleField(fieldName, source.GetTypeName(), source.fClass, ROOT::ENTupleStructure::kCollection),
708 fSoAMemberOffsets(source.fSoAMemberOffsets)
709{
710 fTraits = source.GetTraits();
711 Attach(source.fSubfields[0]->Clone(source.fSubfields[0]->GetFieldName()));
712 fRecordMemberFields = fSubfields[0]->GetMutableSubfields();
714 for (const auto f : fRecordMemberFields)
715 fRecordMemberDeleters.emplace_back(GetDeleterOf(*f));
716 fLockSplitFields = std::make_unique<std::mutex>();
717}
718
719ROOT::RSoAField::RSoAField(std::string_view fieldName, std::string_view className)
720 : RSoAField(fieldName, EnsureValidClass(className))
721{
722}
723
725 const RSoAField &nestedSoA, std::size_t offsetInParent,
726 const std::function<RFieldBase *(const std::string &)> &fnRecordFieldFinder)
727{
728 const std::size_t nNestedRecordMemberFields = nestedSoA.fRecordMemberFields.size();
729
730 // The qualified field name of fields in nestedSoA->fRecordMemberFields will have a "<field name>._0."
731 // prefix because these fields are rooted in a collection named after the nested SoA field.
732 //
733 // E.g., in the following example:
734 //
735 // struct SoA_A { struct Record_A {
736 // SoA_B fB; Record_B fB;
737 // }; };
738 //
739 // struct SoA_B { struct Record_B {
740 // ROOT::RVec<float> fX; float fX;
741 // }; };
742 //
743 // The on-disk schema of SoA_A is "collection of Record_A", and the on-disk schema of SoA_B is
744 // "collection of Record_B".
745 // The qualified field name of fX in the subfield hiararchy of SoA_A is <field name>._0.fB.fX.
746 // The qualified field name of fX in the subfield hiararchy of SoA_B is <field name>._0.fX.
747 const auto lenPrefix = nestedSoA.GetFieldName().length() + strlen("._0.");
748
749 for (std::size_t i = 0; i < nNestedRecordMemberFields; ++i) {
750 const auto fieldNameForMatching =
751 nestedSoA.GetFieldName() + "." + nestedSoA.fRecordMemberFields[i]->GetQualifiedFieldName().substr(lenPrefix);
752
753 fRecordMemberFields.emplace_back(fnRecordFieldFinder(fieldNameForMatching));
754 fRecordMemberDeleters.emplace_back(GetDeleterOf(*nestedSoA.fRecordMemberFields[i]));
755 fSoAMemberOffsets.emplace_back(offsetInParent + nestedSoA.fSoAMemberOffsets[i]);
756 }
757}
758
760{
761 // Build a map of all subfields (nested) of the underlying record type. Map the fully qualified name of the
762 // subfields to their field pointer, so that we can later match the subfields of the SoA class to their corresponding
763 // fields in the underlying record type. Note that the members of the SoA class and the underlying record type
764 // can have different ordering. However, the base classes of the SoA class and the underlying record type must match
765 // in order.
766
767 std::vector<RFieldBase *> realRecordMemberFields; // Contains all subfields of the underlying record type
768 // Qualified field name --> index in realRecordMemberFields
769 std::unordered_map<std::string, std::size_t> recordFieldNameToIdx;
770
771 // Count the top-level subfields of the underlying record type for cross-check with the SoA type
772 unsigned int nDirectRecordSubfields = 0;
773 unsigned int nDirectRecordBases = 0;
774
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++;
779 } else {
780 nDirectRecordSubfields++;
781 }
782 }
783
784 // Build the qualified field name for matching. We root the qualified field name at the underlying record type.
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();
790 }
791 recordFieldNameToIdx[qualifiedName] = realRecordMemberFields.size();
792
793 realRecordMemberFields.emplace_back(&(*itr));
794 }
795
796 // Base classes are treated as unrolled nested SoA classes
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"));
801 }
802 unsigned int baseIdx = 0;
803 for (auto base : ROOT::Detail::TRangeStaticCast<TBaseClass>(*fClass->GetListOfBases())) {
804 if (base->GetDelta() < 0) {
805 throw RException(R__FAIL(std::string("virtual inheritance is not supported: ") + GetTypeName() +
806 " virtually inherits from " + base->GetName()));
807 }
808 TClass *cl = base->GetClassPointer();
809
810 const auto baseFieldName = std::string(":_") + std::to_string(baseIdx);
811
812 // SoA class `A` is allowed to inherit from a SoA class `B` whose underlying record type is `X` if and only if
813 // the underlying record type of `A` inherits from a type `X`.
814 const auto underlyingBaseTypeName = ROOT::Internal::GetRNTupleSoARecord(cl);
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"));
819 }
820
821 std::unique_ptr<RSoAField> soaBaseField;
822 try {
823 soaBaseField = std::make_unique<RSoAField>(baseFieldName, cl->GetName());
824 } catch (const RException &e) {
825 throw RException(R__FAIL(std::string("invalid field type in base class: ") + cl->GetName() + " of SoA field " +
826 GetFieldName() + " (" + e.what() + ")"));
827 }
828
829 GraftNestedMemberFields(*soaBaseField, base->GetDelta(), [&](const std::string &name) {
830 return realRecordMemberFields[recordFieldNameToIdx[name]];
831 });
832
833 for (const RRule &r : soaBaseField->fRules) {
834 fRules.emplace_back(r);
835 fRules.back().fOffset += base->GetDelta();
836 }
837
838 baseIdx++;
839 }
840
841 unsigned int nMembers = 0;
842 for (auto dataMember : ROOT::Detail::TRangeStaticCast<TDataMember>(*fClass->GetListOfDataMembers())) {
843 // NOTE: ReconstructSplitFields() will also traverse the data members and need to apply the same rules for
844 // skipping members
845
846 if ((dataMember->Property() & kIsStatic) || !dataMember->IsPersistent())
847 continue;
848
849 if (dataMember->Property() & kIsArray) {
850 throw RException(R__FAIL(std::string("unsupported array type in SoA class: ") + dataMember->GetName()));
851 }
852
853 const std::string typeName{dataMember->GetTrueTypeName()};
854 auto dmField = RFieldBase::Create(dataMember->GetName(), typeName).Unwrap();
855
856 auto itr = recordFieldNameToIdx.find(dmField->GetFieldName());
857 if (itr == recordFieldNameToIdx.end()) {
858 throw RException(R__FAIL(std::string("unexpected SoA member: ") + dmField->GetFieldName()));
859 }
860 auto underlyingField = realRecordMemberFields[itr->second];
861 assert(dmField->GetFieldName() == underlyingField->GetFieldName());
862
863 if (auto soaField = dynamic_cast<RSoAField *>(dmField.get())) {
864 if (ROOT::Internal::GetRNTupleSoARecord(soaField->fClass) != underlyingField->GetTypeName()) {
865 throw RException(R__FAIL(std::string("nested SoA field ") + soaField->GetQualifiedFieldName() + " [" +
866 soaField->GetTypeName() + "] does not match underlying type " +
867 underlyingField->GetTypeName()));
868 }
869
870 GraftNestedMemberFields(*soaField, dataMember->GetOffset(), [&](const std::string &name) {
871 return realRecordMemberFields[recordFieldNameToIdx[name]];
872 });
873
874 for (const RRule &r : soaField->fRules) {
875 fRules.emplace_back(r);
876 fRules.back().fOffset += dataMember->GetOffset();
877 }
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 + ")"));
889 }
890
891 fRecordMemberFields.emplace_back(underlyingField);
892 fRecordMemberDeleters.emplace_back(GetDeleterOf(*underlyingField));
893 fSoAMemberOffsets.emplace_back(dataMember->GetOffset());
894 } else {
895 throw RException(R__FAIL("invalid field type in SoA class: " + dmField->GetTypeName()));
896 }
897
898 nMembers++;
899 }
900 if (nDirectRecordSubfields != nMembers) {
901 throw RException(R__FAIL("missing SoA members"));
902 }
903
904 auto schemaRules = FindRules(nullptr);
905 for (const auto &r : schemaRules)
906 fRules.emplace_back(RRule{r, 0});
907}
908
909ROOT::RSoAField::RSoAField(std::string_view fieldName, TClass *clSoA)
910 : ROOT::RRuleField(fieldName, GetRenormalizedTypeName(clSoA->GetName()), clSoA, ROOT::ENTupleStructure::kCollection)
911{
912 EnsureValidUserClass(fClass, *this, "RSoAField");
913 const auto recordTypeName = ROOT::Internal::GetRNTupleSoARecord(fClass);
914 if (recordTypeName.empty()) {
915 throw ROOT::RException(R__FAIL(std::string("class ") + GetTypeName() +
916 " is not marked with the rntupleSoARecord "
917 "dictionary option; cannot create corresponding RSoAField."));
918 }
919 try {
920 Attach(std::make_unique<ROOT::RClassField>("_0", recordTypeName));
921 } catch (ROOT::RException &e) {
922 throw RException(R__FAIL("invalid record type of SoA field " + GetTypeName() + " [" + e.what() + "]"));
923 }
924 if (fClass->GetClassVersion() <= 0) {
925 throw RException(R__FAIL(std::string("SoA class ") + GetTypeName() + " is transient or unversioned."));
926 }
927 if (static_cast<std::uint32_t>(fClass->GetClassVersion()) != fSubfields[0]->GetTypeVersion()) {
928 throw RException(R__FAIL(std::string("version mismatch between SoA type and underlying record type: ") +
929 std::to_string(fClass->GetClassVersion()) + " vs. " +
930 std::to_string(fSubfields[0]->GetTypeVersion())));
931 }
932
934
935 std::string renormalizedAlias;
936 if (ROOT::Internal::NeedsMetaNameAsAlias(fClass->GetName(), renormalizedAlias))
937 SetTypeAlias(renormalizedAlias);
938
940 fLockSplitFields = std::make_unique<std::mutex>();
941}
942
943std::unique_ptr<ROOT::RFieldBase> ROOT::RSoAField::CloneImpl(std::string_view newName) const
944{
945 return std::unique_ptr<RSoAField>(new RSoAField(newName, *this));
946}
947
957
959{
960 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
961}
962
964{
965 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
966}
967
968std::size_t ROOT::RSoAField::AppendImpl(const void *from)
969{
970 const std::size_t nSoAMembers = fSoAMemberOffsets.size();
971
972 std::size_t N = 0; // Set by first SoA member and verified for the rest
973 for (std::size_t i = 0; i < nSoAMembers; ++i) {
974 const void *rvecPtr = static_cast<const unsigned char *>(from) + fSoAMemberOffsets[i];
975 auto [beginPtr, sizePtr, _] = ROOT::Internal::GetRVecDataMembers(rvecPtr);
976 assert(*sizePtr >= 0);
977 if (i == 0) {
978 N = *sizePtr;
979 } else {
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)"));
984 }
985 }
986 }
987
988 std::size_t nbytes = 0;
989 if (N > 0) {
990 for (std::size_t i = 0; i < nSoAMembers; ++i) {
991 const void *rvecPtr = static_cast<const unsigned char *>(from) + fSoAMemberOffsets[i];
992 auto [beginPtr, _, __] = ROOT::Internal::GetRVecDataMembers(rvecPtr);
993 RFieldBase *memberField = fRecordMemberFields[i];
994 if (memberField->IsSimple()) {
995 GetPrincipalColumnOf(*memberField)->ForWriting()->AppendV(*beginPtr, N);
996 nbytes += N * GetPrincipalColumnOf(*memberField)->GetElement()->GetPackedSize();
997 } else {
998 for (std::size_t j = 0; j < N; ++j) {
999 nbytes += CallAppendOn(*memberField, *beginPtr + j * memberField->GetValueSize());
1000 }
1001 }
1002 }
1003 }
1004
1005 fNWritten += N;
1006 fPrincipalColumn->ForWriting()->Append(&fNWritten);
1007 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1008}
1009
1011{
1012 // Read collection info for this entry
1014 RNTupleLocalIndex collectionStart;
1015 fPrincipalColumn->ForReading()->GetCollectionInfo(globalIndex, &collectionStart, &N);
1016
1017 const auto nSoAMembers = fSoAMemberOffsets.size();
1018 for (std::size_t i = 0; i < nSoAMembers; ++i) {
1019 RFieldBase *memberField = fRecordMemberFields[i];
1020 const auto memberSize = memberField->GetValueSize();
1021 void *rvecPtr = static_cast<unsigned char *>(to) + fSoAMemberOffsets[i];
1022 auto begin = ROOT::RRVecField::ResizeRVec(rvecPtr, N, memberSize, memberField, fRecordMemberDeleters[i].get());
1023
1024 if (N == 0)
1025 continue;
1026
1027 if (memberField->IsSimple()) {
1028 GetPrincipalColumnOf(*memberField)->ForReading()->ReadV(collectionStart, N, begin);
1029 } else {
1030 if (memberField->IsArtificial()) {
1031 // Other artificial fields simply don't read at all. This does not work here because then
1032 // the vector elements of trivial types would be left uninitialized (complex types explicitly call
1033 // the constructor on vector resize). Thus we explicitly default-initialize trivial types.
1034 // Note that this causes a subtle difference in behavior: if the added member is default-initialized to
1035 // a non-zero value, this will be forgotten in the SoA layout.
1036 if (memberField->GetTraits() & kTraitTriviallyConstructible) {
1037 std::memset(begin, 0, N * memberSize);
1038 }
1039 } else {
1040 for (std::size_t j = 0; j < N; ++j) {
1041 CallReadOn(*memberField, collectionStart + j, begin + (j * memberSize));
1042 }
1043 }
1044 }
1045 }
1046
1047 InvokeRuleFuncs(to);
1048}
1049
1050std::unique_ptr<ROOT::RFieldBase> ROOT::RSoAField::BeforeConnectPageSource(ROOT::Internal::RPageSource & /*pageSource*/)
1051{
1052 // Most of the heavy lifting is done by the actual subfields that map onto the on-disk AoS schema.
1053 // In the SoA field itself, we only need to take care of the in-memory part of the rule processing.
1054 // One complication is that for non-rename rules, we manually need to recurse into base (SoA) classes and
1055 // nested (SoA) classes because we don't have them in the field tree.
1056
1057 // For now, allow only rename rules and whole-object rules
1058
1059 const bool hasSources = std::any_of(fRules.begin(), fRules.end(), [](const auto &r) {
1060 return r.fRule->GetSource() && (r.fRule->GetSource()->GetEntries() > 0);
1061 });
1062 const bool hasTargets =
1063 std::any_of(fRules.begin(), fRules.end(), [](const auto &r) { return r.fRule->GetTarget(); });
1064
1065 if (hasSources) {
1066 throw RException(R__FAIL("I/O customization rules with sources are currently unsupported for SoA fields (" +
1067 GetTypeName() + ")"));
1068 }
1069
1070 if (hasTargets) {
1071 throw RException(R__FAIL("I/O customization rules with targets are currently unsupported for SoA fields (" +
1072 GetTypeName() + ")"));
1073 }
1074
1075 for (const auto &r : fRules) {
1076 AddFuncsFromIORule(r.fRule, r.fOffset);
1077 }
1078
1079 return nullptr;
1080}
1081
1083{
1084 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1085}
1086
1087void ROOT::RSoAField::ConstructValue(void *where) const
1088{
1089 fClass->New(where);
1090}
1091
1092ROOT::RSoAField::RSoADeleter::RSoADeleter(TClass *cl) : RDeleter(cl->GetClassAlignment()), fSoAClass(cl) {}
1093
1094void ROOT::RSoAField::RSoADeleter::operator()(void *objPtr, bool dtorOnly)
1095{
1096 fSoAClass->Destructor(objPtr, true /* dtorOnly */);
1097 RDeleter::operator()(objPtr, dtorOnly);
1098}
1099
1101{
1102 std::lock_guard<std::mutex> lockGuard(*fLockSplitFields);
1103 if (fSplitFields)
1104 return;
1105
1106 fSplitFields = std::make_unique<std::vector<std::unique_ptr<ROOT::RFieldBase>>>();
1107 fSplitOffsets = std::make_unique<std::vector<std::size_t>>();
1108
1109 unsigned int baseIdx = 0;
1111 TClass *cl = base->GetClassPointer();
1112 auto baseField = RFieldBase::Create(std::string(":_" + std::to_string(baseIdx)), cl->GetName()).Unwrap();
1113 fSplitFields->emplace_back(std::move(baseField));
1114 fSplitOffsets->emplace_back(base->GetDelta());
1115 baseIdx++;
1116 }
1117
1119 if ((dataMember->Property() & kIsStatic) || !dataMember->IsPersistent())
1120 continue;
1121
1122 const std::string typeName{dataMember->GetTrueTypeName()};
1123 auto dmField = RFieldBase::Create(dataMember->GetName(), typeName).Unwrap();
1124 fSplitFields->emplace_back(std::move(dmField));
1125 fSplitOffsets->emplace_back(dataMember->GetOffset());
1126 }
1127}
1128
1129std::vector<ROOT::RFieldBase::RValue> ROOT::RSoAField::SplitValue(const RValue &value) const
1130{
1132 const auto nSplitFields = fSplitFields->size();
1133
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) {
1139 values.emplace_back((*fSplitFields)[i]->BindValue(std::shared_ptr<void>(valuePtr, soaPtr + (*fSplitOffsets)[i])));
1140 }
1141 return values;
1142}
1143
1145{
1146 return fClass->GetClassSize();
1147}
1148
1150{
1151 return fClass->GetClassVersion();
1152}
1153
1155{
1156 return fClass->GetCheckSum();
1157}
1158
1160{
1161 const auto align = fClass->GetClassAlignment();
1162 EnsureValidAlignment(align);
1163 return align;
1164}
1165
1166const std::type_info *ROOT::RSoAField::GetPolymorphicTypeInfo() const
1167{
1168 // TODO(jblomer): factor out
1169 bool polymorphic = fClass->ClassProperty() & kClassHasVirtual;
1170 if (!polymorphic) {
1171 return nullptr;
1172 }
1173 return fClass->GetTypeInfo();
1174}
1175
1177{
1178 visitor.VisitSoAField(*this);
1179}
1180
1181//------------------------------------------------------------------------------
1182
1183std::unique_ptr<ROOT::RFieldBase> ROOT::Internal::CreateEmulatedEnumField(std::string_view fieldName,
1184 std::string_view emulatedFromType,
1185 std::string_view underlyingIntType)
1186{
1187 return std::unique_ptr<RFieldBase>(new REnumField(fieldName, emulatedFromType, underlyingIntType));
1188}
1189
1190ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumName)
1191 : REnumField(fieldName, EnsureValidEnum(enumName))
1192{
1193}
1194
1195ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
1196 : ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kPlain,
1197 false /* isSimple */)
1198{
1199 // Avoid accidentally supporting std types through TEnum.
1200 if (enump->Property() & kIsDefinedInStd) {
1201 throw RException(R__FAIL(GetTypeName() + " is not supported"));
1202 }
1203
1204 switch (enump->GetUnderlyingType()) {
1205 case kBool_t: Attach(std::make_unique<RField<Bool_t>>("_0")); break;
1206 case kChar_t: Attach(std::make_unique<RField<Char_t>>("_0")); break;
1207 case kUChar_t: Attach(std::make_unique<RField<UChar_t>>("_0")); break;
1208 case kShort_t: Attach(std::make_unique<RField<Short_t>>("_0")); break;
1209 case kUShort_t: Attach(std::make_unique<RField<UShort_t>>("_0")); break;
1210 case kInt_t: Attach(std::make_unique<RField<Int_t>>("_0")); break;
1211 case kUInt_t: Attach(std::make_unique<RField<UInt_t>>("_0")); break;
1212 case kLong_t: Attach(std::make_unique<RField<Long_t>>("_0")); break;
1213 case kLong64_t: Attach(std::make_unique<RField<Long64_t>>("_0")); break;
1214 case kULong_t: Attach(std::make_unique<RField<ULong_t>>("_0")); break;
1215 case kULong64_t: Attach(std::make_unique<RField<ULong64_t>>("_0")); break;
1216 default: throw RException(R__FAIL("Unsupported underlying integral type for enum type " + GetTypeName()));
1217 }
1218
1220}
1221
1222ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumName,
1223 std::unique_ptr<RFieldBase> intField)
1224 : ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
1225{
1226 Attach(std::move(intField));
1228}
1229
1230ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view emulatedFromType,
1231 std::string_view underlyingIntType)
1232 : ROOT::RFieldBase(fieldName, emulatedFromType, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
1233{
1234 auto intField = Create("_0", std::string(underlyingIntType)).Unwrap();
1235 Attach(std::move(intField));
1237}
1238
1239std::unique_ptr<ROOT::RFieldBase> ROOT::REnumField::CloneImpl(std::string_view newName) const
1240{
1241 auto newIntField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
1242 return std::unique_ptr<REnumField>(new REnumField(newName, GetTypeName(), std::move(newIntField)));
1243}
1244
1246{
1247 // TODO(jblomer): allow enum to enum conversion only by rename rule
1248 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1249}
1250
1251std::vector<ROOT::RFieldBase::RValue> ROOT::REnumField::SplitValue(const RValue &value) const
1252{
1253 std::vector<RValue> result;
1254 result.emplace_back(fSubfields[0]->BindValue(value.GetPtr<void>()));
1255 return result;
1256}
1257
1259{
1260 visitor.VisitEnumField(*this);
1261}
1262
1263//------------------------------------------------------------------------------
1264
1265ROOT::RPairField::RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> itemFields)
1266 : ROOT::RRecordField(fieldName, "std::pair<" + GetTypeList(itemFields, false /* useTypeAliases */) + ">")
1267{
1268 Internal::EnsureTypedChildField(*itemFields[0], *this);
1269 Internal::EnsureTypedChildField(*itemFields[1], *this);
1270 const std::string typeAlias = "std::pair<" + GetTypeList(itemFields, true /* useTypeAliases */) + ">";
1271 if (typeAlias != GetTypeName())
1272 SetTypeAlias(typeAlias);
1273
1274 AttachItemFields(std::move(itemFields));
1275
1276 // ISO C++ does not guarantee any specific layout for `std::pair`; query TClass for the member offsets
1277 auto *c = TClass::GetClass(GetTypeName().c_str());
1278 if (!c) {
1280 fSubfields[0]->GetTypeName(), fSubfields[1]->GetTypeName(), true /* silent */, 0, 0);
1281 if (pairInfo)
1282 c = pairInfo->GetClass();
1283 }
1284 if (!c)
1285 throw RException(R__FAIL("cannot get type information for " + GetTypeName()));
1286 fSize = c->Size();
1287
1288 auto firstElem = c->GetRealData("first");
1289 if (!firstElem)
1290 throw RException(R__FAIL("first: no such member"));
1291 fOffsets.push_back(firstElem->GetThisOffset());
1292
1293 auto secondElem = c->GetRealData("second");
1294 if (!secondElem)
1295 throw RException(R__FAIL("second: no such member"));
1296 fOffsets.push_back(secondElem->GetThisOffset());
1297}
1298
1299std::unique_ptr<ROOT::RFieldBase> ROOT::RPairField::CloneImpl(std::string_view newName) const
1300{
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)));
1304}
1305
1307{
1308 static const std::vector<std::string> prefixes = {"std::pair<", "std::tuple<"};
1309
1310 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1311 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
1312
1313 const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
1314 const auto nOnDiskSubfields = fieldDesc.GetLinkIds().size();
1315 if (nOnDiskSubfields != 2) {
1316 throw ROOT::RException(R__FAIL("invalid number of on-disk subfields for std::pair " +
1317 std::to_string(nOnDiskSubfields) + "\n" +
1318 Internal::GetTypeTraceReport(*this, desc)));
1319 }
1320}
1321
1322//------------------------------------------------------------------------------
1323
1326 bool readFromDisk)
1327{
1328 RIteratorFuncs ifuncs;
1329 ifuncs.fCreateIterators = proxy->GetFunctionCreateIterators(readFromDisk);
1330 ifuncs.fDeleteTwoIterators = proxy->GetFunctionDeleteTwoIterators(readFromDisk);
1331 ifuncs.fNext = proxy->GetFunctionNext(readFromDisk);
1332 R__ASSERT((ifuncs.fCreateIterators != nullptr) && (ifuncs.fDeleteTwoIterators != nullptr) &&
1333 (ifuncs.fNext != nullptr));
1334 return ifuncs;
1335}
1336
1338 : RFieldBase(fieldName, GetRenormalizedTypeName(classp->GetName()), ROOT::ENTupleStructure::kCollection,
1339 false /* isSimple */),
1340 fNWritten(0)
1341{
1342 if (!classp->GetCollectionProxy())
1343 throw RException(R__FAIL(std::string(classp->GetName()) + " has no associated collection proxy"));
1344 if (classp->Property() & kIsDefinedInStd) {
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) {
1350 if (GetTypeName().rfind(tn, 0) == 0) {
1351 isSupported = true;
1352 break;
1353 }
1354 }
1355 if (!isSupported)
1356 throw RException(R__FAIL(std::string(GetTypeName()) + " is not supported"));
1357 }
1358
1359 std::string renormalizedAlias;
1360 if (Internal::NeedsMetaNameAsAlias(classp->GetName(), renormalizedAlias))
1361 SetTypeAlias(renormalizedAlias);
1362
1363 fProxy.reset(classp->GetCollectionProxy()->Generate());
1364 fProperties = fProxy->GetProperties();
1365 fCollectionType = fProxy->GetCollectionType();
1366 if (fProxy->HasPointers())
1367 throw RException(R__FAIL("collection proxies whose value type is a pointer are not supported"));
1368
1369 fIFuncsRead = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(), true /* readFromDisk */);
1370 fIFuncsWrite = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(), false /* readFromDisk */);
1371}
1372
1373ROOT::RProxiedCollectionField::RProxiedCollectionField(std::string_view fieldName, std::string_view typeName)
1374 : RProxiedCollectionField(fieldName, EnsureValidClass(typeName))
1375{
1376 // NOTE (fdegeus): std::map is supported, custom associative might be supported in the future if the need arises.
1378 throw RException(R__FAIL("custom associative collection proxies not supported"));
1379
1380 std::unique_ptr<ROOT::RFieldBase> itemField;
1381
1382 if (auto valueClass = fProxy->GetValueClass()) {
1383 // Element type is a class
1384 itemField = RFieldBase::Create("_0", valueClass->GetName()).Unwrap();
1385 } else {
1386 switch (fProxy->GetType()) {
1387 case EDataType::kChar_t: itemField = std::make_unique<RField<Char_t>>("_0"); break;
1388 case EDataType::kUChar_t: itemField = std::make_unique<RField<UChar_t>>("_0"); break;
1389 case EDataType::kShort_t: itemField = std::make_unique<RField<Short_t>>("_0"); break;
1390 case EDataType::kUShort_t: itemField = std::make_unique<RField<UShort_t>>("_0"); break;
1391 case EDataType::kInt_t: itemField = std::make_unique<RField<Int_t>>("_0"); break;
1392 case EDataType::kUInt_t: itemField = std::make_unique<RField<UInt_t>>("_0"); break;
1393 case EDataType::kLong_t: itemField = std::make_unique<RField<Long_t>>("_0"); break;
1394 case EDataType::kLong64_t: itemField = std::make_unique<RField<Long64_t>>("_0"); break;
1395 case EDataType::kULong_t: itemField = std::make_unique<RField<ULong_t>>("_0"); break;
1396 case EDataType::kULong64_t: itemField = std::make_unique<RField<ULong64_t>>("_0"); break;
1397 case EDataType::kFloat_t: itemField = std::make_unique<RField<Float_t>>("_0"); break;
1398 case EDataType::kDouble_t: itemField = std::make_unique<RField<Double_t>>("_0"); break;
1399 case EDataType::kBool_t: itemField = std::make_unique<RField<Bool_t>>("_0"); break;
1400 default: throw RException(R__FAIL("unsupported value type: " + std::to_string(fProxy->GetType())));
1401 }
1402 }
1403
1404 fItemSize = itemField->GetValueSize();
1405 Attach(std::move(itemField));
1406}
1407
1408std::unique_ptr<ROOT::RFieldBase> ROOT::RProxiedCollectionField::CloneImpl(std::string_view newName) const
1409{
1410 auto clone =
1411 std::unique_ptr<RProxiedCollectionField>(new RProxiedCollectionField(newName, fProxy->GetCollectionClass()));
1412 clone->fItemSize = fItemSize;
1413 clone->Attach(fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1414 return clone;
1415}
1416
1418{
1419 std::size_t nbytes = 0;
1420 unsigned count = 0;
1421 TVirtualCollectionProxy::TPushPop RAII(fProxy.get(), const_cast<void *>(from));
1422 for (auto ptr : RCollectionIterableOnce{const_cast<void *>(from), fIFuncsWrite, fProxy.get(),
1423 (fCollectionType == kSTLvector ? fItemSize : 0U)}) {
1424 nbytes += CallAppendOn(*fSubfields[0], ptr);
1425 count++;
1426 }
1427
1428 fNWritten += count;
1429 fPrincipalColumn->ForWriting()->Append(&fNWritten);
1430 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1431}
1432
1434{
1435 ROOT::NTupleSize_t nItems;
1436 RNTupleLocalIndex collectionStart;
1437 fPrincipalColumn->ForReading()->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1438
1439 TVirtualCollectionProxy::TPushPop RAII(fProxy.get(), to);
1440 void *obj =
1441 fProxy->Allocate(static_cast<std::uint32_t>(nItems), (fProperties & TVirtualCollectionProxy::kNeedDelete));
1442
1443 unsigned i = 0;
1444 for (auto elementPtr : RCollectionIterableOnce{obj, fIFuncsRead, fProxy.get(),
1445 (fCollectionType == kSTLvector || obj != to ? fItemSize : 0U)}) {
1446 CallReadOn(*fSubfields[0], collectionStart + (i++), elementPtr);
1447 }
1448 if (obj != to)
1449 fProxy->Commit(obj);
1450}
1451
1461
1463{
1464 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
1465}
1466
1468{
1469 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
1470}
1471
1473{
1474 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1475}
1476
1478{
1479 fProxy->New(where);
1480}
1481
1482std::unique_ptr<ROOT::RFieldBase::RDeleter> ROOT::RProxiedCollectionField::GetDeleter() const
1483{
1484 if (fProperties & TVirtualCollectionProxy::kNeedDelete) {
1485 std::size_t itemSize = fCollectionType == kSTLvector ? fItemSize : 0U;
1486 return std::make_unique<RProxiedCollectionDeleter>(fProxy, GetDeleterOf(*fSubfields[0]), itemSize);
1487 }
1488 return std::make_unique<RProxiedCollectionDeleter>(fProxy);
1489}
1490
1492 std::shared_ptr<TVirtualCollectionProxy> proxy)
1493 : RDeleter(proxy->GetCollectionClass()->GetClassAlignment()), fProxy(std::move(proxy))
1494{
1495}
1496
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)),
1502 fItemSize(itemSize)
1503{
1504 fIFuncsWrite = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(), false /* readFromDisk */);
1505}
1506
1508{
1509 if (fItemDeleter) {
1510 TVirtualCollectionProxy::TPushPop RAII(fProxy.get(), objPtr);
1511 for (auto ptr : RCollectionIterableOnce{objPtr, fIFuncsWrite, fProxy.get(), fItemSize}) {
1512 fItemDeleter->operator()(ptr, true /* dtorOnly */);
1513 }
1514 }
1515 fProxy->Destructor(objPtr, true /* dtorOnly */);
1516 RDeleter::operator()(objPtr, dtorOnly);
1517}
1518
1519std::vector<ROOT::RFieldBase::RValue> ROOT::RProxiedCollectionField::SplitValue(const RValue &value) const
1520{
1521 std::vector<RValue> result;
1522 auto valueRawPtr = value.GetPtr<void>().get();
1523 TVirtualCollectionProxy::TPushPop RAII(fProxy.get(), valueRawPtr);
1524 for (auto ptr : RCollectionIterableOnce{valueRawPtr, fIFuncsWrite, fProxy.get(),
1525 (fCollectionType == kSTLvector ? fItemSize : 0U)}) {
1526 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(value.GetPtr<void>(), ptr)));
1527 }
1528 return result;
1529}
1530
1532{
1533 return fProxy->Sizeof();
1534}
1535
1537{
1538 const auto align = fProxy->GetCollectionClass()->GetClassAlignment();
1539 EnsureValidAlignment(align);
1540 return align;
1541}
1542
1547
1548//------------------------------------------------------------------------------
1549
1550ROOT::RMapField::RMapField(std::string_view fieldName, EMapType mapType, std::unique_ptr<RFieldBase> itemField)
1551 : RProxiedCollectionField(fieldName,
1552 EnsureValidClass(BuildMapTypeName(mapType, itemField.get(), false /* useTypeAliases */))),
1553 fMapType(mapType)
1554{
1555 Internal::EnsureTypedChildField(*itemField, *this);
1556 if (!itemField->GetTypeAlias().empty())
1557 SetTypeAlias(BuildMapTypeName(mapType, itemField.get(), true /* useTypeAliases */));
1558
1559 auto *itemClass = fProxy->GetValueClass();
1560 fItemSize = itemClass->GetClassSize();
1561
1562 Attach(std::move(itemField), "_0");
1563}
1564
1565std::unique_ptr<ROOT::RFieldBase> ROOT::RMapField::CloneImpl(std::string_view newName) const
1566{
1567 return std::make_unique<RMapField>(newName, fMapType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1568}
1569
1571{
1572 static const std::vector<std::string> prefixesRegular = {"std::map<", "std::unordered_map<"};
1573
1574 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1575
1576 switch (fMapType) {
1577 case EMapType::kMap:
1578 case EMapType::kUnorderedMap: EnsureMatchingTypePrefix(desc, prefixesRegular).ThrowOnError(); break;
1579 default:
1580 break;
1581 // no restrictions for multimaps
1582 }
1583}
1584
1585//------------------------------------------------------------------------------
1586
1587ROOT::RSetField::RSetField(std::string_view fieldName, ESetType setType, std::unique_ptr<RFieldBase> itemField)
1588 : ROOT::RProxiedCollectionField(fieldName,
1589 EnsureValidClass(BuildSetTypeName(setType, *itemField, false /* useTypeAlias */))),
1590 fSetType(setType)
1591{
1592 if (!itemField->GetTypeAlias().empty())
1593 SetTypeAlias(BuildSetTypeName(setType, *itemField, true /* useTypeAlias */));
1594
1595 fItemSize = itemField->GetValueSize();
1596
1597 Attach(std::move(itemField), "_0");
1598}
1599
1600std::unique_ptr<ROOT::RFieldBase> ROOT::RSetField::CloneImpl(std::string_view newName) const
1601{
1602 return std::make_unique<RSetField>(newName, fSetType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName()));
1603}
1604
1606{
1607 static const std::vector<std::string> prefixesRegular = {"std::set<", "std::unordered_set<", "std::map<",
1608 "std::unordered_map<"};
1609
1610 EnsureMatchingOnDiskCollection(desc).ThrowOnError();
1611
1612 switch (fSetType) {
1613 case ESetType::kSet:
1614 case ESetType::kUnorderedSet: EnsureMatchingTypePrefix(desc, prefixesRegular).ThrowOnError(); break;
1615 default:
1616 break;
1617 // no restrictions for multisets
1618 }
1619}
1620
1621//------------------------------------------------------------------------------
1622
1623namespace {
1624
1625/// Used in RStreamerField::AppendImpl() in order to record the encountered streamer info records
1626class TBufferRecStreamer : public TBufferFile {
1627public:
1628 using RCallbackStreamerInfo = std::function<void(TVirtualStreamerInfo *)>;
1629
1630private:
1631 RCallbackStreamerInfo fCallbackStreamerInfo;
1632
1633public:
1634 TBufferRecStreamer(TBuffer::EMode mode, Int_t bufsize, RCallbackStreamerInfo callbackStreamerInfo)
1635 : TBufferFile(mode, bufsize), fCallbackStreamerInfo(std::move(callbackStreamerInfo))
1636 {
1637 }
1638 void TagStreamerInfo(TVirtualStreamerInfo *info) final { fCallbackStreamerInfo(info); }
1639};
1640
1641} // anonymous namespace
1642
1643ROOT::RStreamerField::RStreamerField(std::string_view fieldName, std::string_view className)
1644 : RStreamerField(fieldName, EnsureValidClass(className))
1645{
1646}
1647
1648ROOT::RStreamerField::RStreamerField(std::string_view fieldName, TClass *classp)
1649 : ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(classp->GetName()), ROOT::ENTupleStructure::kStreamer,
1650 false /* isSimple */),
1651 fClass(classp),
1652 fIndex(0)
1653{
1655 throw RException(R__FAIL("streamer field " + GetFieldName() + " requires at least an emulated class"));
1658
1659 std::string renormalizedAlias;
1660 if (Internal::NeedsMetaNameAsAlias(classp->GetName(), renormalizedAlias))
1661 SetTypeAlias(renormalizedAlias);
1662
1664 // For RClassField, we only check for explicit constructors and destructors and then recursively combine traits from
1665 // all member subfields. For RStreamerField, we treat the class as a black box and additionally need to check for
1666 // implicit constructors and destructors.
1671}
1672
1673std::unique_ptr<ROOT::RFieldBase> ROOT::RStreamerField::CloneImpl(std::string_view newName) const
1674{
1675 // To get the correct TClass instance in the clone, we clone using the un-normalized type name
1676 return std::unique_ptr<RStreamerField>(new RStreamerField(newName, fClass->GetName()));
1677}
1678
1679std::size_t ROOT::RStreamerField::AppendImpl(const void *from)
1680{
1681 TBufferRecStreamer buffer(TBuffer::kWrite, GetValueSize(),
1682 [this](TVirtualStreamerInfo *info) { fStreamerInfos[info->GetNumber()] = info; });
1683 fClass->Streamer(const_cast<void *>(from), buffer);
1684
1685 auto nbytes = buffer.Length();
1686 fAuxiliaryColumn->ForWriting()->AppendV(buffer.Buffer(), buffer.Length());
1687 fIndex += nbytes;
1688 fPrincipalColumn->ForWriting()->Append(&fIndex);
1689 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
1690}
1691
1693{
1694 RNTupleLocalIndex collectionStart;
1695 ROOT::NTupleSize_t nbytes;
1696 fPrincipalColumn->ForReading()->GetCollectionInfo(globalIndex, &collectionStart, &nbytes);
1697
1698 TBufferFile buffer(TBuffer::kRead, nbytes);
1699 fAuxiliaryColumn->ForReading()->ReadV(collectionStart, nbytes, buffer.Buffer());
1700 fClass->Streamer(to, buffer);
1701}
1702
1712
1714{
1715 GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>();
1716}
1717
1719{
1720 GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>(desc);
1721}
1722
1724{
1725 source.RegisterStreamerInfos();
1726 return nullptr;
1727}
1728
1730{
1731 EnsureMatchingOnDiskField(desc, kDiffTypeName | kDiffTypeVersion).ThrowOnError();
1732}
1733
1735{
1736 fClass->New(where);
1737}
1738
1743
1745{
1746 fClass->Destructor(objPtr, true /* dtorOnly */);
1747 RDeleter::operator()(objPtr, dtorOnly);
1748}
1749
1759
1761{
1762 const auto align = fClass->GetClassAlignment();
1763 EnsureValidAlignment(align);
1764 return align;
1765}
1766
1768{
1769 return fClass->GetClassSize();
1770}
1771
1773{
1774 return fClass->GetClassVersion();
1775}
1776
1778{
1779 return fClass->GetCheckSum();
1780}
1781
1783{
1784 visitor.VisitStreamerField(*this);
1785}
1786
1787//------------------------------------------------------------------------------
1788
1790{
1791 if (auto dataMember = TObject::Class()->GetDataMember(name)) {
1792 return dataMember->GetOffset();
1793 }
1794 throw RException(R__FAIL('\'' + std::string(name) + '\'' + " is an invalid data member"));
1795}
1796
1797ROOT::RField<TObject>::RField(std::string_view fieldName, const RField<TObject> &source)
1798 : ROOT::RFieldBase(fieldName, "TObject", ROOT::ENTupleStructure::kRecord, false /* isSimple */)
1799{
1801 Attach(source.GetConstSubfields()[0]->Clone("fUniqueID"));
1802 Attach(source.GetConstSubfields()[1]->Clone("fBits"));
1803}
1804
1805ROOT::RField<TObject>::RField(std::string_view fieldName)
1806 : ROOT::RFieldBase(fieldName, "TObject", ROOT::ENTupleStructure::kRecord, false /* isSimple */)
1807{
1808 assert(TObject::Class()->GetClassVersion() == 1);
1809
1811 Attach(std::make_unique<RField<UInt_t>>("fUniqueID"));
1812 Attach(std::make_unique<RField<UInt_t>>("fBits"));
1813}
1814
1815std::unique_ptr<ROOT::RFieldBase> ROOT::RField<TObject>::CloneImpl(std::string_view newName) const
1816{
1817 return std::unique_ptr<RField<TObject>>(new RField<TObject>(newName, *this));
1818}
1819
1820std::size_t ROOT::RField<TObject>::AppendImpl(const void *from)
1821{
1822 // Cf. TObject::Streamer()
1823
1824 auto *obj = static_cast<const TObject *>(from);
1825 if (obj->TestBit(TObject::kIsReferenced)) {
1826 throw RException(R__FAIL("RNTuple I/O on referenced TObject is unsupported"));
1827 }
1828
1829 std::size_t nbytes = 0;
1830 nbytes += CallAppendOn(*fSubfields[0], reinterpret_cast<const unsigned char *>(from) + GetOffsetUniqueID());
1831
1832 UInt_t bits = *reinterpret_cast<const UInt_t *>(reinterpret_cast<const unsigned char *>(from) + GetOffsetBits());
1833 bits &= (~TObject::kIsOnHeap & ~TObject::kNotDeleted);
1834 nbytes += CallAppendOn(*fSubfields[1], &bits);
1835
1836 return nbytes;
1837}
1838
1840{
1841 // Cf. TObject::Streamer()
1842
1843 auto *obj = static_cast<TObject *>(to);
1844 if (obj->TestBit(TObject::kIsReferenced)) {
1845 throw RException(R__FAIL("RNTuple I/O on referenced TObject is unsupported"));
1846 }
1847
1848 *reinterpret_cast<UInt_t *>(reinterpret_cast<unsigned char *>(to) + GetOffsetUniqueID()) = uniqueID;
1849
1850 const UInt_t bitIsOnHeap = obj->TestBit(TObject::kIsOnHeap) ? TObject::kIsOnHeap : 0;
1851 bits |= bitIsOnHeap | TObject::kNotDeleted;
1852 *reinterpret_cast<UInt_t *>(reinterpret_cast<unsigned char *>(to) + GetOffsetBits()) = bits;
1853}
1854
1856{
1857 UInt_t uniqueID, bits;
1858 CallReadOn(*fSubfields[0], globalIndex, &uniqueID);
1859 CallReadOn(*fSubfields[1], globalIndex, &bits);
1860 ReadTObject(to, uniqueID, bits);
1861}
1862
1864{
1865 UInt_t uniqueID, bits;
1866 CallReadOn(*fSubfields[0], localIndex, &uniqueID);
1867 CallReadOn(*fSubfields[1], localIndex, &bits);
1868 ReadTObject(to, uniqueID, bits);
1869}
1870
1872{
1873 return TObject::Class()->GetClassVersion();
1874}
1875
1877{
1878 return TObject::Class()->GetCheckSum();
1879}
1880
1882{
1883 new (where) TObject();
1884}
1885
1886std::vector<ROOT::RFieldBase::RValue> ROOT::RField<TObject>::SplitValue(const RValue &value) const
1887{
1888 std::vector<RValue> result;
1889 // Use GetPtr<TObject> to type-check
1890 std::shared_ptr<void> ptr = value.GetPtr<TObject>();
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())));
1894 return result;
1895}
1896
1898{
1899 return sizeof(TObject);
1900}
1901
1903{
1904 return alignof(TObject);
1905}
1906
1908{
1909 visitor.VisitTObjectField(*this);
1910}
1911
1912//------------------------------------------------------------------------------
1913
1914ROOT::RTupleField::RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> itemFields)
1915 : ROOT::RRecordField(fieldName, "std::tuple<" + GetTypeList(itemFields, false /* useTypeAliases */) + ">")
1916{
1917 for (const auto &f : itemFields) {
1919 }
1920 const std::string typeAlias = "std::tuple<" + GetTypeList(itemFields, true /* useTypeAliases */) + ">";
1921 if (typeAlias != GetTypeName())
1922 SetTypeAlias(typeAlias);
1923
1924 AttachItemFields(std::move(itemFields));
1925
1926 auto *c = TClass::GetClass(GetTypeName().c_str());
1927 if (!c)
1928 throw RException(R__FAIL("cannot get type information for " + GetTypeName()));
1929 fSize = c->Size();
1930
1931 // ISO C++ does not guarantee neither specific layout nor member names for `std::tuple`. However, most
1932 // implementations including libstdc++ (gcc), libc++ (llvm), and MSVC name members as `_0`, `_1`, ..., `_N-1`,
1933 // following the order of the type list.
1934 // Use TClass to get their offsets; in case a particular `std::tuple` implementation does not define such
1935 // members, the assertion below will fail.
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());
1939 if (!member)
1940 throw RException(R__FAIL(memberName + ": no such member"));
1941 fOffsets.push_back(member->GetThisOffset());
1942 }
1943}
1944
1945std::unique_ptr<ROOT::RFieldBase> ROOT::RTupleField::CloneImpl(std::string_view newName) const
1946{
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()));
1951 }
1952 return std::unique_ptr<RTupleField>(new RTupleField(newName, std::move(itemClones)));
1953}
1954
1956{
1957 static const std::vector<std::string> prefixes = {"std::pair<", "std::tuple<"};
1958
1959 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1960 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
1961
1962 const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
1963 const auto nOnDiskSubfields = fieldDesc.GetLinkIds().size();
1964 const auto nSubfields = fSubfields.size();
1965 if (nOnDiskSubfields != nSubfields) {
1966 throw ROOT::RException(R__FAIL("invalid number of on-disk subfields for std::tuple " +
1967 std::to_string(nOnDiskSubfields) + " vs. " + std::to_string(nSubfields) + "\n" +
1968 Internal::GetTypeTraceReport(*this, desc)));
1969 }
1970}
1971
1972//------------------------------------------------------------------------------
1973
1974namespace {
1975
1976// Depending on the compiler, the variant tag is stored either in a trailing char or in a trailing unsigned int
1977constexpr std::size_t GetVariantTagSize()
1978{
1979 // Should be all zeros except for the tag, which is 1
1980 std::variant<char> t;
1981 constexpr auto sizeOfT = sizeof(t);
1982
1983 static_assert(sizeOfT == 2 || sizeOfT == 8, "unsupported std::variant layout");
1984 return sizeOfT == 2 ? 1 : 4;
1985}
1986
1987template <std::size_t VariantSizeT>
1988struct RVariantTag {
1989 using ValueType_t = typename std::conditional_t<VariantSizeT == 1, std::uint8_t,
1990 typename std::conditional_t<VariantSizeT == 4, std::uint32_t, void>>;
1991};
1992
1993} // anonymous namespace
1994
1996 : ROOT::RFieldBase(name, source.GetTypeName(), ROOT::ENTupleStructure::kVariant, false /* isSimple */),
1997 fMaxItemSize(source.fMaxItemSize),
1998 fMaxAlignment(source.fMaxAlignment),
1999 fTagOffset(source.fTagOffset),
2000 fVariantOffset(source.fVariantOffset),
2001 fNWritten(source.fNWritten.size(), 0)
2002{
2003 for (const auto &f : source.GetConstSubfields())
2004 Attach(f->Clone(f->GetFieldName()));
2005 fTraits = source.fTraits;
2006}
2007
2008ROOT::RVariantField::RVariantField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> itemFields)
2009 : ROOT::RFieldBase(fieldName, "std::variant<" + GetTypeList(itemFields, false /* useTypeAliases */) + ">",
2010 ROOT::ENTupleStructure::kVariant, false /* isSimple */)
2011{
2012 for (const auto &f : itemFields) {
2014 }
2015 // The variant needs to initialize its own tag member
2016 fTraits |= kTraitTriviallyDestructible & ~kTraitTriviallyConstructible;
2017
2018 const std::string typeAlias = "std::variant<" + GetTypeList(itemFields, true /* useTypeAliases */) + ">";
2019 if (typeAlias != GetTypeName())
2020 SetTypeAlias(typeAlias);
2021
2022 auto nFields = itemFields.size();
2023 if (nFields == 0 || nFields > kMaxVariants) {
2024 throw RException(R__FAIL("invalid number of variant fields (outside [1.." + std::to_string(kMaxVariants) + ")"));
2025 }
2026 fNWritten.resize(nFields, 0);
2027 for (unsigned int i = 0; i < nFields; ++i) {
2028 fMaxItemSize = std::max(fMaxItemSize, itemFields[i]->GetValueSize());
2029 fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment());
2030 fTraits &= itemFields[i]->GetTraits();
2031 Attach(std::move(itemFields[i]), "_" + std::to_string(i));
2032 }
2033
2034 // With certain template parameters, the union of members of an std::variant starts at an offset > 0.
2035 // For instance, std::variant<std::optional<int>> on macOS.
2036 auto cl = TClass::GetClass(GetTypeName().c_str());
2037 assert(cl);
2038 auto dm = reinterpret_cast<TDataMember *>(cl->GetListOfDataMembers()->First());
2039 if (dm)
2040 fVariantOffset = dm->GetOffset();
2041
2042 const auto tagSize = GetVariantTagSize();
2043 const auto padding = tagSize - (fMaxItemSize % tagSize);
2044 fTagOffset = fVariantOffset + fMaxItemSize + ((padding == tagSize) ? 0 : padding);
2045}
2046
2047std::unique_ptr<ROOT::RFieldBase> ROOT::RVariantField::CloneImpl(std::string_view newName) const
2048{
2049 return std::unique_ptr<RVariantField>(new RVariantField(newName, *this));
2050}
2051
2052std::uint8_t ROOT::RVariantField::GetTag(const void *variantPtr, std::size_t tagOffset)
2053{
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;
2057}
2058
2059void ROOT::RVariantField::SetTag(void *variantPtr, std::size_t tagOffset, std::uint8_t tag)
2060{
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);
2064}
2065
2066std::size_t ROOT::RVariantField::AppendImpl(const void *from)
2067{
2068 auto tag = GetTag(from, fTagOffset);
2069 std::size_t nbytes = 0;
2070 auto index = 0;
2071 if (tag > 0) {
2072 nbytes += CallAppendOn(*fSubfields[tag - 1], reinterpret_cast<const unsigned char *>(from) + fVariantOffset);
2073 index = fNWritten[tag - 1]++;
2074 }
2075 ROOT::Internal::RColumnSwitch varSwitch(index, tag);
2076 fPrincipalColumn->ForWriting()->Append(&varSwitch);
2077 return nbytes + sizeof(ROOT::Internal::RColumnSwitch);
2078}
2079
2081{
2082 RNTupleLocalIndex variantIndex;
2083 std::uint32_t tag;
2084 fPrincipalColumn->ForReading()->GetSwitchInfo(globalIndex, &variantIndex, &tag);
2085 R__ASSERT(tag < 256);
2086
2087 // If `tag` equals 0, the variant is in the invalid state, i.e, it does not hold any of the valid alternatives in
2088 // the type list. This happens, e.g., if the field was late added; in this case, keep the invalid tag, which makes
2089 // any `std::holds_alternative<T>` check fail later.
2090 if (R__likely(tag > 0)) {
2091 void *varPtr = reinterpret_cast<unsigned char *>(to) + fVariantOffset;
2092 CallConstructValueOn(*fSubfields[tag - 1], varPtr);
2093 CallReadOn(*fSubfields[tag - 1], variantIndex, varPtr);
2094 }
2095 SetTag(to, fTagOffset, tag);
2096}
2097
2099{
2100 static RColumnRepresentations representations({{ENTupleColumnType::kSwitch}}, {});
2101 return representations;
2102}
2103
2105{
2106 GenerateColumnsImpl<ROOT::Internal::RColumnSwitch>();
2107}
2108
2110{
2111 GenerateColumnsImpl<ROOT::Internal::RColumnSwitch>(desc);
2112}
2113
2115{
2116 static const std::vector<std::string> prefixes = {"std::variant<"};
2117
2118 EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
2119 EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
2120
2121 const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
2122 if (fSubfields.size() != fieldDesc.GetLinkIds().size()) {
2123 throw RException(R__FAIL("number of variants on-disk do not match for " + GetQualifiedFieldName() + "\n" +
2124 Internal::GetTypeTraceReport(*this, desc)));
2125 }
2126}
2127
2129{
2130 memset(where, 0, GetValueSize());
2131 CallConstructValueOn(*fSubfields[0], reinterpret_cast<unsigned char *>(where) + fVariantOffset);
2132 SetTag(where, fTagOffset, 1);
2133}
2134
2136{
2137 auto tag = GetTag(objPtr, fTagOffset);
2138 if (tag > 0) {
2139 fItemDeleters[tag - 1]->operator()(reinterpret_cast<unsigned char *>(objPtr) + fVariantOffset, true /*dtorOnly*/);
2140 }
2141 RDeleter::operator()(objPtr, dtorOnly);
2142}
2143
2144std::unique_ptr<ROOT::RFieldBase::RDeleter> ROOT::RVariantField::GetDeleter() const
2145{
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));
2150 }
2151 return std::make_unique<RVariantDeleter>(fTagOffset, fVariantOffset, GetAlignment(), std::move(itemDeleters));
2152}
2153
2155{
2156 return std::max(fMaxAlignment, alignof(RVariantTag<GetVariantTagSize()>::ValueType_t));
2157}
2158
2160{
2161 const auto alignment = GetAlignment();
2162 const auto actualSize = fTagOffset + GetVariantTagSize();
2163 const auto padding = alignment - (actualSize % alignment);
2164 return actualSize + ((padding == alignment) ? 0 : padding);
2165}
2166
2168{
2169 std::fill(fNWritten.begin(), fNWritten.end(), 0);
2170}
interop::TCppScope_t fClass
std::string className
Definition JSONIO.cxx:31
#define R__likely(expr)
Definition RConfig.hxx:569
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:322
#define R__LOG_WARNING(...)
Definition RLogger.hxx:357
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
@ kFloat_t
Definition TDataType.h:31
@ kULong64_t
Definition TDataType.h:32
@ kInt_t
Definition TDataType.h:30
@ kLong_t
Definition TDataType.h:30
@ kShort_t
Definition TDataType.h:29
@ kBool_t
Definition TDataType.h:32
@ kULong_t
Definition TDataType.h:30
@ kLong64_t
Definition TDataType.h:32
@ kUShort_t
Definition TDataType.h:29
@ kDouble_t
Definition TDataType.h:31
@ kChar_t
Definition TDataType.h:29
@ kUChar_t
Definition TDataType.h:29
@ kUInt_t
Definition TDataType.h:30
@ kClassHasExplicitCtor
@ kClassHasImplicitCtor
@ kClassHasVirtual
@ kClassHasExplicitDtor
@ kClassHasImplicitDtor
@ kIsArray
Definition TDictionary.h:79
@ kIsStatic
Definition TDictionary.h:80
@ kIsDefinedInStd
Definition TDictionary.h:98
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:139
#define N
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
char name[80]
Definition TGX11.cxx:142
TCanvas * alignment()
Definition alignment.C:1
#define _(A, B)
Definition cfortran.h:112
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.
A helper class for piece-wise construction of an RExtraTypeInfoDescriptor.
RResult< RExtraTypeInfoDescriptor > MoveDescriptor()
RExtraTypeInfoDescriptorBuilder & ContentId(EExtraTypeInfoIds contentId)
RExtraTypeInfoDescriptorBuilder & TypeName(const std::string &typeName)
RExtraTypeInfoDescriptorBuilder & Content(const std::string &content)
RExtraTypeInfoDescriptorBuilder & TypeVersion(std::uint32_t typeVersion)
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
The field for a class with dictionary.
Definition RField.hxx:194
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
Definition RField.hxx:215
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...
~RClassField() override
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.
Definition RField.hxx:315
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.
Definition RError.hxx:78
Field specific extra type information from the header / extenstion header.
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.
bool IsSimple() const
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.
Definition RField.hxx:58
std::vector< std::unique_ptr< RFieldBase > > ReleaseSubfields()
Moves all subfields into the returned vector.
Definition RField.cxx:64
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:352
RField(std::string_view name)
Definition RField.hxx:355
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)
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...
Definition RField.hxx:135
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.
Definition RField.hxx:148
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.
Definition RField.hxx:151
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...
Definition RFieldSoA.hxx:54
std::unique_ptr< std::mutex > fLockSplitFields
protects the fSplitFields member.
Definition RFieldSoA.hxx:95
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.
Definition RFieldSoA.hxx:75
size_t GetValueSize() const final
What sizeof(T) for this type returns.
std::vector< std::unique_ptr< RDeleter > > fRecordMemberDeleters
Definition RFieldSoA.hxx:79
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.
Definition RFieldSoA.hxx:77
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
Definition RFieldSoA.hxx:94
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.
Definition RFieldSoA.hxx:93
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
The field for a class using ROOT standard streaming.
Definition RField.hxx:255
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
Definition RField.hxx:267
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.
Definition TBufferFile.h:47
@ kWrite
Definition TBuffer.h:73
@ kRead
Definition TBuffer.h:73
char * Buffer() const
Definition TBuffer.h:96
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
UInt_t GetCheckSum(ECheckSum code=kCurrentCheckSum) const
Call GetCheckSum with validity check.
Definition TClass.cxx:6693
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
Definition TClass.cxx:2331
EState GetState() const
Definition TClass.h:504
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition TClass.cxx:5529
size_t GetClassAlignment() const
Return the alignment requirement (in bytes) for objects of this class.
Definition TClass.cxx:5840
void BuildRealData(void *pointer=nullptr, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
Definition TClass.cxx:2043
const std::type_info * GetTypeInfo() const
Definition TClass.h:512
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
Definition TClass.cxx:3833
TList * GetListOfRealData() const
Definition TClass.h:468
Int_t Size() const
Return size of object of this class.
Definition TClass.cxx:5871
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition TClass.cxx:3699
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,...
Definition TClass.cxx:4716
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition TClass.cxx:2923
Int_t GetClassSize() const
Definition TClass.h:439
Long_t ClassProperty() const
Return the C++ property of this class, eg.
Definition TClass.cxx:2408
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Definition TClass.cxx:6268
@ kInterpreted
Definition TClass.h:129
@ kEmulated
Definition TClass.h:128
Version_t GetClassVersion() const
Definition TClass.h:434
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2999
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
The TEnum class implements the enum type.
Definition TEnum.h:33
EDataType GetUnderlyingType() const
Get the underlying integer type of the enum: enum E { kOne }; // ==> int enum F: long; // ==> long Re...
Definition TEnum.h:81
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
Definition TEnum.cxx:141
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition TEnum.cxx:181
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:42
@ kIsOnHeap
object is on heap
Definition TObject.h:90
@ kNotDeleted
object has not been deleted
Definition TObject.h:91
static TClass * Class()
@ kIsReferenced
if object is referenced by a TRef or TRefArray
Definition TObject.h:74
The TRealData class manages the effective list of all data members for a given class.
Definition TRealData.h:30
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
const Int_t n
Definition legend1.C:16
TRangeCast< T, false > TRangeStaticCast
TRangeStaticCast is an adapter class that allows the typed iteration through a TCollection.
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
Definition RField.cxx:35
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.
Definition BitUtils.hxx:36
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
@ kSTLvector
Definition ESTLType.h:30
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
ENTupleStructure
The fields in the RNTuple data model tree can carry different structural information about the type s...
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
std::unique_ptr< RFieldBase > fField
The field used to read the on-disk data.
Definition RField.hxx:144
std::size_t fOffset
offset in fStagingArea
Definition RField.hxx:145