Skip to content
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

[ntuple] don't try to construct an Emulated TClass as a RClassField #17661

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

silverweed
Copy link
Contributor

When constructing a RClassField we need some information that we don't have when the TClass is Emulated (or less), therefore we now check that we have at least an Interpreted TClass in RFieldBase::Create(). If not, we follow the same logic as when we have no TClass at all (i.e. either create an emulated field or fail, depending on the user options).

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #17648

@silverweed silverweed self-assigned this Feb 7, 2025
@silverweed silverweed requested a review from jblomer as a code owner February 7, 2025 09:24
When constructing a RClassField we need some information that we don't
have when the TClass is Emulated (or less), therefore we now check
that we have at least an Interpreted TClass in RFieldBase::Create().
If not, we follow the same logic as when we have no TClass at all
(i.e. either create an emulated field or fail, depending on the user
options).
Copy link
Contributor

@jblomer jblomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link

github-actions bot commented Feb 7, 2025

Test Results

    18 files      18 suites   4d 4h 0m 58s ⏱️
 2 690 tests  2 687 ✅ 0 💤 3 ❌
46 722 runs  46 719 ✅ 0 💤 3 ❌

For more details on these failures, see this check.

Results for commit 6c10350.

@@ -594,7 +594,10 @@ ROOT::Experimental::RFieldBase::Create(const std::string &fieldName, const std::

if (!result) {
auto cl = TClass::GetClass(canonicalType.c_str());
if (cl != nullptr) {
// NOTE: if the class is not at least "Interpreted" we don't have enough information to
// properly construct the RClassField (e.g. we are missing the list of bases), so in that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not precise. The list of base class is available in the TStreamerInfo and thus available for an Emulated class.

Is this PR a temporary fix/workaround or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you access that information? When we load a class from file without dictionary we observe that TClass::GetListOfBases() returns nullptr. Do we need to take some explicit steps to have that list filled? Or do we need to call a different method?

Copy link
Member

@pcanal pcanal Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to look at the TStreamerInfo, eg.

auto info = cl->GetStreamerInfo(); // This return the current StreamerInfo describing the in memory layout
for(auto elem : TRangeStaticCast<TStreamerElement>( *info )) {
   if (elem->IsBase()) {
       ...
   }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcanal I guess you meant TRangeStaticCast<TStreamerElement>(info->GetElements());
but this gives me TStreamerElements and TStreamerBases: how do I get to the TBaseClass from there?
Or can I still access stuff like GetDelta() from a TStreamerBase?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you meant TRangeStaticCast(info->GetElements());

Indeed, sorry :)

how do I get to the TBaseClass from there?

You can't, it is a different interface.

Or can I still access stuff like GetDelta() from a TStreamerBase?

Yes, through GetOffset. Note that the list of TStreamerElement will only contains the direct base classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ntuple] Record field emulation not working with TFile
4 participants