-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[ntuple] fixes to subfield name handling #20629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,11 +38,22 @@ void ROOT::Internal::SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val) | |||||||||||||||
| fieldZero.fAllowFieldSubstitutions = val; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| void ROOT::RFieldZero::Attach(std::unique_ptr<RFieldBase> child) | ||||||||||||||||
| { | ||||||||||||||||
| const std::string childName = child->GetFieldName(); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to avoid the copy? |
||||||||||||||||
| if (fSubFieldNames.count(childName) > 0) | ||||||||||||||||
| throw RException(R__FAIL("duplicate field name: " + childName)); | ||||||||||||||||
| RFieldBase::Attach(std::move(child), ""); | ||||||||||||||||
| fSubFieldNames.insert(childName); | ||||||||||||||||
|
Comment on lines
+44
to
+47
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can do this in one go:
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| std::unique_ptr<ROOT::RFieldBase> ROOT::RFieldZero::CloneImpl(std::string_view /*newName*/) const | ||||||||||||||||
| { | ||||||||||||||||
| auto result = std::make_unique<RFieldZero>(); | ||||||||||||||||
| for (auto &f : fSubfields) | ||||||||||||||||
| for (auto &f : fSubfields) { | ||||||||||||||||
| result->Attach(f->Clone(f->GetFieldName())); | ||||||||||||||||
| result->fSubFieldNames.insert(f->GetFieldName()); | ||||||||||||||||
| } | ||||||||||||||||
| return result; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -603,13 +614,19 @@ ROOT::RRecordField::RRecordField(std::string_view fieldName, std::vector<std::un | |||||||||||||||
| { | ||||||||||||||||
| fTraits |= kTraitTrivialType; | ||||||||||||||||
| fOffsets.reserve(itemFields.size()); | ||||||||||||||||
| std::unordered_set<std::string> fieldNames; | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the local |
||||||||||||||||
| for (auto &item : itemFields) { | ||||||||||||||||
| const auto itemName = item->GetFieldName(); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will copy the field name |
||||||||||||||||
| if (fieldNames.count(itemName) > 0) { | ||||||||||||||||
| throw RException(R__FAIL("duplicate field name: " + itemName)); | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+620
to
+622
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| fSize += GetItemPadding(fSize, item->GetAlignment()); | ||||||||||||||||
| fOffsets.push_back(fSize); | ||||||||||||||||
| fMaxAlignment = std::max(fMaxAlignment, item->GetAlignment()); | ||||||||||||||||
| fSize += item->GetValueSize(); | ||||||||||||||||
| fTraits &= item->GetTraits(); | ||||||||||||||||
| Attach(std::move(item)); | ||||||||||||||||
| fieldNames.insert(itemName); | ||||||||||||||||
| } | ||||||||||||||||
| fTraits |= !emulatedFromType.empty() * kTraitEmulatedField; | ||||||||||||||||
| // Trailing padding: although this is implementation-dependent, most add enough padding to comply with the | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm,
RFieldBase::Attachis non-virtualso "overriding" it in the base class only works if we statically know the type of theRFieldZero- is that the case?