Repository navigation
[ntuple] Fixes to RNTupleMerger with emulated types #23702
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 all commits
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 |
|---|---|---|
|
|
@@ -531,8 +531,9 @@ void ROOT::RRVecField::AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const | |
| //------------------------------------------------------------------------------ | ||
|
|
||
| ROOT::RVectorField::RVectorField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField, | ||
| std::optional<std::string_view> emulatedFromType) | ||
| : ROOT::RFieldBase(fieldName, emulatedFromType ? *emulatedFromType : "std::vector<" + itemField->GetTypeName() + ">", | ||
| const ROOT::RFieldDescriptor *emulatedFrom) | ||
| : ROOT::RFieldBase(fieldName, | ||
| emulatedFrom ? emulatedFrom->GetTypeName() : "std::vector<" + itemField->GetTypeName() + ">", | ||
| ROOT::ENTupleStructure::kCollection, false /* isSimple */), | ||
| fItemSize(itemField->GetValueSize()), | ||
| fNWritten(0) | ||
|
|
@@ -542,8 +543,11 @@ ROOT::RVectorField::RVectorField(std::string_view fieldName, std::unique_ptr<RFi | |
| R__FAIL(std::string("Unsupported vector item alignment: ") + std::to_string(itemField->GetAlignment()))); | ||
| } | ||
|
|
||
| if (emulatedFromType && !emulatedFromType->empty()) | ||
| if (emulatedFrom && !emulatedFrom->GetTypeName().empty()) { | ||
| fTraits |= kTraitEmulatedField; | ||
| fEmulatedTypeVersion = emulatedFrom->GetTypeVersion(); | ||
| fEmulatedTypeChecksum = emulatedFrom->GetTypeChecksum().value_or(0); | ||
| } | ||
|
|
||
| if (!itemField->GetTypeAlias().empty()) | ||
| fTypeAlias = "std::vector<" + itemField->GetTypeAlias() + ">"; | ||
|
|
@@ -554,22 +558,36 @@ ROOT::RVectorField::RVectorField(std::string_view fieldName, std::unique_ptr<RFi | |
| } | ||
|
|
||
| ROOT::RVectorField::RVectorField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField) | ||
| : RVectorField(fieldName, std::move(itemField), {}) | ||
| : RVectorField(fieldName, std::move(itemField), nullptr) | ||
| { | ||
| } | ||
|
|
||
| std::unique_ptr<ROOT::RVectorField> | ||
| ROOT::RVectorField::CreateUntyped(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField) | ||
| { | ||
| return std::unique_ptr<ROOT::RVectorField>(new RVectorField(fieldName, itemField->Clone("_0"), "")); | ||
| ROOT::RFieldDescriptor desc; | ||
| return std::unique_ptr<ROOT::RVectorField>(new RVectorField(fieldName, itemField->Clone("_0"), &desc)); | ||
| } | ||
|
|
||
| std::unique_ptr<ROOT::RFieldBase> ROOT::RVectorField::CloneImpl(std::string_view newName) const | ||
| { | ||
| auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName()); | ||
| auto isUntyped = GetTypeName().empty() || ((fTraits & kTraitEmulatedField) != 0); | ||
| auto emulatedFromType = isUntyped ? std::make_optional(GetTypeName()) : std::nullopt; | ||
| return std::unique_ptr<ROOT::RVectorField>(new RVectorField(newName, std::move(newItemField), emulatedFromType)); | ||
| ROOT::RFieldDescriptor desc; | ||
| if (isUntyped) { | ||
| ROOT::Internal::RFieldDescriptorBuilder builder; | ||
| desc = builder.TypeVersion(GetTypeVersion()) | ||
| .TypeChecksum(GetTypeChecksum()) | ||
| .TypeName(GetTypeName()) | ||
| // we need an Id for MoveDescriptor to succeed, but we're not going to use it. | ||
|
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. Which part makes it optional? (and is it too hard and/or fragile to remove this requirement?
Contributor
Author
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. In this case we're using the descriptor just as a container for the three values we care about (type version/checksum/name), so it's a bit of an improper use. |
||
| .FieldId(42) | ||
| // we also need a Structure for the same reason. | ||
| .Structure(ENTupleStructure::kCollection) | ||
| .MoveDescriptor() | ||
| .Unwrap(); | ||
| } | ||
| return std::unique_ptr<ROOT::RVectorField>( | ||
| new RVectorField(newName, std::move(newItemField), isUntyped ? &desc : nullptr)); | ||
| } | ||
|
|
||
| std::size_t ROOT::RVectorField::AppendImpl(const void *from) | ||
|
|
||
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.
Ok for now, we'll come back to this to avoid disguising an untyped record as an emulated record. This is a pre-existing issue, of course.