Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tree/ntuple/src/RFieldMeta.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,9 @@ ROOT::Experimental::RSoAField::RSoAField(std::string_view fieldName, TClass *clS
} catch (ROOT::RException &e) {
throw RException(R__FAIL("invalid record type of SoA field " + GetTypeName() + " [" + e.what() + "]"));
}
R__ASSERT(fClass->GetClassVersion() >= 0);
if (fClass->GetClassVersion() <= 0) {
throw RException(R__FAIL(std::string("SoA class ") + GetTypeName() + " is transient or unversioned."));
}
if (static_cast<std::uint32_t>(fClass->GetClassVersion()) != fSubfields[0]->GetTypeVersion()) {
throw RException(R__FAIL(std::string("version mismatch between SoA type and underlying record type: ") +
std::to_string(fClass->GetClassVersion()) + " vs. " +
Expand Down
4 changes: 4 additions & 0 deletions tree/ntuple/test/SoAField.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ struct SoAVersionMismatch {
ClassDefNV(SoAVersionMismatch, 4);
};

struct RecordUnversioned {};

struct SoAUnversioned {};

struct RecordSimple {
float fX;
float fY;
Expand Down
3 changes: 3 additions & 0 deletions tree/ntuple/test/SoAFieldLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#pragma link C++ options=rntupleSoARecord(xyz) class SoAUnknownRecord+;
#pragma link C++ options=rntupleSoARecord(Record) class SoAVersionMismatch+;

#pragma link C++ class RecordUnversioned+;
#pragma link C++ options=rntupleSoARecord(RecordUnversioned) class SoAUnversioned+;

#pragma link C++ class RecordSimple+;
#pragma link C++ options=rntupleSoARecord(RecordSimple) class SoASimple+;
#pragma link C++ options=rntupleSoARecord(RecordSimple) class SoASimpleSwapped+;
Expand Down
7 changes: 7 additions & 0 deletions tree/ntuple/test/ntuple_soa.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ TEST(RNTuple, SoACheck)
EXPECT_THAT(e.what(), ::testing::HasSubstr("version mismatch between SoA type and underlying record type"));
}

try {
auto f = std::make_unique<RSoAField>("f", "SoAUnversioned");
FAIL() << "creating unversioned SoA field should fail";
} catch (const ROOT::RException &e) {
EXPECT_THAT(e.what(), ::testing::HasSubstr("is transient or unversioned"));
}

try {
auto f = std::make_unique<RSoAField>("f", "SoASimpleBadArray");
FAIL() << "creating SoA field with arrays should fail";
Expand Down
Loading