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

Add support for enums with non-default size #17009

Open
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

pcanal
Copy link
Member

@pcanal pcanal commented Nov 22, 2024

This PR Is chained (includes all commit from) #16995.

The companion roottest PR is root-project/roottest#1226

It also requires an increase in the TStreamerInfo class version number (to mark which files/StreamerInfo have weird data for non-default size enum and which files are correct).

This fixes #16312. However files produced without this PR and with enum with a non default size will have data that is incorrectly saved but potential recoverable. The way the data is written will dependent on the size of the enum at the time of writing. Since this size is not recorded in the file, we can not have a general solution to read those corrupted files. However when that enum size used at write time is known, the techniques described here and here can be used to recover those weird files.

If reading both the corrupted files (using the above mentioned work-around) and the new files (correctly written with this PR) the recommendation is to increase the version number of the classes that contain an enum with non-default size so that the rules or custom streamer can distinguish the old and new files.

This enables the StreamerInfoActions to enable the shortcuts that
are possible in that case.
The version recorded 'here' is the version of the TStreamerInfo class not the user class
Even without schema evolution, the representation of a collection of enums
on file is a `vector<int>` so `TStreamerElement::fType` and `TStreamerElement::fClassObject`
should point to `vector<int>` while `TStreamerElement::fNewType` and
`TStreamerElement::fNewClass` should point to the current in memory representaition
`actualCollectionType< actualEnum >` that will know/remember what is the actual enum
in memory representation.
Combine the code with the one use for the text actions
Combine the code with the one use for the text actions
To use be for case where the read and write implementation differs only slightly
To be used for function template that can be used for more than one actual looper (usually in
conjunction with the LoopOverCollection template
Allow to share code with the collection loopers.
This required the addition of a concept that can be used to reduce boiler plate duplication.
We now have an example where a generic function (Read/WriteStreamerLoop) is used with action
with different signature by leveraging template arguments packs and a using statement declaration
within the *Looper helper structs
@pcanal pcanal self-assigned this Nov 22, 2024
Copy link

github-actions bot commented Nov 22, 2024

Test Results

    18 files      18 suites   4d 7h 39m 15s ⏱️
 2 684 tests  2 683 ✅ 0 💤 1 ❌
46 475 runs  46 473 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit 86262f0.

♻️ This comment has been updated with latest results.

Using the new bit kBitsIsValid.
This allows to both store the validity in the rootpcm file and also to execute IsValid
on a TEnum read from a rootpcm without doing a Clang lookup
I.e. take into account the non-default size of an enum declaration
We split the reprensentation of a collection of enums between in memory
representation and onfile representation (always `vector<int>`).
Similarly for data member that enum types we set the in memory type (`NewType`)
to be correct and keep the onfile type (`fType`) as it was (`Int_t`)
@pcanal pcanal changed the title WIP: Add support for enums with non-default size Add support for enums with non-default size Nov 22, 2024
@pcanal pcanal marked this pull request as ready for review November 22, 2024 22:50
@pcanal pcanal requested a review from dpiparo as a code owner November 22, 2024 22:50
@pcanal pcanal requested a review from jblomer November 22, 2024 22:50
@pcanal
Copy link
Member Author

pcanal commented Nov 22, 2024

@ktf This ready for further testing and will be merged once the reviews are done.

@ktf
Copy link
Contributor

ktf commented Nov 25, 2024

Thanks. I will need a bit to digest what we actually need to do for this. I also assume you are going to backport this to 6-32?

@pcanal
Copy link
Member Author

pcanal commented Nov 25, 2024

It is an unusually large/significant change to backport but if you need it in v6.32/34, we can indeed backport it.

This automatically set the in-memory type (newType)
of the TStreamerElement to the correct value.  We just
need to set the onfile type (fType/old type) to be Int_t
@pcanal pcanal closed this Nov 26, 2024
@pcanal pcanal reopened this Nov 26, 2024
@ktf
Copy link
Contributor

ktf commented Nov 26, 2024

Let me check how it goes with this and the HEAD on our ARM box and then we can discuss the backporting. @dpiparo can you remind me the timeline for v6-36?

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

Successfully merging this pull request may close these issues.

Broken streaming of vector of enum with underlying type other than int
2 participants