Skip to content

Commit 133130d

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 42e99d5 commit 133130d

13 files changed

+60
-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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ 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 */),
99+
fError(error),
100+
fCategory(category)
99101
{
100102
fTraits |= kTraitInvalidField;
101103
}
@@ -324,7 +326,7 @@ private:
324326

325327
protected:
326328
RCardinalityField(std::string_view fieldName, std::string_view typeName)
327-
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
329+
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kStatic, false /* isSimple */)
328330
{
329331
}
330332

@@ -354,7 +356,7 @@ protected:
354356

355357
public:
356358
RSimpleField(std::string_view name, std::string_view type)
357-
: RFieldBase(name, type, ROOT::ENTupleStructure::kLeaf, true /* isSimple */)
359+
: RFieldBase(name, type, ROOT::ENTupleStructure::kStatic, true /* isSimple */)
358360
{
359361
fTraits |= kTraitTrivialType;
360362
}

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/RNTupleTypes.hxx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,28 @@ enum class ENTupleColumnType {
9999
kMax,
100100
};
101101

102-
/// The fields in the ntuple model tree can carry different structural information about the type system.
103-
/// Leaf fields contain just data, collection fields resolve to offset columns, record fields have no
104-
/// materialization on the primitive column layer.
102+
/// The fields in the RNTuple data model tree can carry different structural information about the type system.
103+
/// Collection fields have an offset column and subfields with arbitrary cardinality, record fields have no
104+
/// materialization on the primitive column layer and an arbitrary number of subfields. Static fields are either
105+
/// leafs (e.g., `float`) or fields with exactly one child that has the same cardinality as the parent
106+
/// (modulo field repetitions, e.g. std::atomic<T>).
105107
// IMPORTANT: if you add members, remember to change the related `operator<<` below.
106108
enum class ENTupleStructure : std::uint16_t {
107109
kInvalid,
108-
kLeaf,
110+
kStatic,
109111
kCollection,
110112
kRecord,
111113
kVariant,
112114
kStreamer,
113-
kUnknown
115+
kUnknown,
116+
117+
// for backwards compatibility
118+
kLeaf R__DEPRECATED(6, 40, "use instead ROOT::ENTupleStructure::kStatic") = kStatic
114119
};
115120

116121
inline std::ostream &operator<<(std::ostream &os, ENTupleStructure structure)
117122
{
118-
static const char *const names[] = {"Invalid", "Leaf", "Collection", "Record", "Variant", "Streamer", "Unknown"};
123+
static const char *const names[] = {"Invalid", "Static", "Collection", "Record", "Variant", "Streamer", "Unknown"};
119124
static_assert((std::size_t)ENTupleStructure::kUnknown + 1 == std::size(names));
120125

121126
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
@@ -634,7 +634,7 @@ void ROOT::RRecordField::AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) con
634634
//------------------------------------------------------------------------------
635635

636636
ROOT::RBitsetField::RBitsetField(std::string_view fieldName, std::size_t N)
637-
: ROOT::RFieldBase(fieldName, "std::bitset<" + std::to_string(N) + ">", ROOT::ENTupleStructure::kLeaf,
637+
: ROOT::RFieldBase(fieldName, "std::bitset<" + std::to_string(N) + ">", ROOT::ENTupleStructure::kStatic,
638638
false /* isSimple */, N),
639639
fN(N)
640640
{
@@ -981,7 +981,7 @@ size_t ROOT::ROptionalField::GetAlignment() const
981981

982982
ROOT::RAtomicField::RAtomicField(std::string_view fieldName, std::string_view typeName,
983983
std::unique_ptr<RFieldBase> itemField)
984-
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
984+
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kStatic, false /* isSimple */)
985985
{
986986
if (itemField->GetTraits() & kTraitTriviallyConstructible)
987987
fTraits |= kTraitTriviallyConstructible;

tree/ntuple/src/RFieldMeta.cxx

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

520520
ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
521-
: ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kLeaf,
521+
: ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kStatic,
522522
false /* isSimple */)
523523
{
524524
// Avoid accidentally supporting std types through TEnum.
@@ -545,7 +545,7 @@ ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
545545

546546
ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumName,
547547
std::unique_ptr<RFieldBase> intField)
548-
: ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
548+
: ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kStatic, false /* isSimple */)
549549
{
550550
Attach(std::move(intField));
551551
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
@@ -692,7 +692,7 @@ static void GenerateZeroPagesForColumns(size_t nEntriesToGenerate, std::span<con
692692

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

697697
const auto &columnDesc = dstDescriptor.GetColumnDescriptor(column.fOutputId);
698698
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
@@ -73,7 +73,7 @@ ROOT::Internal::RProjectedFields::EnsureValidMapping(const ROOT::RFieldBase *tar
7373
dynamic_cast<const ROOT::RCardinalityField *>(target));
7474
if (!hasCompatibleStructure)
7575
return R__FAIL("field mapping structural mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
76-
if ((source->GetStructure() == ROOT::ENTupleStructure::kLeaf) ||
76+
if ((source->GetStructure() == ROOT::ENTupleStructure::kStatic) ||
7777
(source->GetStructure() == ROOT::ENTupleStructure::kStreamer)) {
7878
if (target->GetTypeName() != source->GetTypeName())
7979
return R__FAIL("field mapping type mismatch: " + source->GetFieldName() + " --> " + target->GetFieldName());
@@ -100,7 +100,7 @@ ROOT::Internal::RProjectedFields::EnsureValidMapping(const ROOT::RFieldBase *tar
100100
auto parent = f->GetParent();
101101
while (parent) {
102102
if ((parent->GetStructure() != ROOT::ENTupleStructure::kRecord) &&
103-
(parent->GetStructure() != ROOT::ENTupleStructure::kLeaf)) {
103+
(parent->GetStructure() != ROOT::ENTupleStructure::kStatic)) {
104104
return parent;
105105
}
106106
parent = parent->GetParent();

tree/ntuple/src/RNTupleSerialize.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ DeserializeField(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RFie
149149
std::uint32_t typeVersion;
150150
std::uint32_t parentId;
151151
// initialize properly for call to SerializeFieldStructure()
152-
ENTupleStructure structure{ENTupleStructure::kLeaf};
152+
ENTupleStructure structure{ENTupleStructure::kStatic};
153153
std::uint16_t flags;
154154
std::uint32_t result;
155155
if (auto res = RNTupleSerializer::SerializeFieldStructure(structure, nullptr)) {
@@ -811,7 +811,7 @@ ROOT::Internal::RNTupleSerializer::SerializeFieldStructure(ROOT::ENTupleStructur
811811
{
812812
using ENTupleStructure = ROOT::ENTupleStructure;
813813
switch (structure) {
814-
case ENTupleStructure::kLeaf: return SerializeUInt16(0x00, buffer);
814+
case ENTupleStructure::kStatic: return SerializeUInt16(0x00, buffer);
815815
case ENTupleStructure::kCollection: return SerializeUInt16(0x01, buffer);
816816
case ENTupleStructure::kRecord: return SerializeUInt16(0x02, buffer);
817817
case ENTupleStructure::kVariant: return SerializeUInt16(0x03, buffer);
@@ -830,7 +830,7 @@ ROOT::Internal::RNTupleSerializer::DeserializeFieldStructure(const void *buffer,
830830
std::uint16_t onDiskValue;
831831
auto result = DeserializeUInt16(buffer, onDiskValue);
832832
switch (onDiskValue) {
833-
case 0x00: structure = ENTupleStructure::kLeaf; break;
833+
case 0x00: structure = ENTupleStructure::kStatic; break;
834834
case 0x01: structure = ENTupleStructure::kCollection; break;
835835
case 0x02: structure = ENTupleStructure::kRecord; break;
836836
case 0x03: structure = ENTupleStructure::kVariant; break;

0 commit comments

Comments
 (0)