[ntuple] detect runtime member streamers via TRealData#21281
[ntuple] detect runtime member streamers via TRealData#21281JasMehta08 wants to merge 1 commit intoroot-project:masterfrom
Conversation
jblomer
left a comment
There was a problem hiding this comment.
Thank you!
I think that automatically using a streamer field is undesired. Custom member streamers are a rare case and for now, I think we should simply detect this case in RClassField and fail with an error message.
We would also need a test for this.
c4e0f67 to
695bd21
Compare
|
I have updated the PR,
Please let me know if I should change anything. Thanks! |
jblomer
left a comment
There was a problem hiding this comment.
Looks quite close to being merge ready!
| // Detect custom streamers set on individual members at runtime via | ||
| // TClass::SetMemberStreamer() or TClass::AdoptMemberStreamer(). | ||
| // These are stored in TRealData and are not caught by CanSplit(). | ||
| if (auto realDataList = fClass->GetListOfRealData()) { |
There was a problem hiding this comment.
Use the following snippet to iterate the real data:
for (auto realMember : ROOT::Detail::TRangeStaticCast<TRealData>(*fClass->GetListOfRealData())) {
tree/ntuple/test/StreamerField.hxx
Outdated
| @@ -101,4 +101,11 @@ struct TemperatureKelvin { | |||
| float fValue; | |||
| }; | |||
|
|
|||
| // Test class for runtime member streamers set via TClass::SetMemberStreamer | |||
| struct MemberStreamerContainer { | |||
There was a problem hiding this comment.
| struct MemberStreamerContainer { | |
| struct MemberWithCustomStreamer { |
tree/ntuple/test/StreamerField.hxx
Outdated
| @@ -101,4 +101,11 @@ struct TemperatureKelvin { | |||
| float fValue; | |||
| }; | |||
|
|
|||
| // Test class for runtime member streamers set via TClass::SetMemberStreamer | |||
| struct MemberStreamerContainer { | |||
There was a problem hiding this comment.
This class should go in CustomStruct.hxx
| @@ -27,4 +27,6 @@ | |||
| #pragma link C++ options = rntupleStreamerMode(true) class TemperatureCelsius + ; | |||
| #pragma link C++ options = rntupleStreamerMode(true) class TemperatureKelvin + ; | |||
|
|
|||
| #pragma link C++ class MemberStreamerContainer + ; | |||
There was a problem hiding this comment.
| #pragma link C++ class MemberStreamerContainer + ; | |
| #pragma link C++ class MemberStreamerContainer+; |
tree/ntuple/test/rfield_streamer.cxx
Outdated
| b << *val; | ||
| } | ||
| }); | ||
|
|
There was a problem hiding this comment.
Perhaps also check that "CanSplit" is still true
tree/ntuple/test/rfield_streamer.cxx
Outdated
| @@ -407,3 +407,26 @@ TEST(RField, StreamerClassMismatch) | |||
| false /* matchFullMessage */); | |||
| reader->LoadEntry(0); | |||
| } | |||
|
|
|||
| // Detect custom streamers set on class members at runtime via TClass::SetMemberStreamer. | |||
| TEST(RField, MemberCustomStreamer) | |||
There was a problem hiding this comment.
This test should go in rfield_class.cxx
695bd21 to
b1324a7
Compare
|
i have updated the code,
Thanks! |
b1324a7 to
f6314db
Compare
Test Results 21 files 21 suites 3d 3h 50m 29s ⏱️ For more details on these failures, see this check. Results for commit f6314db. |
jblomer
left a comment
There was a problem hiding this comment.
In principle looks good to me but see the CI report (missing TBuffer.h include)
tree/ntuple/test/CustomStruct.hxx
Outdated
| struct MemberWithCustomStreamer { | ||
| int fNormal = 0; | ||
| int fCustom = 0; | ||
| ClassDefNV(MemberWithCustomStreamer, 1); |
There was a problem hiding this comment.
Nit:
| ClassDefNV(MemberWithCustomStreamer, 1); | |
| ClassDefNV(MemberWithCustomStreamer, 2); |
|
@jblomer |
f6314db to
14a18ab
Compare
|
I have added the changes that you had pointed out about I also changed the code snippet as i think it is the cause of the segmentation fault. Thanks! |
This Pull request:
Changes or fixes:
When a class member has a custom streamer set at runtime via
TClass::SetMemberStreamer()orTClass::AdoptMemberStreamer(),RFieldBase::Create()now detects this by iteratingTRealDataand checkingTRealData::GetStreamer().If any member has a custom streamer, an RStreamerField is used instead of RClassField, preventing the class from being split into columns which would bypass the member's custom serialization logic.
Checklist:
This PR fixes #20448