Skip to content

Commit 3333f53

Browse files
committed
[ntuple] deprecate small helpers in RFieldDescriptor
The query methods `IsCustomClass`, `IsCustomEnum`, and `IsStdAtomic` are rather arbitrary and should not have been added to the public interface. They only make sense in the internal context in which they are used. Removed for v6.42.
1 parent 52ac3a0 commit 3333f53

File tree

4 files changed

+48
-33
lines changed

4 files changed

+48
-33
lines changed

tree/ntuple/inc/ROOT/RNTupleDescriptor.hxx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,10 @@ public:
189189
std::uint32_t GetColumnCardinality() const { return fColumnCardinality; }
190190
std::optional<std::uint32_t> GetTypeChecksum() const { return fTypeChecksum; }
191191
bool IsProjectedField() const { return fProjectionSourceId != ROOT::kInvalidDescriptorId; }
192-
/// Tells if the field describes a user-defined class rather than a fundamental type, a collection, or one of the
193-
/// natively supported stdlib classes.
194-
/// The dictionary does not need to be available for this method.
195-
bool IsCustomClass() const;
196-
/// Tells if the field describes a user-defined enum type.
197-
/// The dictionary does not need to be available for this method.
198-
/// Needs the full descriptor to look up sub fields.
199-
bool IsCustomEnum(const RNTupleDescriptor &desc) const;
200-
bool IsStdAtomic() const;
192+
193+
bool IsCustomClass() const R__DEPRECATED(6, 42, "removed from public interface");
194+
bool IsCustomEnum(const RNTupleDescriptor &desc) const R__DEPRECATED(6, 42, "removed from public interface");
195+
bool IsStdAtomic() const R__DEPRECATED(6, 42, "removed from public interface");
201196
};
202197

203198
// clang-format off
@@ -1769,6 +1764,14 @@ inline RNTupleDescriptor CloneDescriptorSchema(const RNTupleDescriptor &desc)
17691764
return desc.CloneSchema();
17701765
}
17711766

1767+
/// Tells if the field describes a user-defined enum type.
1768+
/// The dictionary does not need to be available for this method.
1769+
/// Needs the full descriptor to look up sub fields.
1770+
bool IsCustomEnumFieldDesc(const RNTupleDescriptor &desc, const RFieldDescriptor &fieldDesc);
1771+
1772+
/// Tells if the field describes a std::atomic<T> type
1773+
bool IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc);
1774+
17721775
} // namespace Internal
17731776

17741777
} // namespace ROOT

tree/ntuple/src/RField.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void ROOT::RSimpleField<T>::ReconcileIntegralField(const RNTupleDescriptor &desc
117117
EnsureMatchingOnDiskField(desc, kDiffTypeName);
118118

119119
const RFieldDescriptor &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId());
120-
if (fieldDesc.IsCustomEnum(desc)) {
120+
if (Internal::IsCustomEnumFieldDesc(desc, fieldDesc)) {
121121
SetOnDiskId(desc.FindFieldId("_0", GetOnDiskId()));
122122
return;
123123
}

tree/ntuple/src/RFieldBase.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,8 @@ void ROOT::RFieldBase::ConnectPageSource(ROOT::Internal::RPageSource &pageSource
959959
// Note that we have to do this before calling BeforeConnectPageSource(), which already may compare the field
960960
// to its on-disk description.
961961
const auto &desc = pageSource.GetSharedDescriptorGuard().GetRef();
962-
if (!dynamic_cast<RAtomicField *>(this) && desc.GetFieldDescriptor(GetOnDiskId()).IsStdAtomic()) {
962+
if (!dynamic_cast<RAtomicField *>(this) &&
963+
Internal::IsStdAtomicFieldDesc(desc.GetFieldDescriptor(GetOnDiskId()))) {
963964
SetOnDiskId(desc.GetFieldDescriptor(GetOnDiskId()).GetLinkIds()[0]);
964965
}
965966
}

tree/ntuple/src/RNTupleDescriptor.cxx

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,18 @@ ROOT::RFieldDescriptor::CreateField(const RNTupleDescriptor &ntplDesc, const ROO
151151

152152
bool ROOT::RFieldDescriptor::IsCustomClass() const
153153
{
154-
if (fStructure != ROOT::ENTupleStructure::kRecord && fStructure != ROOT::ENTupleStructure::kStreamer)
154+
if (GetStructure() != ROOT::ENTupleStructure::kRecord && GetStructure() != ROOT::ENTupleStructure::kStreamer) {
155155
return false;
156+
}
156157

157158
// Skip untyped structs
158-
if (fTypeName.empty())
159+
if (GetTypeName().empty())
159160
return false;
160161

161-
if (fStructure == ROOT::ENTupleStructure::kRecord) {
162-
if (fTypeName.compare(0, 10, "std::pair<") == 0)
162+
if (GetStructure() == ROOT::ENTupleStructure::kRecord) {
163+
if (GetTypeName().compare(0, 10, "std::pair<") == 0)
163164
return false;
164-
if (fTypeName.compare(0, 11, "std::tuple<") == 0)
165+
if (GetTypeName().compare(0, 11, "std::tuple<") == 0)
165166
return false;
166167
}
167168

@@ -170,27 +171,12 @@ bool ROOT::RFieldDescriptor::IsCustomClass() const
170171

171172
bool ROOT::RFieldDescriptor::IsCustomEnum(const RNTupleDescriptor &desc) const
172173
{
173-
if (fStructure != ROOT::ENTupleStructure::kPlain)
174-
return false;
175-
if (fTypeName.rfind("std::", 0) == 0)
176-
return false;
177-
178-
auto subFieldId = desc.FindFieldId("_0", fFieldId);
179-
if (subFieldId == kInvalidDescriptorId)
180-
return false;
181-
182-
static const std::string gIntTypeNames[] = {"bool", "char", "std::int8_t", "std::uint8_t",
183-
"std::int16_t", "std::uint16_t", "std::int32_t", "std::uint32_t",
184-
"std::int64_t", "std::uint64_t"};
185-
return std::find(std::begin(gIntTypeNames), std::end(gIntTypeNames),
186-
desc.GetFieldDescriptor(subFieldId).GetTypeName()) != std::end(gIntTypeNames);
174+
return Internal::IsCustomEnumFieldDesc(desc, *this);
187175
}
188176

189177
bool ROOT::RFieldDescriptor::IsStdAtomic() const
190178
{
191-
if (fStructure != ROOT::ENTupleStructure::kPlain)
192-
return false;
193-
return (fTypeName.rfind("std::atomic<", 0) == 0);
179+
return Internal::IsStdAtomicFieldDesc(*this);
194180
}
195181

196182
////////////////////////////////////////////////////////////////////////////////
@@ -1507,3 +1493,28 @@ ROOT::Experimental::RNTupleAttrSetDescriptor ROOT::Experimental::RNTupleAttrSetD
15071493
desc.fName = fName;
15081494
return desc;
15091495
}
1496+
1497+
bool ROOT::Internal::IsCustomEnumFieldDesc(const RNTupleDescriptor &desc, const RFieldDescriptor &fieldDesc)
1498+
{
1499+
if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kPlain)
1500+
return false;
1501+
if (fieldDesc.GetTypeName().rfind("std::", 0) == 0)
1502+
return false;
1503+
1504+
auto subFieldId = desc.FindFieldId("_0", fieldDesc.GetId());
1505+
if (subFieldId == kInvalidDescriptorId)
1506+
return false;
1507+
1508+
static const std::string gIntTypeNames[] = {"bool", "char", "std::int8_t", "std::uint8_t",
1509+
"std::int16_t", "std::uint16_t", "std::int32_t", "std::uint32_t",
1510+
"std::int64_t", "std::uint64_t"};
1511+
return std::find(std::begin(gIntTypeNames), std::end(gIntTypeNames),
1512+
desc.GetFieldDescriptor(subFieldId).GetTypeName()) != std::end(gIntTypeNames);
1513+
}
1514+
1515+
bool ROOT::Internal::IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc)
1516+
{
1517+
if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kPlain)
1518+
return false;
1519+
return (fieldDesc.GetTypeName().rfind("std::atomic<", 0) == 0);
1520+
}

0 commit comments

Comments
 (0)