Skip to content

Commit bd12deb

Browse files
committed
[ntuple] fix type names with [U]Long64_t template args
Custom classes with [U]Long64_t template arguments need to use their meta-normalized name as type alias. Otherwise, during reconstruction with the RNTuple normalized name, the streamer info for the `std::[u]int64_t` argument will be requested (typically `long` instead of `long long`).
1 parent 26df1c6 commit bd12deb

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

tree/ntuple/src/RFieldMeta.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ ROOT::RClassField::RClassField(std::string_view fieldName, TClass *classp)
158158
if (!(fClass->ClassProperty() & kClassHasExplicitDtor))
159159
fTraits |= kTraitTriviallyDestructible;
160160

161+
std::string renormalizedAlias;
162+
if (Internal::NeedsMetaNameAsAlias(classp->GetName(), renormalizedAlias))
163+
fTypeAlias = renormalizedAlias;
164+
161165
int i = 0;
162166
const auto *bases = fClass->GetListOfBases();
163167
assert(bases);

tree/ntuple/test/CustomStruct.hxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ struct alignas(std::uint64_t) TestEBO : public EmptyStruct {
100100
template <typename T>
101101
class EdmWrapper {
102102
public:
103+
struct Inner {
104+
T fX;
105+
};
106+
103107
bool fIsPresent = true;
104108
T fMember;
105109
};

tree/ntuple/test/rfield_class.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ TEST(RNTuple, StreamerInfoRecords)
407407
{"DerivedA", {"DerivedA", "CustomStruct"}},
408408
{"std::pair<CustomStruct, DerivedA>", {"DerivedA", "CustomStruct"}},
409409
{"EdmWrapper<long long>", {"EdmWrapper<Long64_t>"}},
410+
{"EdmContainer", {"EdmContainer", "EdmWrapper<Long64_t>"}},
411+
{"EdmWrapper<long long>::Inner", {"EdmWrapper<Long64_t>::Inner"}},
410412
{"TRotation", {"TRotation"}}};
411413

412414
for (const auto &t : testees) {
@@ -436,5 +438,11 @@ TEST(RNTuple, StreamerInfoRecords)
436438
expectedInfos.erase(itr);
437439
}
438440
EXPECT_TRUE(expectedInfos.empty());
441+
442+
// Make sure we can reconstruct the fields
443+
auto reader = RNTupleReader::Open("ntpl", fileGuard.GetPath());
444+
if (auto field = dynamic_cast<const ROOT::RClassField *>(&reader->GetModel().GetConstField("f"))) {
445+
EXPECT_EQ(t.second[0], field->GetClass()->GetName());
446+
}
439447
}
440448
}

0 commit comments

Comments
 (0)