Skip to content

Commit f73b4cb

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 974531e commit f73b4cb

File tree

4 files changed

+70
-44
lines changed

4 files changed

+70
-44
lines changed

tree/ntuple/inc/ROOT/RNTupleDescriptor.hxx

Lines changed: 17 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
@@ -1772,6 +1767,19 @@ inline RNTupleDescriptor CloneDescriptorSchema(const RNTupleDescriptor &desc)
17721767
return desc.CloneSchema();
17731768
}
17741769

1770+
/// Tells if the field describes a user-defined class rather than a fundamental type, a collection, or one of the
1771+
/// natively supported stdlib classes.
1772+
/// The dictionary does not need to be available for this method.
1773+
bool IsCustomClassFieldDesc(const RFieldDescriptor &fieldDesc);
1774+
1775+
/// Tells if the field describes a user-defined enum type.
1776+
/// The dictionary does not need to be available for this method.
1777+
/// Needs the full descriptor to look up sub fields.
1778+
bool IsCustomEnumFieldDesc(const RNTupleDescriptor &desc, const RFieldDescriptor &fieldDesc);
1779+
1780+
/// Tells if the field describes a std::atomic<T> type
1781+
bool IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc);
1782+
17751783
} // namespace Internal
17761784

17771785
} // 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: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -152,46 +152,17 @@ ROOT::RFieldDescriptor::CreateField(const RNTupleDescriptor &ntplDesc, const ROO
152152

153153
bool ROOT::RFieldDescriptor::IsCustomClass() const
154154
{
155-
if (fStructure != ROOT::ENTupleStructure::kRecord && fStructure != ROOT::ENTupleStructure::kStreamer)
156-
return false;
157-
158-
// Skip untyped structs
159-
if (fTypeName.empty())
160-
return false;
161-
162-
if (fStructure == ROOT::ENTupleStructure::kRecord) {
163-
if (fTypeName.compare(0, 10, "std::pair<") == 0)
164-
return false;
165-
if (fTypeName.compare(0, 11, "std::tuple<") == 0)
166-
return false;
167-
}
168-
169-
return true;
155+
return Internal::IsCustomClassFieldDesc(*this);
170156
}
171157

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

190163
bool ROOT::RFieldDescriptor::IsStdAtomic() const
191164
{
192-
if (fStructure != ROOT::ENTupleStructure::kPlain)
193-
return false;
194-
return (fTypeName.rfind("std::atomic<", 0) == 0);
165+
return Internal::IsStdAtomicFieldDesc(*this);
195166
}
196167

197168
////////////////////////////////////////////////////////////////////////////////
@@ -1419,7 +1390,7 @@ RNTupleSerializer::StreamerInfoMap_t ROOT::Internal::RNTupleDescriptorBuilder::B
14191390

14201391
std::function<void(const RFieldDescriptor &)> fnWalkFieldTree;
14211392
fnWalkFieldTree = [&desc, &streamerInfoMap, &fnWalkFieldTree](const RFieldDescriptor &fieldDesc) {
1422-
if (fieldDesc.IsCustomClass()) {
1393+
if (Internal::IsCustomClassFieldDesc(fieldDesc)) {
14231394
// Add streamer info for this class to streamerInfoMap
14241395
auto cl = TClass::GetClass(fieldDesc.GetTypeName().c_str());
14251396
if (!cl) {
@@ -1550,3 +1521,49 @@ ROOT::Experimental::RNTupleAttrSetDescriptor ROOT::Experimental::RNTupleAttrSetD
15501521
desc.fName = fName;
15511522
return desc;
15521523
}
1524+
1525+
bool ROOT::Internal::IsCustomClassFieldDesc(const RFieldDescriptor &fieldDesc)
1526+
{
1527+
if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kRecord &&
1528+
fieldDesc.GetStructure() != ROOT::ENTupleStructure::kStreamer) {
1529+
return false;
1530+
}
1531+
1532+
// Skip untyped structs
1533+
if (fieldDesc.GetTypeName().empty())
1534+
return false;
1535+
1536+
if (fieldDesc.GetStructure() == ROOT::ENTupleStructure::kRecord) {
1537+
if (fieldDesc.GetTypeName().compare(0, 10, "std::pair<") == 0)
1538+
return false;
1539+
if (fieldDesc.GetTypeName().compare(0, 11, "std::tuple<") == 0)
1540+
return false;
1541+
}
1542+
1543+
return true;
1544+
}
1545+
1546+
bool ROOT::Internal::IsCustomEnumFieldDesc(const RNTupleDescriptor &desc, const RFieldDescriptor &fieldDesc)
1547+
{
1548+
if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kPlain)
1549+
return false;
1550+
if (fieldDesc.GetTypeName().rfind("std::", 0) == 0)
1551+
return false;
1552+
1553+
auto subFieldId = desc.FindFieldId("_0", fieldDesc.GetId());
1554+
if (subFieldId == kInvalidDescriptorId)
1555+
return false;
1556+
1557+
static const std::string gIntTypeNames[] = {"bool", "char", "std::int8_t", "std::uint8_t",
1558+
"std::int16_t", "std::uint16_t", "std::int32_t", "std::uint32_t",
1559+
"std::int64_t", "std::uint64_t"};
1560+
return std::find(std::begin(gIntTypeNames), std::end(gIntTypeNames),
1561+
desc.GetFieldDescriptor(subFieldId).GetTypeName()) != std::end(gIntTypeNames);
1562+
}
1563+
1564+
bool ROOT::Internal::IsStdAtomicFieldDesc(const RFieldDescriptor &fieldDesc)
1565+
{
1566+
if (fieldDesc.GetStructure() != ROOT::ENTupleStructure::kPlain)
1567+
return false;
1568+
return (fieldDesc.GetTypeName().rfind("std::atomic<", 0) == 0);
1569+
}

0 commit comments

Comments
 (0)