Skip to content

Commit c935ac6

Browse files
committed
[ntuple] ENTupleStructure::kLeaf --> kPlain
The structural role "leaf" was ill-named because in the tree of fields also inner nodes can carry that role. Hence renamed to "plain". Plain nodes are either leaves or they are inner "wrapper fields" with exactly one child field of the same cardinality (same number of elements modulo field repetition).
1 parent f696a50 commit c935ac6

13 files changed

+57
-52
lines changed

tree/dataframe/src/RNTupleDS.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ 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::kPlain, false /* isSimple */) {}
6969
RRDFCardinalityField(RRDFCardinalityField &&other) = default;
7070
RRDFCardinalityField &operator=(RRDFCardinalityField &&other) = default;
7171
~RRDFCardinalityField() override = default;
@@ -135,7 +135,7 @@ class RArraySizeField final : public ROOT::RFieldBase {
135135

136136
public:
137137
RArraySizeField(std::size_t arrayLength)
138-
: ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kLeaf, false /* isSimple */),
138+
: ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kPlain, false /* isSimple */),
139139
fArrayLength(arrayLength)
140140
{
141141
}

tree/ntuple/inc/ROOT/RField.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected:
9797

9898
public:
9999
RInvalidField(std::string_view name, std::string_view type, std::string_view error, ECategory category)
100-
: RFieldBase(name, type, ROOT::ENTupleStructure::kLeaf, false /* isSimple */), fError(error), fCategory(category)
100+
: RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, false /* isSimple */), fError(error), fCategory(category)
101101
{
102102
fTraits |= kTraitInvalidField;
103103
}
@@ -326,7 +326,7 @@ private:
326326

327327
protected:
328328
RCardinalityField(std::string_view fieldName, std::string_view typeName)
329-
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
329+
: RFieldBase(fieldName, typeName, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
330330
{
331331
}
332332

@@ -355,7 +355,7 @@ protected:
355355
void ConstructValue(void *where) const final { new (where) T{0}; }
356356

357357
RSimpleField(std::string_view name, std::string_view type)
358-
: RFieldBase(name, type, ROOT::ENTupleStructure::kLeaf, true /* isSimple */)
358+
: RFieldBase(name, type, ROOT::ENTupleStructure::kPlain, true /* isSimple */)
359359
{
360360
fTraits |= kTraitTrivialType;
361361
}

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::kPlain, 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. Plain fields are either
105+
/// leafs (e.g., `float`) or "wrapper fields" with exactly one child that has the same cardinality
106+
/// (number of elements in the data set modulo field repetitions) as the parent (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+
kPlain,
109111
kCollection,
110112
kRecord,
111113
kVariant,
112114
kStreamer,
113-
kUnknown
115+
kUnknown,
116+
117+
// for backwards compatibility
118+
kLeaf R__DEPRECATED(6, 42, "use instead ROOT::ENTupleStructure::kPlain") = kPlain
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", "Plain", "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::kPlain,
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::kPlain, 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
@@ -524,7 +524,7 @@ ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumNa
524524
}
525525

526526
ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
527-
: ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kLeaf,
527+
: ROOT::RFieldBase(fieldName, GetRenormalizedTypeName(enump->GetQualifiedName()), ROOT::ENTupleStructure::kPlain,
528528
false /* isSimple */)
529529
{
530530
// Avoid accidentally supporting std types through TEnum.
@@ -551,7 +551,7 @@ ROOT::REnumField::REnumField(std::string_view fieldName, TEnum *enump)
551551

552552
ROOT::REnumField::REnumField(std::string_view fieldName, std::string_view enumName,
553553
std::unique_ptr<RFieldBase> intField)
554-
: ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kLeaf, false /* isSimple */)
554+
: ROOT::RFieldBase(fieldName, enumName, ROOT::ENTupleStructure::kPlain, false /* isSimple */)
555555
{
556556
Attach(std::move(intField));
557557
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::kPlain, 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
@@ -700,7 +700,7 @@ GenerateZeroPagesForColumns(size_t nEntriesToGenerate, std::span<const RColumnMe
700700

701701
// NOTE: we cannot have a Record here because it has no associated columns.
702702
R__ASSERT(structure == ROOT::ENTupleStructure::kCollection || structure == ROOT::ENTupleStructure::kVariant ||
703-
structure == ROOT::ENTupleStructure::kLeaf);
703+
structure == ROOT::ENTupleStructure::kPlain);
704704

705705
const auto &columnDesc = dstDescriptor.GetColumnDescriptor(column.fOutputId);
706706
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::kPlain) ||
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::kPlain)) {
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::kPlain};
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::kPlain: 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::kPlain; 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)