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

I/O Schema Evolution: Automate conversion from Derived* to Base* #22

Open
pcanal opened this issue Mar 14, 2023 · 3 comments
Open

I/O Schema Evolution: Automate conversion from Derived* to Base* #22

pcanal opened this issue Mar 14, 2023 · 3 comments

Comments

@pcanal
Copy link
Owner

pcanal commented Mar 14, 2023

See https://sft.its.cern.ch/jira/browse/ROOT-871?jql=project%20%3D%20ROOT%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20ORDER%20BY%20created%20ASC

I had a class containing a pointer to one of our classes and had to turn this pointer into a pointer to one of its base-class, eg:

Old: class A { TNamed *a; }
New: class A { TObject *a; }{code}

Now I get the following message reading a root file in which I stored an object of the old class with the new class in the dictionary:
Warning in <TStreamerInfo:BuildOld>: Cannot convert A::a from type:TNamed* to type TObject, skip element.

It should be easy to detect that TObject is a base class of TNamed (and both are in the dictionary) so reading the object and setting the pointer correctly should not be very difficult. And would allow simple changes to your classes without loosing compatibility.

@pcanal
Copy link
Owner Author

pcanal commented Mar 14, 2023

Use derived-to-base.tgz as a reproducer.

@pcanal
Copy link
Owner Author

pcanal commented Mar 14, 2023

A work-around on case by case basis is to use an I/O customization rule, for example in this case:

#pragma read sourceClass="A" targetClass="A" versions="[1-]" source="TNamed *fValue" target="fValue" code="{ fValue = onfile.fValue; }";

where versions could be replaced by checksums with the value corresponding to the old schema/class-layout.

@pcanal
Copy link
Owner Author

pcanal commented Mar 14, 2023

Automating this would (probably) require to create a new TStreamerInfoAction that captures as part of its configuration the base class offset needed to adjust the pointer (e.g. for cases where there derived class inherited from multiple base classes). Special care would need to be given to the case of diamond and virtual inheritance.

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

No branches or pull requests

1 participant