Skip to content

Commit 74816d1

Browse files
committed
[ntuple] ENTupleStructure::kLeaf --> kStatic
The structural role "leaf" was ill-named because in the tree of fields also inner nodes can carry that role. Hence renamed to "static". Static nodes are either leaves or they are inner fields with exactly one child field of the same cardinality (modulo field repetition). That is, static fields add hierarchy to the field tree but they don't carry any more structural information.
1 parent b4f1da1 commit 74816d1

13 files changed

+59
-51
lines changed

tree/dataframe/src/RNTupleDS.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class RRDFCardinalityField final : public ROOT::RFieldBase {
6565
void ConstructValue(void *where) const final { *static_cast<std::size_t *>(where) = 0; }
6666

6767
public:
68-
RRDFCardinalityField() : ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kLeaf, false /* isSimple */) {}
68+
RRDFCardinalityField() : ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kStatic, false /* isSimple */)
69+
{
70+
}
6971
RRDFCardinalityField(RRDFCardinalityField &&other) = default;
7072
RRDFCardinalityField &operator=(RRDFCardinalityField &&other) = default;
7173
~RRDFCardinalityField() override = default;
@@ -135,7 +137,7 @@ class RArraySizeField final : public ROOT::RFieldBase {
135137

136138
public:
137139
RArraySizeField(std::size_t arrayLength)
138-
: ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kLeaf, false /* isSimple */),
140+
: ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kStatic, false /* isSimple */),
139141
fArrayLength(arrayLength)
140142
{
141143
}

tree/ntuple/inc/ROOT/RField.hxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ protected:
9595

9696
public:
9797
RInvalidField(std::string_view name, std::string_view type, std::string_view error, RCategory category)
98-
: RFieldBase(name, type, ROOT::ENTupleStructure::kLeaf, false /* isSimple */), fError(error), fCategory(category)
98+
: RFieldBase(name, type, ROOT::ENTupleStructure::kStatic, false /* isSimple */), fError(error)
99+
, fCategory(category)
99100
{
100101
fTraits |= kTraitInvalidField;
101102
}
@@ -324,7 +325,7 @@ private:
324325

325326
protected:
326327
RCardinalityField(std::string_view fieldName, std::string_view typeName)
327-
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
328+
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kStatic, false /* isSimple */)
328329
{
329330
}
330331

@@ -354,7 +355,7 @@ protected:
354355

355356
public:
356357
RSimpleField(std::string_view name, std::string_view type)
357-
: RFieldBase(name, type, ROOT::ENTupleStructure::kLeaf, true /* isSimple */)
358+
: RFieldBase(name, type, ROOT::ENTupleStructure::kStatic, true /* isSimple */)
358359
{
359360
fTraits |= kTraitTrivialType;
360361
}

tree/ntuple/inc/ROOT/RField/RFieldSTLMisc.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private:
336336
public:
337337
static std::string TypeName() { return "std::string"; }
338338
explicit RField(std::string_view name)
339-
: RFieldBase(name, TypeName(), ROOT::ENTupleStructure::kLeaf, false /* isSimple */), fIndex(0)
339+
: RFieldBase(name, TypeName(), ROOT::ENTupleStructure::kStatic, false /* isSimple */), fIndex(0)
340340
{
341341
}
342342
RField(RField &&other) = default;

tree/ntuple/inc/ROOT/RNTupleUtil.hxx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,28 @@ enum class ENTupleColumnType {
105105
kMax,
106106
};
107107

108-
/// The fields in the ntuple model tree can carry different structural information about the type system.
109-
/// Leaf fields contain just data, collection fields resolve to offset columns, record fields have no
110-
/// materialization on the primitive column layer.
108+
/// The fields in the RNTuple data model tree can carry different structural information about the type system.
109+
/// Collection fields have an offset column and subfields with arbitrary cardinality, record fields have no
110+
/// materialization on the primitive column layer and an arbitrary number of subfields. Static fields are either
111+
/// leafs (e.g., `float`) or fields with exactly one child that has the same cardinality as the parent
112+
/// (modulo field repetitions, e.g. std::atomic<T>).
111113
// IMPORTANT: if you add members, remember to change the related `operator<<` below.
112114
enum class ENTupleStructure : std::uint16_t {
113115
kInvalid,
114-
kLeaf,
116+
kStatic,
115117
kCollection,
116118
kRecord,
117119
kVariant,
118120
kStreamer,
119-
kUnknown
121+
kUnknown,
122+
123+
// for backwards compatibility
124+
kLeaf R__DEPRECATED(6, 40, "use instead ROOT::ENTupleStructure::kStatic") = kStatic
120125
};
121126

122127
inline std::ostream &operator<<(std::ostream &os, ENTupleStructure structure)
123128
{
124-
static const char *const names[] = {"Invalid", "Leaf", "Collection", "Record", "Variant", "Streamer", "Unknown"};
129+
static const char *const names[] = {"Invalid", "Static", "Collection", "Record", "Variant", "Streamer", "Unknown"};
125130
static_assert((std::size_t)ENTupleStructure::kUnknown + 1 == std::size(names));
126131

127132
if (R__likely(static_cast<std::size_t>(structure) <= std::size(names)))

tree/ntuple/src/RField.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ void ROOT::RRecordField::AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) con
624624
//------------------------------------------------------------------------------
625625

626626
ROOT::RBitsetField::RBitsetField(std::string_view fieldName, std::size_t N)
627-
: ROOT::RFieldBase(fieldName, "std::bitset<" + std::to_string(N) + ">", ROOT::ENTupleStructure::kLeaf,
627+
: ROOT::RFieldBase(fieldName, "std::bitset<" + std::to_string(N) + ">", ROOT::ENTupleStructure::kStatic,
628628
false /* isSimple */, N),
629629
fN(N)
630630
{
@@ -971,7 +971,7 @@ size_t ROOT::ROptionalField::GetAlignment() const
971971

972972
ROOT::RAtomicField::RAtomicField(std::string_view fieldName, std::string_view typeName,
973973
std::unique_ptr<RFieldBase> itemField)
974-
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
974+
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kStatic, false /* isSimple */)
975975
{
976976
if (itemField->GetTraits() & kTraitTriviallyConstructible)
977977
fTraits |= kTraitTriviallyConstructible;

tree/ntuple/src/RFieldMeta.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumNa
517517
}
518518

519519
ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
520-
: ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kLeaf,
520+
: ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kStatic,
521521
false /* isSimple */)
522522
{
523523
// Avoid accidentally supporting std types through TEnum.
@@ -544,7 +544,7 @@ ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
544544

545545
ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumName,
546546
std::unique_ptr<RFieldBase> intField)
547-
: ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
547+
: ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kStatic, false /* isSimple */)
548548
{
549549
Attach(std::move(intField));
550550
fTraits |= kTraitTriviallyConstructible | kTraitTriviallyDestructible;

tree/ntuple/src/RFieldSequenceContainer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ROOT::RArrayField::RArrayField(std::string_view fieldName, std::unique_ptr<RFiel
1717
: ROOT::RFieldBase(fieldName,
1818
"std::array<" + itemField->GetTypeName() + "," +
1919
Internal::GetNormalizedInteger(static_cast<unsigned long long>(arrayLength)) + ">",
20-
ROOT::ENTupleStructure::kLeaf, false /* isSimple */, arrayLength),
20+
ROOT::ENTupleStructure::kStatic, false /* isSimple */, arrayLength),
2121
fItemSize(itemField->GetValueSize()),
2222
fArrayLength(arrayLength)
2323
{

tree/ntuple/src/RNTupleMerger.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static void GenerateZeroPagesForColumns(size_t nEntriesToGenerate, std::span<con
691691

692692
// NOTE: we cannot have a Record here because it has no associated columns.
693693
R__ASSERT(structure == ROOT::ENTupleStructure::kCollection || structure == ROOT::ENTupleStructure::kVariant ||
694-
structure == ROOT::ENTupleStructure::kLeaf);
694+
structure == ROOT::ENTupleStructure::kStatic);
695695

696696
const auto &columnDesc = dstDescriptor.GetColumnDescriptor(column.fOutputId);
697697
const auto colElement = RColumnElementBase::Generate(columnDesc.GetType());

tree/ntuple/src/RNTupleModel.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ROOT::Internal::RProjectedFields::EnsureValidMapping(const ROOT::RFieldBase *tar
7272
dynamic_cast<const ROOT::RCardinalityField *>(target));
7373
if (!hasCompatibleStructure)
7474
return R__FAIL("field mapping structural mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
75-
if ((source->GetStructure() == ROOT::ENTupleStructure::kLeaf) ||
75+
if ((source->GetStructure() == ROOT::ENTupleStructure::kStatic) ||
7676
(source->GetStructure() == ROOT::ENTupleStructure::kStreamer)) {
7777
if (target->GetTypeName() != source->GetTypeName())
7878
return R__FAIL("field mapping type mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
@@ -99,7 +99,7 @@ ROOT::Internal::RProjectedFields::EnsureValidMapping(const ROOT::RFieldBase *tar
9999
auto parent = f->GetParent();
100100
while (parent) {
101101
if ((parent->GetStructure() != ROOT::ENTupleStructure::kRecord) &&
102-
(parent->GetStructure() != ROOT::ENTupleStructure::kLeaf)) {
102+
(parent->GetStructure() != ROOT::ENTupleStructure::kStatic)) {
103103
return parent;
104104
}
105105
parent = parent->GetParent();

tree/ntuple/src/RNTupleSerialize.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ DeserializeField(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RFie
148148
std::uint32_t typeVersion;
149149
std::uint32_t parentId;
150150
// initialize properly for call to SerializeFieldStructure()
151-
ENTupleStructure structure{ENTupleStructure::kLeaf};
151+
ENTupleStructure structure{ENTupleStructure::kStatic};
152152
std::uint16_t flags;
153153
std::uint32_t result;
154154
if (auto res = RNTupleSerializer::SerializeFieldStructure(structure, nullptr)) {
@@ -810,7 +810,7 @@ ROOT::Internal::RNTupleSerializer::SerializeFieldStructure(ROOT::ENTupleStructur
810810
{
811811
using ENTupleStructure = ROOT::ENTupleStructure;
812812
switch (structure) {
813-
case ENTupleStructure::kLeaf: return SerializeUInt16(0x00, buffer);
813+
case ENTupleStructure::kStatic: return SerializeUInt16(0x00, buffer);
814814
case ENTupleStructure::kCollection: return SerializeUInt16(0x01, buffer);
815815
case ENTupleStructure::kRecord: return SerializeUInt16(0x02, buffer);
816816
case ENTupleStructure::kVariant: return SerializeUInt16(0x03, buffer);
@@ -829,7 +829,7 @@ ROOT::Internal::RNTupleSerializer::DeserializeFieldStructure(const void *buffer,
829829
std::uint16_t onDiskValue;
830830
auto result = DeserializeUInt16(buffer, onDiskValue);
831831
switch (onDiskValue) {
832-
case 0x00: structure = ENTupleStructure::kLeaf; break;
832+
case 0x00: structure = ENTupleStructure::kStatic; break;
833833
case 0x01: structure = ENTupleStructure::kCollection; break;
834834
case 0x02: structure = ENTupleStructure::kRecord; break;
835835
case 0x03: structure = ENTupleStructure::kVariant; break;

0 commit comments

Comments
 (0)