diff --git a/tree/dataframe/src/RNTupleDS.cxx b/tree/dataframe/src/RNTupleDS.cxx index db1f3aa17b568..14198e5baf469 100644 --- a/tree/dataframe/src/RNTupleDS.cxx +++ b/tree/dataframe/src/RNTupleDS.cxx @@ -58,9 +58,9 @@ namespace ROOT::Internal::RDF { /// TODO(jblomer): consider providing a general set of useful virtual fields as part of RNTuple. class RRDFCardinalityField final : public ROOT::RFieldBase { protected: - std::unique_ptr CloneImpl(std::string_view /* newName */) const final + std::unique_ptr CloneImpl(std::string_view newName) const final { - return std::make_unique(); + return std::make_unique(newName); } void ConstructValue(void *where) const final { *static_cast(where) = 0; } @@ -68,7 +68,10 @@ class RRDFCardinalityField final : public ROOT::RFieldBase { void ReconcileOnDiskField(const RNTupleDescriptor &) final {} public: - RRDFCardinalityField() : ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kPlain, false /* isSimple */) {} + RRDFCardinalityField(std::string_view name) + : ROOT::RFieldBase(name, "std::size_t", ROOT::ENTupleStructure::kPlain, false /* isSimple */) + { + } RRDFCardinalityField(RRDFCardinalityField &&other) = default; RRDFCardinalityField &operator=(RRDFCardinalityField &&other) = default; ~RRDFCardinalityField() override = default; @@ -121,9 +124,9 @@ class RArraySizeField final : public ROOT::RFieldBase { private: std::size_t fArrayLength; - std::unique_ptr CloneImpl(std::string_view) const final + std::unique_ptr CloneImpl(std::string_view newName) const final { - return std::make_unique(fArrayLength); + return std::make_unique(newName, fArrayLength); } void GenerateColumns() final { throw RException(R__FAIL("RArraySizeField fields must only be used for reading")); } void GenerateColumns(const ROOT::RNTupleDescriptor &) final {} @@ -140,8 +143,8 @@ class RArraySizeField final : public ROOT::RFieldBase { void ReconcileOnDiskField(const RNTupleDescriptor &) final {} public: - RArraySizeField(std::size_t arrayLength) - : ROOT::RFieldBase("", "std::size_t", ROOT::ENTupleStructure::kPlain, false /* isSimple */), + RArraySizeField(std::string_view name, std::size_t arrayLength) + : ROOT::RFieldBase(name, "std::size_t", ROOT::ENTupleStructure::kPlain, false /* isSimple */), fArrayLength(arrayLength) { } @@ -330,10 +333,11 @@ void ROOT::RDF::RNTupleDS::AddField(const ROOT::RNTupleDescriptor &desc, std::st // Collections get the additional "number of" RDF column (e.g. "R_rdf_sizeof_tracks") if (!fieldInfos.empty()) { const auto &info = fieldInfos.back(); + const std::string name = "R_rdf_sizeof_" + desc.GetFieldDescriptor(info.fFieldId).GetFieldName(); if (info.fNRepetitions > 0) { - cardinalityField = std::make_unique(info.fNRepetitions); + cardinalityField = std::make_unique(name, info.fNRepetitions); } else { - cardinalityField = std::make_unique(); + cardinalityField = std::make_unique(name); } cardinalityField->SetOnDiskId(info.fFieldId); } @@ -341,17 +345,20 @@ void ROOT::RDF::RNTupleDS::AddField(const ROOT::RNTupleDescriptor &desc, std::st for (auto i = fieldInfos.rbegin(); i != fieldInfos.rend(); ++i) { const auto &fieldInfo = *i; + const auto valueFieldName = valueField->GetFieldName(); + if (fieldInfo.fNRepetitions > 0) { // Fixed-size array, read it as ROOT::RVec in memory - valueField = std::make_unique("", std::move(valueField), fieldInfo.fNRepetitions); + valueField = + std::make_unique(valueFieldName, valueField->Clone("_0"), fieldInfo.fNRepetitions); } else { // Actual collection. A std::vector or ROOT::RVec gets added as a ROOT::RVec. All other collection types keep // their original type. if (convertToRVec) { - valueField = std::make_unique("", std::move(valueField)); + valueField = std::make_unique(valueFieldName, valueField->Clone("_0")); } else { auto outerFieldType = desc.GetFieldDescriptor(fieldInfo.fFieldId).GetTypeName(); - valueField = ROOT::RFieldBase::Create("", outerFieldType).Unwrap(); + valueField = ROOT::RFieldBase::Create(valueFieldName, outerFieldType).Unwrap(); } } @@ -360,13 +367,14 @@ void ROOT::RDF::RNTupleDS::AddField(const ROOT::RNTupleDescriptor &desc, std::st // Skip the inner-most collection level to construct the cardinality column // It's taken care of by the `if (!fieldInfos.empty())` scope above if (i != fieldInfos.rbegin()) { + const auto cardinalityFieldName = cardinalityField->GetFieldName(); if (fieldInfo.fNRepetitions > 0) { // This collection level refers to a fixed-size array - cardinalityField = - std::make_unique("", std::move(cardinalityField), fieldInfo.fNRepetitions); + cardinalityField = std::make_unique( + cardinalityFieldName, cardinalityField->Clone("_0"), fieldInfo.fNRepetitions); } else { // This collection level refers to an RVec - cardinalityField = std::make_unique("", std::move(cardinalityField)); + cardinalityField = std::make_unique(cardinalityFieldName, cardinalityField->Clone("_0")); } cardinalityField->SetOnDiskId(fieldInfo.fFieldId); diff --git a/tree/ntuple/inc/ROOT/RField.hxx b/tree/ntuple/inc/ROOT/RField.hxx index b8783121174f6..20a7c6b94a7c9 100644 --- a/tree/ntuple/inc/ROOT/RField.hxx +++ b/tree/ntuple/inc/ROOT/RField.hxx @@ -69,6 +69,8 @@ class RFieldZero final : public RFieldBase { /// This flag is reset on Clone(). bool fAllowFieldSubstitutions = false; + std::unordered_set fSubFieldNames; ///< Efficient detection of duplicate field names + protected: std::unique_ptr CloneImpl(std::string_view newName) const final; void ConstructValue(void *) const final {} @@ -76,7 +78,9 @@ protected: public: RFieldZero() : RFieldBase("", "", ROOT::ENTupleStructure::kRecord, false /* isSimple */) {} - using RFieldBase::Attach; + /// A public version of the Attach method that allows piece-wise construction of the zero field. + /// Will throw on duplicate subfield names. + void Attach(std::unique_ptr child); size_t GetValueSize() const final { return 0; } size_t GetAlignment() const final { return 0; } diff --git a/tree/ntuple/inc/ROOT/RField/RFieldRecord.hxx b/tree/ntuple/inc/ROOT/RField/RFieldRecord.hxx index 6e8437eb46175..a03e1daeaa8cf 100644 --- a/tree/ntuple/inc/ROOT/RField/RFieldRecord.hxx +++ b/tree/ntuple/inc/ROOT/RField/RFieldRecord.hxx @@ -87,17 +87,17 @@ protected: /// that ensure that the resulting memory layout matches std::pair or std::tuple, resp. RRecordField(std::string_view fieldName, std::string_view typeName); - void AttachItemFields(std::vector> itemFields); + void AttachItemFields(std::vector> itemFields, bool useNumberedFields); template - void AttachItemFields(std::array, N> itemFields) + void AttachItemFields(std::array, N> itemFields, bool useNumberedFields) { fTraits |= kTraitTrivialType; for (unsigned i = 0; i < N; ++i) { fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment()); fSize += GetItemPadding(fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize(); fTraits &= itemFields[i]->GetTraits(); - Attach(std::move(itemFields[i])); + Attach(std::move(itemFields[i]), useNumberedFields ? ("_" + std::to_string(i)) : ""); } // Trailing padding: although this is implementation-dependent, most add enough padding to comply with the // requirements of the type with strictest alignment diff --git a/tree/ntuple/inc/ROOT/RFieldBase.hxx b/tree/ntuple/inc/ROOT/RFieldBase.hxx index 3c27e0d7628a8..f7ff3d6542491 100644 --- a/tree/ntuple/inc/ROOT/RFieldBase.hxx +++ b/tree/ntuple/inc/ROOT/RFieldBase.hxx @@ -501,8 +501,9 @@ protected: // on the data that's written, e.g. for polymorphic types in the streamer field. virtual ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo() const { return ROOT::RExtraTypeInfoDescriptor(); } - /// Add a new subfield to the list of nested fields - void Attach(std::unique_ptr child); + /// Add a new subfield to the list of nested fields. Throws an exception if childName is non-empty and the passed + /// field has a different name. + void Attach(std::unique_ptr child, std::string_view expectedChildName = ""); /// Called by ConnectPageSource() before connecting; derived classes may override this as appropriate, e.g. /// for the application of I/O rules. In the process, the field at hand or its subfields may be marked as diff --git a/tree/ntuple/src/RField.cxx b/tree/ntuple/src/RField.cxx index b5250382b2dc6..bdef34618b5a7 100644 --- a/tree/ntuple/src/RField.cxx +++ b/tree/ntuple/src/RField.cxx @@ -38,11 +38,22 @@ void ROOT::Internal::SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val) fieldZero.fAllowFieldSubstitutions = val; } +void ROOT::RFieldZero::Attach(std::unique_ptr child) +{ + const std::string childName = child->GetFieldName(); + if (fSubFieldNames.count(childName) > 0) + throw RException(R__FAIL("duplicate field name: " + childName)); + RFieldBase::Attach(std::move(child), ""); + fSubFieldNames.insert(childName); +} + std::unique_ptr ROOT::RFieldZero::CloneImpl(std::string_view /*newName*/) const { auto result = std::make_unique(); - for (auto &f : fSubfields) + for (auto &f : fSubfields) { result->Attach(f->Clone(f->GetFieldName())); + result->fSubFieldNames.insert(f->GetFieldName()); + } return result; } @@ -565,14 +576,15 @@ ROOT::RRecordField::RRecordField(std::string_view fieldName, std::string_view ty { } -void ROOT::RRecordField::AttachItemFields(std::vector> itemFields) +void ROOT::RRecordField::AttachItemFields(std::vector> itemFields, bool useNumberedFields) { fTraits |= kTraitTrivialType; - for (auto &item : itemFields) { - fMaxAlignment = std::max(fMaxAlignment, item->GetAlignment()); - fSize += GetItemPadding(fSize, item->GetAlignment()) + item->GetValueSize(); - fTraits &= item->GetTraits(); - Attach(std::move(item)); + const auto N = itemFields.size(); + for (std::size_t i = 0; i < N; ++i) { + fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment()); + fSize += GetItemPadding(fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize(); + fTraits &= itemFields[i]->GetTraits(); + Attach(std::move(itemFields[i]), useNumberedFields ? ("_" + std::to_string(i)) : ""); } // Trailing padding: although this is implementation-dependent, most add enough padding to comply with the // requirements of the type with strictest alignment @@ -602,7 +614,12 @@ ROOT::RRecordField::RRecordField(std::string_view fieldName, std::vector fieldNames; for (auto &item : itemFields) { + const auto &itemName = item->GetFieldName(); + if (!fieldNames.insert(itemName).second) { + throw RException(R__FAIL("duplicate field name: " + itemName)); + } fSize += GetItemPadding(fSize, item->GetAlignment()); fOffsets.push_back(fSize); fMaxAlignment = std::max(fMaxAlignment, item->GetAlignment()); @@ -845,7 +862,7 @@ ROOT::RNullableField::RNullableField(std::string_view fieldName, const std::stri if (!itemField->GetTypeAlias().empty()) fTypeAlias = typePrefix + "<" + itemField->GetTypeAlias() + ">"; - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); } const ROOT::RFieldBase::RColumnRepresentations &ROOT::RNullableField::GetColumnRepresentations() const @@ -1190,7 +1207,7 @@ ROOT::RAtomicField::RAtomicField(std::string_view fieldName, std::unique_ptrGetTypeAlias().empty()) fTypeAlias = "std::atomic<" + itemField->GetTypeAlias() + ">"; - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); } std::unique_ptr ROOT::RAtomicField::CloneImpl(std::string_view newName) const diff --git a/tree/ntuple/src/RFieldBase.cxx b/tree/ntuple/src/RFieldBase.cxx index 1cc69fa63ba4c..1a7a208dcaef5 100644 --- a/tree/ntuple/src/RFieldBase.cxx +++ b/tree/ntuple/src/RFieldBase.cxx @@ -648,12 +648,18 @@ std::vector ROOT::RFieldBase::SplitValue(const RValue return std::vector(); } -void ROOT::RFieldBase::Attach(std::unique_ptr child) +void ROOT::RFieldBase::Attach(std::unique_ptr child, std::string_view expectedChildName) { // Note that during a model update, new fields will be attached to the zero field. The zero field, however, // does not change its inital state because only its sub fields get connected by RPageSink::UpdateSchema. if (fState != EState::kUnconnected) throw RException(R__FAIL("invalid attempt to attach subfield to already connected field")); + + if (!expectedChildName.empty() && child->GetFieldName() != expectedChildName) { + throw RException(R__FAIL(std::string("invalid subfield name: ") + child->GetFieldName() + + " expected: " + std::string(expectedChildName))); + } + child->fParent = this; fSubfields.emplace_back(std::move(child)); } diff --git a/tree/ntuple/src/RFieldMeta.cxx b/tree/ntuple/src/RFieldMeta.cxx index 9ef7fa5e6a2fb..198aebb202a8a 100644 --- a/tree/ntuple/src/RFieldMeta.cxx +++ b/tree/ntuple/src/RFieldMeta.cxx @@ -709,7 +709,7 @@ ROOT::RPairField::RPairField(std::string_view fieldName, std::array ROOT::RProxiedCollectionField::CloneImpl(std::string_view newName) const { - auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName()); auto clone = std::unique_ptr(new RProxiedCollectionField(newName, fProxy->GetCollectionClass())); clone->fItemSize = fItemSize; - clone->Attach(std::move(newItemField)); + clone->Attach(fSubfields[0]->Clone(fSubfields[0]->GetFieldName())); return clone; } @@ -976,7 +975,7 @@ ROOT::RMapField::RMapField(std::string_view fieldName, EMapType mapType, std::un auto *itemClass = fProxy->GetValueClass(); fItemSize = itemClass->GetClassSize(); - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); } std::unique_ptr ROOT::RMapField::CloneImpl(std::string_view newName) const @@ -1011,7 +1010,7 @@ ROOT::RSetField::RSetField(std::string_view fieldName, ESetType setType, std::un fItemSize = itemField->GetValueSize(); - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); } std::unique_ptr ROOT::RSetField::CloneImpl(std::string_view newName) const @@ -1323,7 +1322,7 @@ ROOT::RTupleField::RTupleField(std::string_view fieldName, std::vectorGetValueSize()); fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment()); fTraits &= itemFields[i]->GetTraits(); - Attach(std::move(itemFields[i])); + Attach(std::move(itemFields[i]), "_" + std::to_string(i)); } // With certain template parameters, the union of members of an std::variant starts at an offset > 0. diff --git a/tree/ntuple/src/RFieldSequenceContainer.cxx b/tree/ntuple/src/RFieldSequenceContainer.cxx index 03789767f1e34..3995b82f2b1a6 100644 --- a/tree/ntuple/src/RFieldSequenceContainer.cxx +++ b/tree/ntuple/src/RFieldSequenceContainer.cxx @@ -128,7 +128,7 @@ ROOT::RArrayField::RArrayField(std::string_view fieldName, std::unique_ptrGetTypeAlias() + "," + Internal::GetNormalizedInteger(static_cast(arrayLength)) + ">"; } - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); } std::unique_ptr ROOT::RArrayField::CloneImpl(std::string_view newName) const @@ -251,7 +251,7 @@ ROOT::RRVecField::RRVecField(std::string_view fieldName, std::unique_ptrGetTypeAlias().empty()) fTypeAlias = "ROOT::VecOps::RVec<" + itemField->GetTypeAlias() + ">"; - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); fValueSize = EvalRVecValueSize(fSubfields[0]->GetAlignment(), fSubfields[0]->GetValueSize(), GetAlignment()); // Determine if we can optimimize bulk reading @@ -560,7 +560,7 @@ ROOT::RVectorField::RVectorField(std::string_view fieldName, std::unique_ptrGetTraits() & kTraitTriviallyDestructible)) fItemDeleter = GetDeleterOf(*itemField); - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); } ROOT::RVectorField::RVectorField(std::string_view fieldName, std::unique_ptr itemField) @@ -870,7 +870,7 @@ ROOT::RArrayAsRVecField::RArrayAsRVecField(std::string_view fieldName, std::uniq { if (!itemField->GetTypeAlias().empty()) fTypeAlias = "ROOT::VecOps::RVec<" + itemField->GetTypeAlias() + ">"; - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); fValueSize = EvalRVecValueSize(fSubfields[0]->GetAlignment(), fSubfields[0]->GetValueSize(), GetAlignment()); if (!(fSubfields[0]->GetTraits() & kTraitTriviallyDestructible)) fItemDeleter = GetDeleterOf(*fSubfields[0]); @@ -974,7 +974,7 @@ ROOT::RArrayAsVectorField::RArrayAsVectorField(std::string_view fieldName, std:: { if (!itemField->GetTypeAlias().empty()) fTypeAlias = "std::vector<" + itemField->GetTypeAlias() + ">"; - Attach(std::move(itemField)); + Attach(std::move(itemField), "_0"); if (!(fSubfields[0]->GetTraits() & kTraitTriviallyDestructible)) fItemDeleter = GetDeleterOf(*fSubfields[0]); } diff --git a/tree/ntuple/src/RNTupleProcessor.cxx b/tree/ntuple/src/RNTupleProcessor.cxx index 5ab94a2465db0..7db30a98da256 100644 --- a/tree/ntuple/src/RNTupleProcessor.cxx +++ b/tree/ntuple/src/RNTupleProcessor.cxx @@ -401,7 +401,7 @@ class RAuxiliaryProcessorField final : public ROOT::RRecordField { for (auto &item : itemFields) { fOffsets.push_back(GetItemPadding(fSize, item->GetAlignment())); } - AttachItemFields(std::move(itemFields)); + AttachItemFields(std::move(itemFields), false /* useNumberedFields */); } }; } // namespace ROOT::Experimental::Internal diff --git a/tree/ntuple/test/CMakeLists.txt b/tree/ntuple/test/CMakeLists.txt index 6a5ee685630e9..17278482d9cf2 100644 --- a/tree/ntuple/test/CMakeLists.txt +++ b/tree/ntuple/test/CMakeLists.txt @@ -43,6 +43,7 @@ if(NOT MSVC) ROOT_ADD_GTEST(ntuple_evolution_shape ntuple_evolution_shape.cxx LIBRARIES ROOTNTuple) ROOT_ADD_GTEST(ntuple_emulated ntuple_emulated.cxx LIBRARIES ROOTNTuple) endif() +ROOT_ADD_GTEST(ntuple_field_name ntuple_field_name.cxx LIBRARIES ROOTNTuple) ROOT_ADD_GTEST(ntuple_join_table ntuple_join_table.cxx LIBRARIES ROOTNTuple) ROOT_ADD_GTEST(ntuple_merger ntuple_merger.cxx LIBRARIES ROOTNTuple CustomStruct ZLIB::ZLIB Tree INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/tree/tree/inc) ROOT_ADD_GTEST(ntuple_metrics ntuple_metrics.cxx LIBRARIES ROOTNTuple) diff --git a/tree/ntuple/test/ntuple_field_name.cxx b/tree/ntuple/test/ntuple_field_name.cxx new file mode 100644 index 0000000000000..a5d962fc6521a --- /dev/null +++ b/tree/ntuple/test/ntuple_field_name.cxx @@ -0,0 +1,111 @@ +#include "ntuple_test.hxx" + +namespace { + +template +void CheckSingleSubfieldName() +{ + try { + FieldT("f", std::make_unique>("x")); + FAIL() << "invalid subfield name should fail"; + } catch (const ROOT::RException &e) { + EXPECT_THAT(e.what(), testing::HasSubstr("invalid subfield name")); + } +} + +template +void ResetContainer(ContainerT &) +{ + static_assert(!std::is_same_v, "unsupported container type"); +} + +template <> +void ResetContainer(std::vector> &v) +{ + v.resize(2); +} + +template <> +void ResetContainer(std::array, 2> &) +{ +} + +template +void CheckDoubleSubfieldName(SubfieldCollectionT &&items) +{ + ASSERT_EQ(2u, items.size()); + + items[0] = std::make_unique>("_0"); + items[1] = std::make_unique>("x"); + try { + FieldT("f", std::move(items)); + FAIL() << "invalid subfield name should fail"; + } catch (const ROOT::RException &e) { + EXPECT_THAT(e.what(), testing::HasSubstr("invalid subfield name")); + } + + ResetContainer(items); + + items[0] = std::make_unique>("x"); + items[1] = std::make_unique>("_1"); + try { + FieldT("f", std::move(items)); + FAIL() << "invalid subfield name should fail"; + } catch (const ROOT::RException &e) { + EXPECT_THAT(e.what(), testing::HasSubstr("invalid subfield name")); + } +} + +} // anonymous namespace + +TEST(RNTuple, SubFieldName) +{ + CheckSingleSubfieldName(); + CheckSingleSubfieldName(); + CheckSingleSubfieldName(); + CheckSingleSubfieldName(); + + CheckDoubleSubfieldName(std::vector>(2)); + CheckDoubleSubfieldName(std::vector>(2)); + CheckDoubleSubfieldName(std::array, 2>()); + + try { + ROOT::RArrayField("f", std::make_unique>("x"), 2); + FAIL() << "invalid subfield name should fail"; + } catch (const ROOT::RException &e) { + EXPECT_THAT(e.what(), testing::HasSubstr("invalid subfield name")); + } + + try { + ROOT::RSetField("f", ROOT::RSetField::ESetType::kSet, std::make_unique>("x")); + FAIL() << "invalid subfield name should fail"; + } catch (const ROOT::RException &e) { + EXPECT_THAT(e.what(), testing::HasSubstr("invalid subfield name")); + } + + std::unique_ptr p{ + new ROOT::RPairField("f", {std::make_unique>("_0"), std::make_unique>("_1")})}; + try { + ROOT::RMapField("f", ROOT::RMapField::EMapType::kMap, std::move(p)); + FAIL() << "invalid subfield name should fail"; + } catch (const ROOT::RException &e) { + EXPECT_THAT(e.what(), testing::HasSubstr("invalid subfield name")); + } +} + +TEST(RNTuple, FieldNameCollision) +{ + ROOT::RFieldZero zero; + zero.Attach(std::make_unique>("x")); + EXPECT_THROW(zero.Attach(std::make_unique>("x")), ROOT::RException); + + std::vector> items; + items.emplace_back(std::make_unique>("x")); + items.emplace_back(std::make_unique>("x")); + try { + ROOT::RRecordField("f", std::move(items)); + FAIL() << "duplicate field names should throw"; + } catch (const ROOT::RException &err) { + EXPECT_THAT(err.what(), testing::HasSubstr("duplicate field name")); + } +} diff --git a/tree/ntuple/test/ntuple_print.cxx b/tree/ntuple/test/ntuple_print.cxx index 1ac73392ff0d5..49b23ba9c6713 100644 --- a/tree/ntuple/test/ntuple_print.cxx +++ b/tree/ntuple/test/ntuple_print.cxx @@ -118,7 +118,7 @@ TEST(RNtuplePrint, ArrayAsRVec) { std::stringstream os; RPrepareVisitor prepVisitor; - ROOT::RArrayAsRVecField testField("arrayasrvecfield", std::make_unique>("myfloat"), 0); + ROOT::RArrayAsRVecField testField("arrayasrvecfield", std::make_unique>("_0"), 0); testField.AcceptVisitor(prepVisitor); RPrintSchemaVisitor visitor(os, '$'); visitor.SetDeepestLevel(prepVisitor.GetDeepestLevel()); @@ -126,7 +126,7 @@ TEST(RNtuplePrint, ArrayAsRVec) testField.AcceptVisitor(visitor); std::string expected{std::string("") + "$ Field 1 : arrayasrvecfield (ROOT::VecOps::RVec) $\n" + - "$ Field 1.1 : myfloat (float) $\n"}; + "$ Field 1.1 : _0 (float) $\n"}; EXPECT_EQ(expected, os.str()); } diff --git a/tree/ntuple/test/ntuple_type_name.cxx b/tree/ntuple/test/ntuple_type_name.cxx index b1b92aa3b695b..30172d03b7788 100644 --- a/tree/ntuple/test/ntuple_type_name.cxx +++ b/tree/ntuple/test/ntuple_type_name.cxx @@ -501,7 +501,7 @@ TEST(RNTuple, PropagateTypeAlias) { std::vector> items; items.emplace_back(GetDouble32Item()); - items.emplace_back(std::make_unique>("f")); + items.emplace_back(std::make_unique>("_1")); auto f = std::make_unique("f", std::move(items)); EXPECT_EQ("std::variant", f->GetTypeName()); EXPECT_EQ("std::variant", f->GetTypeAlias()); @@ -510,7 +510,7 @@ TEST(RNTuple, PropagateTypeAlias) { std::array, 2> items; items[0] = GetDouble32Item(); - items[1] = std::make_unique>("f"); + items[1] = std::make_unique>("_1"); auto f = std::make_unique("f", std::move(items)); EXPECT_EQ("std::pair", f->GetTypeName()); EXPECT_EQ("std::pair", f->GetTypeAlias()); @@ -519,14 +519,14 @@ TEST(RNTuple, PropagateTypeAlias) { std::vector> items; items.emplace_back(GetDouble32Item()); - items.emplace_back(std::make_unique>("f")); + items.emplace_back(std::make_unique>("_1")); auto f = std::make_unique("f", std::move(items)); EXPECT_EQ("std::tuple", f->GetTypeName()); EXPECT_EQ("std::tuple", f->GetTypeAlias()); } { - auto f = std::make_unique("f", GetDouble32Item()); + auto f = std::make_unique("_0", GetDouble32Item()); EXPECT_EQ("std::optional", f->GetTypeName()); EXPECT_EQ("std::optional", f->GetTypeAlias()); } @@ -534,9 +534,9 @@ TEST(RNTuple, PropagateTypeAlias) { std::array, 2> items; items[0] = GetDouble32Item(); - items[1] = std::make_unique>("f"); + items[1] = std::make_unique>("_1"); auto f = std::make_unique("f", ROOT::RMapField::EMapType::kMultiMap, - std::make_unique("f", std::move(items))); + std::make_unique("_0", std::move(items))); EXPECT_EQ("std::multimap", f->GetTypeName()); EXPECT_EQ("std::multimap", f->GetTypeAlias()); } diff --git a/tree/ntuple/test/rfield_vector.cxx b/tree/ntuple/test/rfield_vector.cxx index 4374a25030d69..7e5109cff631d 100644 --- a/tree/ntuple/test/rfield_vector.cxx +++ b/tree/ntuple/test/rfield_vector.cxx @@ -123,7 +123,7 @@ TEST(RNTuple, InsideCollection) ASSERT_NE(idKlass, ROOT::kInvalidDescriptorId); auto idA = source->GetSharedDescriptorGuard()->FindFieldId("a", idKlass); ASSERT_NE(idA, ROOT::kInvalidDescriptorId); - auto fieldInner = std::unique_ptr(RFieldBase::Create("klassVec_a", "float").Unwrap()); + auto fieldInner = std::unique_ptr(RFieldBase::Create("_0", "float").Unwrap()); fieldInner->SetOnDiskId(idA); auto field = std::make_unique("klassVec", std::move(fieldInner));