Skip to content

Commit 71f4346

Browse files
committed
[ntuple] accept full descriptor in EnsureMatchingTypePrefix()
1 parent 2f0b548 commit 71f4346

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

tree/ntuple/inc/ROOT/RFieldBase.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ protected:
537537
/// Many fields accept a range of type prefixes for schema evolution,
538538
/// e.g. std::unique_ptr< and std::optional< for nullable fields
539539
RResult<void>
540-
EnsureMatchingTypePrefix(const RFieldDescriptor &fieldDesc, const std::vector<std::string> &prefixes) const;
540+
EnsureMatchingTypePrefix(const RNTupleDescriptor &desc, const std::vector<std::string> &prefixes) const;
541541

542542
/// Factory method to resurrect a field from the stored on-disk type information. This overload takes an already
543543
/// normalized type name and type alias.

tree/ntuple/src/RField.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,7 @@ void ROOT::RNullableField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
880880
static const std::vector<std::string> prefixes = {"std::optional<", "std::unique_ptr<"};
881881

882882
EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
883-
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
884-
EnsureMatchingTypePrefix(fieldDesc, prefixes).ThrowOnError();
883+
EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
885884
}
886885

887886
ROOT::RNTupleLocalIndex ROOT::RNullableField::GetItemIndex(ROOT::NTupleSize_t globalIndex)
@@ -1100,8 +1099,7 @@ void ROOT::RAtomicField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
11001099
static const std::vector<std::string> prefixes = {"std::atomic<"};
11011100

11021101
EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1103-
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
1104-
EnsureMatchingTypePrefix(fieldDesc, prefixes).ThrowOnError();
1102+
EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
11051103
}
11061104

11071105
std::vector<ROOT::RFieldBase::RValue> ROOT::RAtomicField::SplitValue(const RValue &value) const

tree/ntuple/src/RFieldBase.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,10 @@ ROOT::RFieldBase::EnsureMatchingOnDiskField(const RNTupleDescriptor &desc, std::
10491049
return R__FAIL(errMsg.str());
10501050
}
10511051

1052-
ROOT::RResult<void> ROOT::RFieldBase::EnsureMatchingTypePrefix(const RFieldDescriptor &fieldDesc,
1052+
ROOT::RResult<void> ROOT::RFieldBase::EnsureMatchingTypePrefix(const RNTupleDescriptor &desc,
10531053
const std::vector<std::string> &prefixes) const
10541054
{
1055+
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
10551056
for (const auto &p : prefixes) {
10561057
if (fieldDesc.GetTypeName().rfind(p, 0) == 0)
10571058
return RResult<void>::Success();

tree/ntuple/src/RFieldMeta.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ void ROOT::RPairField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
685685
static const std::vector<std::string> prefixes = {"std::pair<", "std::tuple<"};
686686

687687
EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
688-
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
689-
EnsureMatchingTypePrefix(fieldDesc, prefixes).ThrowOnError();
688+
EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
690689

690+
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
691691
const auto nOnDiskSubfields = fieldDesc.GetLinkIds().size();
692692
if (nOnDiskSubfields != 2) {
693693
throw ROOT::RException(
@@ -1232,9 +1232,9 @@ void ROOT::RTupleField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
12321232
static const std::vector<std::string> prefixes = {"std::pair<", "std::tuple<"};
12331233

12341234
EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1235-
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
1236-
EnsureMatchingTypePrefix(fieldDesc, prefixes).ThrowOnError();
1235+
EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
12371236

1237+
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
12381238
const auto nOnDiskSubfields = fieldDesc.GetLinkIds().size();
12391239
const auto nSubfields = fSubfields.size();
12401240
if (nOnDiskSubfields != nSubfields) {
@@ -1394,9 +1394,9 @@ void ROOT::RVariantField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
13941394
static const std::vector<std::string> prefixes = {"std::variant<"};
13951395

13961396
EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
1397-
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
1398-
EnsureMatchingTypePrefix(fieldDesc, prefixes).ThrowOnError();
1397+
EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
13991398

1399+
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
14001400
if (fSubfields.size() != fieldDesc.GetLinkIds().size()) {
14011401
throw RException(R__FAIL("number of variants on-disk do not match for " + GetQualifiedFieldName()));
14021402
}

tree/ntuple/src/RFieldSequenceContainer.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ void ROOT::RArrayField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
8686
static const std::vector<std::string> prefixes = {"std::array<"};
8787

8888
EnsureMatchingOnDiskField(desc, kDiffTypeName).ThrowOnError();
89-
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
90-
EnsureMatchingTypePrefix(fieldDesc, prefixes).ThrowOnError();
89+
EnsureMatchingTypePrefix(desc, prefixes).ThrowOnError();
9190
}
9291

9392
void ROOT::RArrayField::ConstructValue(void *where) const

0 commit comments

Comments
 (0)