From 25c14f2f02206a0876d39b2e13dd78d3a56a2caf Mon Sep 17 00:00:00 2001 From: Florine de Geus Date: Fri, 16 Oct 2026 19:17:41 +0200 Subject: [PATCH 1/6] [ntuple] Move internal RNTupleProcessor classes out of Experimental * RNTupleProcessorProvenance * RNTupleProcessorEntry --- .../dataframe/inc/ROOT/RNTupleProcessorDS.hxx | 2 +- tree/dataframe/src/RNTupleProcessorDS.cxx | 12 +- tree/ntuple/inc/ROOT/RNTupleProcessor.hxx | 149 ++++++++++-------- .../ntuple/inc/ROOT/RNTupleProcessorEntry.hxx | 8 +- tree/ntuple/src/RNTupleProcessor.cxx | 71 ++++----- tree/ntuple/src/RNTupleProcessorEntry.cxx | 31 ++-- tree/ntuple/test/ntuple_processor.cxx | 8 +- tree/ntuple/test/ntuple_processor_chain.cxx | 10 +- tree/ntuple/test/ntuple_processor_join.cxx | 4 +- 9 files changed, 149 insertions(+), 146 deletions(-) diff --git a/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx b/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx index 1ca79627a3058..21fbdf264a5b0 100644 --- a/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx +++ b/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx @@ -92,7 +92,7 @@ class RNTupleProcessorDS final : public ROOT::RDF::RDataSource { /// be added as `ROOT::VecOps::RVec` (e.g., `std::set will be added as a `std::set`, but `Jet.[pt|eta] will be /// added as `ROOT::VecOps::RVec). void AddField(const ROOT::RFieldBase &field, std::string_view colName, - Internal::RNTupleProcessorProvenance procProvenance, std::deque &fieldInfos, + ROOT::Internal::RNTupleProcessorProvenance procProvenance, std::deque &fieldInfos, bool convertToRVec = true); public: diff --git a/tree/dataframe/src/RNTupleProcessorDS.cxx b/tree/dataframe/src/RNTupleProcessorDS.cxx index 04bd48828659a..ada246247352e 100644 --- a/tree/dataframe/src/RNTupleProcessorDS.cxx +++ b/tree/dataframe/src/RNTupleProcessorDS.cxx @@ -49,7 +49,7 @@ RNTupleProcessorDS::~RNTupleProcessorDS() = default; // TODO: see if common parts of this and RNTupleDS::AddField can be factored out. void RNTupleProcessorDS::AddField(const ROOT::RFieldBase &field, std::string_view colName, - Internal::RNTupleProcessorProvenance procProvenance, + ROOT::Internal::RNTupleProcessorProvenance procProvenance, std::deque &fieldInfos, bool convertToRVec) { // As an example for the mapping of RNTuple fields to RDF columns, let's consider an RNTuple @@ -208,7 +208,7 @@ void RNTupleProcessorDS::AddField(const ROOT::RFieldBase &field, std::string_vie fColumnNames.emplace_back(cardinalityFieldName); fColumnTypes.emplace_back(cardinalityField->GetTypeName()); fProcessor->AddFieldToEntry(std::move(cardinalityField), cardinalityFieldName, nullptr, - Internal::RNTupleProcessorProvenance()); + ROOT::Internal::RNTupleProcessorProvenance()); } fieldInfos.emplace_back(field.GetOnDiskId(), field.GetFieldName(), field.GetTypeName(), nRepetitions); @@ -220,7 +220,7 @@ void RNTupleProcessorDS::AddField(const ROOT::RFieldBase &field, std::string_vie // Add nested fields explicitly to the entry, because they may be mapped differently. if (fieldInfos.size() > 1) { fProcessor->AddFieldToEntry(std::move(valueField), canonicalName, nullptr, - Internal::RNTupleProcessorProvenance()); + ROOT::Internal::RNTupleProcessorProvenance()); } for (std::uint16_t i = 0; i < nFieldInfosAdded; i++) { @@ -232,7 +232,7 @@ RNTupleProcessorDS::RNTupleProcessorDS(std::unique_ptrAddAllFieldsToEntry(Internal::RNTupleProcessorProvenance(), /*includeSubfields=*/false); + fProcessor->AddAllFieldsToEntry(ROOT::Internal::RNTupleProcessorProvenance(), /*includeSubfields=*/false); const auto &entry = fProcessor->GetEntry(); for (auto fieldIdx : entry.GetFieldIndices()) { const auto &field = entry.GetValue(fieldIdx).GetField(); @@ -321,7 +321,7 @@ RNTupleProcessorDS::GetColumnReaders(unsigned int /* slot */, std::string_view n newField->SetOnDiskId(field.GetOnDiskId()); try { - fProcessor->AddFieldToEntry(std::move(newField), strName, nullptr, Internal::RNTupleProcessorProvenance()); + fProcessor->AddFieldToEntry(std::move(newField), strName, nullptr, ROOT::Internal::RNTupleProcessorProvenance()); } catch (const ROOT::RException &) { std::string msg = "RNTupleProcessorDS: invalid type \"" + requestedType + "\" for column \"" + strName + "\" with on-disk type \"" + field.GetTypeName() + "\""; @@ -375,7 +375,7 @@ bool RNTupleProcessorDS::HasColumn(std::string_view colName) const void RNTupleProcessorDS::Initialize() { fCurrentRanges.clear(); - fProcessor->Connect(fProcessor->GetEntry().GetFieldIndices(), Internal::RNTupleProcessorProvenance(), + fProcessor->Connect(fProcessor->GetEntry().GetFieldIndices(), ROOT::Internal::RNTupleProcessorProvenance(), /*updateFields=*/false); } diff --git a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx index d3fbaae230475..6f44e50ed41ad 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx @@ -34,16 +34,20 @@ namespace Experimental { class RNTupleProcessor; namespace Internal { -struct RNTupleProcessorEntryLoader; // for unit tests -const RNTupleProcessorEntry * -LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields); // for unit tests - namespace RDF { class RNTupleProcessorColumnReader; class RNTupleProcessorDS; } // namespace RDF } // namespace Internal +} // namespace Experimental + +namespace Internal { +struct RNTupleProcessorEntryLoader; // for unit tests +const RNTupleProcessorEntry * +LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields); // for unit tests +} // namespace Internal +namespace Experimental { // clang-format off /** \class ROOT::Experimental::RNTupleOpenSpec @@ -97,11 +101,11 @@ class RNTupleProcessorOptionalPtr { friend class RNTupleProcessor; private: - Internal::RNTupleProcessorEntry *fProcessorEntry; - Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; + ROOT::Internal::RNTupleProcessorEntry *fProcessorEntry; + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; - RNTupleProcessorOptionalPtr(Internal::RNTupleProcessorEntry *processorEntry, - Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) + RNTupleProcessorOptionalPtr(ROOT::Internal::RNTupleProcessorEntry *processorEntry, + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) : fProcessorEntry(processorEntry), fFieldIndex(fieldIdx) { } @@ -199,11 +203,11 @@ class RNTupleProcessorOptionalPtr { friend class RNTupleProcessor; private: - Internal::RNTupleProcessorEntry *fProcessorEntry; - Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; + ROOT::Internal::RNTupleProcessorEntry *fProcessorEntry; + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; - RNTupleProcessorOptionalPtr(Internal::RNTupleProcessorEntry *processorEntry, - Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) + RNTupleProcessorOptionalPtr(ROOT::Internal::RNTupleProcessorEntry *processorEntry, + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) : fProcessorEntry(processorEntry), fFieldIndex(fieldIdx) { } @@ -277,7 +281,7 @@ public: /// /// \return A pointer to the newly created RNTupleProcessor. // TODO(fdegeus) Move back to RNTupleProcessor::CreateJoin once RNTupleProcessor moves out of Experimental. -std::unique_ptr +std::unique_ptr CreateRNTupleJoinProcessor(RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTuple, const std::vector &joinFields, const RNTupleProcessorOptions &opts = RNTupleProcessorOptions()); @@ -296,9 +300,10 @@ CreateRNTupleJoinProcessor(RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTu /// /// \return A pointer to the newly created RNTupleProcessor. // TODO(fdegeus) Move back to RNTupleProcessor::CreateJoin once RNTupleProcessor moves out of Experimental. -std::unique_ptr -CreateRNTupleJoinProcessor(std::unique_ptr primaryProcessor, - std::unique_ptr auxProcessor, const std::vector &joinFields, +std::unique_ptr +CreateRNTupleJoinProcessor(std::unique_ptr primaryProcessor, + std::unique_ptr auxProcessor, + const std::vector &joinFields, const RNTupleProcessorOptions &opts = RNTupleProcessorOptions()); // clang-format off @@ -339,10 +344,10 @@ that is returned by RequestField(). */ // clang-format on class RNTupleProcessor { - friend struct ROOT::Experimental::Internal::RNTupleProcessorEntryLoader; // for unit tests - friend const Internal::RNTupleProcessorEntry * - ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(RNTupleProcessor &processor, - bool includeSubfields); // For unit tests + friend struct ROOT::Internal::RNTupleProcessorEntryLoader; // for unit tests + friend const ROOT::Internal::RNTupleProcessorEntry * + ROOT::Internal::LoadFullRNTupleProcessorEntry(RNTupleProcessor &processor, + bool includeSubfields); // For unit tests friend class RNTupleSingleProcessor; friend class RNTupleChainProcessor; friend class RNTupleJoinProcessor; @@ -432,8 +437,8 @@ protected: RNTupleProcessorOptions fOptions; - std::shared_ptr fEntry = nullptr; - std::unordered_set fFieldIdxs; + std::shared_ptr fEntry = nullptr; + std::unordered_set fFieldIdxs; /// Total number of entries. Only to be used internally by the processor, not meant to be exposed in the public /// interface. @@ -443,7 +448,7 @@ protected: ///////////////////////////////////////////////////////////////////////////// /// \brief Initialize the processor by creating an (initially empty) `fEntry`, or setting an existing one. - virtual void Initialize(std::shared_ptr entry) = 0; + virtual void Initialize(std::shared_ptr entry) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Check if the processor already has been initialized. @@ -456,8 +461,8 @@ protected: /// \param[in] provenance Provenance of the processor. /// \param[in] updateFields Whether the fields in the entry need to be updated, because the current underlying /// RNTuple source changed. - virtual void Connect(const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance &provenance, bool updateFields) = 0; + virtual void Connect(const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool updateFields) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Disconnect the processor from associated physical storage. @@ -484,11 +489,11 @@ protected: ///////////////////////////////////////////////////////////////////////////// /// \brief Get a reference to the processor's internal entry. - Internal::RNTupleProcessorEntry &GetEntry() { return *fEntry; } + ROOT::Internal::RNTupleProcessorEntry &GetEntry() { return *fEntry; } ///////////////////////////////////////////////////////////////////////////// /// \brief Get a reference to the processor's internal entry. - const Internal::RNTupleProcessorEntry &GetEntry() const { return *fEntry; } + const ROOT::Internal::RNTupleProcessorEntry &GetEntry() const { return *fEntry; } ///////////////////////////////////////////////////////////////////////////// /// \brief Get the total number of entries in this processor @@ -514,9 +519,9 @@ protected: /// \return The index of the newly added field in the entry. /// /// In case the field was already present in the entry, the index of the existing field is returned. - virtual Internal::RNTupleProcessorEntry::FieldIndex_t + virtual ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(const std::string &canonicalFieldName, const std::string &typeName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) = 0; + const ROOT::Internal::RNTupleProcessorProvenance &provenance) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. @@ -533,16 +538,17 @@ protected: /// \return The index of the newly added field in the entry. /// /// In case the field was already present in the entry, the index of the existing field is returned. - virtual Internal::RNTupleProcessorEntry::FieldIndex_t + virtual ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &canonicalFieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) = 0; + const ROOT::Internal::RNTupleProcessorProvenance &provenance) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \param[in] provenance Provenance of the processor. /// \param[in] addFieldMode Bitfield indicating how the fields should be added. - virtual void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) = 0; + virtual void + AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. @@ -620,7 +626,7 @@ public: return RNTupleProcessorOptionalPtr(fEntry.get(), *fieldIdx); } - auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, Internal::RNTupleProcessorProvenance()); + auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, ROOT::Internal::RNTupleProcessorProvenance()); return RNTupleProcessorOptionalPtr(fEntry.get(), fieldIdx); } @@ -643,7 +649,7 @@ public: RequestField(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr) { Initialize(fEntry); - auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, Internal::RNTupleProcessorProvenance()); + auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, ROOT::Internal::RNTupleProcessorProvenance()); return RNTupleProcessorOptionalPtr(fEntry.get(), fieldIdx); } @@ -694,7 +700,7 @@ public: RIterator(RNTupleProcessor &processor, ROOT::NTupleSize_t firstEntryIdx) : fProcessor(processor) { if (fProcessor.fEntry && firstEntryIdx != ROOT::kInvalidNTupleIndex) { - fProcessor.Connect(fProcessor.fEntry->GetFieldIndices(), Internal::RNTupleProcessorProvenance(), + fProcessor.Connect(fProcessor.fEntry->GetFieldIndices(), ROOT::Internal::RNTupleProcessorProvenance(), /*updateFields=*/false); fProcessor.SetEntryMapping(firstEntryIdx, fEntryMapping); } @@ -802,13 +808,14 @@ private: /// \brief Initialize the processor by creating an (initially empty) `fEntry`, or setting an existing one. /// /// At this point, the page source for the underlying RNTuple of the processor will be created and opened. - void Initialize(std::shared_ptr entry = nullptr) final; + void Initialize(std::shared_ptr entry = nullptr) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Connect the provided fields indices in the entry to their on-disk fields. - void Connect(const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance(), - bool updateFields = false) final; + void + Connect(const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance &provenance = ROOT::Internal::RNTupleProcessorProvenance(), + bool updateFields = false) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Disconnect the processor from associated physical storage. @@ -845,23 +852,24 @@ private: /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry( - const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, - const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance()) final; + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, + const ROOT::Internal::RNTupleProcessorProvenance &provenance = + ROOT::Internal::RNTupleProcessorProvenance()) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - Internal::RNTupleProcessorEntry::FieldIndex_t + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) final; + const ROOT::Internal::RNTupleProcessorProvenance &provenance) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \sa RNTupleProcessor::AddAllFieldsToEntry() - void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; + void AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. @@ -912,19 +920,20 @@ private: ROOT::NTupleSize_t fLastLoadedEntry = 0; //< Last (global) entry number that was loaded std::size_t fCurrentProcessorNumber = 0; //< Number of the currently open inner processor - Internal::RNTupleProcessorProvenance fProvenance; + ROOT::Internal::RNTupleProcessorProvenance fProvenance; ///////////////////////////////////////////////////////////////////////////// /// \brief Initialize the processor by creating an (initially empty) `fEntry`, or setting an existing one. - void Initialize(std::shared_ptr entry = nullptr) final; + void Initialize(std::shared_ptr entry = nullptr) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Connect the provided fields indices in the entry to their on-disk fields. /// /// \sa RNTupleProcessor::Connect() - void Connect(const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance(), - bool updateFields = false) final; + void + Connect(const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance &provenance = ROOT::Internal::RNTupleProcessorProvenance(), + bool updateFields = false) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Update the entry to reflect any missing fields in the current inner processor. @@ -965,23 +974,24 @@ private: /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry( - const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, - const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance()) final; + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, + const ROOT::Internal::RNTupleProcessorProvenance &provenance = + ROOT::Internal::RNTupleProcessorProvenance()) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - Internal::RNTupleProcessorEntry::FieldIndex_t + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) final; + const ROOT::Internal::RNTupleProcessorProvenance &provenance) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \sa RNTupleProcessor::AddAllFieldsToEntry() - void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; + void AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. @@ -1032,23 +1042,24 @@ private: std::unique_ptr fAuxiliaryProcessor; std::vector fJoinFieldNames; - std::set fJoinFieldIdxs; + std::set fJoinFieldIdxs; std::unique_ptr fJoinTable; bool fJoinTableIsBuilt = false; - std::unordered_set fAuxiliaryFieldIdxs; + std::unordered_set fAuxiliaryFieldIdxs; /// \brief Initialize the processor by creating an (initially empty) `fEntry`, or setting an existing one. - void Initialize(std::shared_ptr entry = nullptr) final; + void Initialize(std::shared_ptr entry = nullptr) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Connect the provided fields indices in the entry to their on-disk fields. /// /// \sa RNTupleProcessor::Connect() - void Connect(const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance(), - bool updateFields = false) final; + void + Connect(const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance &provenance = ROOT::Internal::RNTupleProcessorProvenance(), + bool updateFields = false) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Disconnect the processor from associated physical storage. @@ -1093,23 +1104,24 @@ private: /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry( - const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, - const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance()) final; + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, + const ROOT::Internal::RNTupleProcessorProvenance &provenance = + ROOT::Internal::RNTupleProcessorProvenance()) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - Internal::RNTupleProcessorEntry::FieldIndex_t + ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) final; + const ROOT::Internal::RNTupleProcessorProvenance &provenance) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \sa RNTupleProcessor::AddAllFieldsToEntry() - void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; + void AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. @@ -1143,7 +1155,6 @@ public: RNTupleJoinProcessor operator=(RNTupleJoinProcessor &&) = delete; ~RNTupleJoinProcessor() override = default; }; - } // namespace Experimental } // namespace ROOT diff --git a/tree/ntuple/inc/ROOT/RNTupleProcessorEntry.hxx b/tree/ntuple/inc/ROOT/RNTupleProcessorEntry.hxx index 98e12e76a09d6..01f769f6c4b59 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessorEntry.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessorEntry.hxx @@ -1,8 +1,6 @@ /// \file ROOT/RNTupleProcessor.hxx /// \author Florine de Geus /// \date 2025-06-25 -/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -/// is welcome! /************************************************************************* * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. * @@ -24,10 +22,9 @@ #include namespace ROOT { -namespace Experimental { namespace Internal { /** -\class ROOT::Experimental::RNTupleProcessorProvenance +\class ROOT::RNTupleProcessorProvenance \ingroup NTuple \brief Identifies how a processor is composed. @@ -84,7 +81,7 @@ public: // clang-format off /** -\class ROOT::Experimental::Internal::RNTupleProcessorEntry +\class ROOT::Internal::RNTupleProcessorEntry \ingroup NTuple \brief Collection of values in an RNTupleProcessor, analogous to REntry, with checks and support for missing values. */ @@ -260,7 +257,6 @@ public: std::unordered_set GetFieldIndices() const; }; } // namespace Internal -} // namespace Experimental } // namespace ROOT #endif // ROOT_RNTupleProcessorEntry diff --git a/tree/ntuple/src/RNTupleProcessor.cxx b/tree/ntuple/src/RNTupleProcessor.cxx index 08d157a253bc6..720567a0996c6 100644 --- a/tree/ntuple/src/RNTupleProcessor.cxx +++ b/tree/ntuple/src/RNTupleProcessor.cxx @@ -23,8 +23,8 @@ #include -const ROOT::Experimental::Internal::RNTupleProcessorEntry * -ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(RNTupleProcessor &processor, bool includeSubfields) +const ROOT::Internal::RNTupleProcessorEntry * +ROOT::Internal::LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields) { processor.AddAllFieldsToEntry(RNTupleProcessorProvenance(), includeSubfields); return processor.fEntry.get(); @@ -125,14 +125,14 @@ ROOT::Experimental::RNTupleSingleProcessor::RNTupleSingleProcessor(RNTupleOpenSp } void ROOT::Experimental::RNTupleSingleProcessor::Initialize( - std::shared_ptr entry) + std::shared_ptr entry) { // The processor has already been initialized. if (IsInitialized() && fPageSource) return; if (!entry) - fEntry = std::make_shared(); + fEntry = std::make_shared(); else fEntry = std::move(entry); @@ -199,10 +199,9 @@ ROOT::Experimental::RNTupleSingleProcessor::ConnectField(std::unique_ptrFindFieldIndex(canonicalFieldName, typeName); if (!fieldIdx) { @@ -226,10 +225,9 @@ ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(const std::string &c return *fieldIdx; } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t -ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(std::unique_ptr field, - const std::string &canonicalFieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry( + std::unique_ptr field, const std::string &canonicalFieldName, void *valuePtr, + const ROOT::Internal::RNTupleProcessorProvenance &provenance) { auto fieldIdx = fEntry->FindFieldIndex(canonicalFieldName, field->GetTypeName()); if (!fieldIdx) { @@ -254,7 +252,7 @@ ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(std::unique_ptrGetSharedDescriptorGuard(); @@ -304,8 +302,8 @@ void ROOT::Experimental::RNTupleSingleProcessor::LoadEntryImpl(const REntryMappi } void ROOT::Experimental::RNTupleSingleProcessor::Connect( - const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields) + const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields) { Initialize(fEntry); @@ -374,14 +372,13 @@ ROOT::Experimental::RNTupleChainProcessor::RNTupleChainProcessor( fInnerNEntries.assign(fInnerProcessors.size(), kInvalidNTupleIndex); } -void ROOT::Experimental::RNTupleChainProcessor::Initialize( - std::shared_ptr entry) +void ROOT::Experimental::RNTupleChainProcessor::Initialize(std::shared_ptr entry) { if (IsInitialized()) return; if (!entry) - fEntry = std::make_shared(); + fEntry = std::make_shared(); else fEntry = std::move(entry); @@ -407,8 +404,8 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::GetNEntries() } void ROOT::Experimental::RNTupleChainProcessor::Connect( - const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */) + const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */) { Initialize(); fFieldIdxs = fieldIdxs; @@ -435,24 +432,24 @@ void ROOT::Experimental::RNTupleChainProcessor::ConnectInnerProcessor(std::size_ innerProc->Connect(fFieldIdxs, fProvenance, /*updateFields=*/true); } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) + const ROOT::Internal::RNTupleProcessorProvenance &provenance) { return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(fieldName, typeName, valuePtr, provenance); } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) + const ROOT::Internal::RNTupleProcessorProvenance &provenance) { return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(std::move(field), fieldName, valuePtr, provenance); } void ROOT::Experimental::RNTupleChainProcessor::AddAllFieldsToEntry( - const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) + const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) { Initialize(); fInnerProcessors[0]->AddAllFieldsToEntry(provenance, includeSubfields); @@ -557,14 +554,13 @@ ROOT::Experimental::RNTupleJoinProcessor::RNTupleJoinProcessor(std::unique_ptr entry) +void ROOT::Experimental::RNTupleJoinProcessor::Initialize(std::shared_ptr entry) { if (IsInitialized()) return; if (!entry) - fEntry = std::make_shared(); + fEntry = std::make_shared(); else fEntry = std::move(entry); @@ -584,8 +580,9 @@ void ROOT::Experimental::RNTupleJoinProcessor::Initialize( // We prepend the name of the primary processor in this case to prevent reading from the wrong join field in // composed join operations. - auto fieldIdx = AddFieldToEntry(fOptions.GetProcessorName() + ".R_rntproc_join_" + joinField, "std::uint64_t", - nullptr, Internal::RNTupleProcessorProvenance(fOptions.GetProcessorName())); + auto fieldIdx = + AddFieldToEntry(fOptions.GetProcessorName() + ".R_rntproc_join_" + joinField, "std::uint64_t", nullptr, + ROOT::Internal::RNTupleProcessorProvenance(fOptions.GetProcessorName())); fJoinFieldIdxs.insert(fieldIdx); } @@ -594,8 +591,8 @@ void ROOT::Experimental::RNTupleJoinProcessor::Initialize( } void ROOT::Experimental::RNTupleJoinProcessor::Connect( - const std::unordered_set &fieldIdxs, - const Internal::RNTupleProcessorProvenance &provenance, bool updateFields) + const std::unordered_set &fieldIdxs, + const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool updateFields) { Initialize(); @@ -618,10 +615,10 @@ void ROOT::Experimental::RNTupleJoinProcessor::Disconnect() fAuxiliaryProcessor->Disconnect(); } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) + const ROOT::Internal::RNTupleProcessorProvenance &provenance) { auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->fOptions.GetProcessorName()); if (auxProvenance.IsPresentInFieldName(fieldName)) { @@ -649,10 +646,10 @@ ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(const std::string &fie } } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) + const ROOT::Internal::RNTupleProcessorProvenance &provenance) { auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->GetOptions().GetProcessorName()); if (auxProvenance.IsPresentInFieldName(fieldName)) { @@ -680,7 +677,7 @@ ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(std::unique_ptrAddAllFieldsToEntry(provenance, includeSubfields); diff --git a/tree/ntuple/src/RNTupleProcessorEntry.cxx b/tree/ntuple/src/RNTupleProcessorEntry.cxx index 355e8cef185d9..0a510231a8dd4 100644 --- a/tree/ntuple/src/RNTupleProcessorEntry.cxx +++ b/tree/ntuple/src/RNTupleProcessorEntry.cxx @@ -15,7 +15,7 @@ #include -const std::string &ROOT::Experimental::Internal::RNTupleProcessorEntry::FindFieldName(FieldIndex_t fieldIdx) const +const std::string &ROOT::Internal::RNTupleProcessorEntry::FindFieldName(FieldIndex_t fieldIdx) const { assert(fieldIdx < fProcessorValues.size()); @@ -30,9 +30,9 @@ const std::string &ROOT::Experimental::Internal::RNTupleProcessorEntry::FindFiel return empty; } -std::optional -ROOT::Experimental::Internal::RNTupleProcessorEntry::FindFieldIndex(std::string_view canonicalFieldName, - std::string_view typeName) const +std::optional +ROOT::Internal::RNTupleProcessorEntry::FindFieldIndex(std::string_view canonicalFieldName, + std::string_view typeName) const { auto it = fFieldName2Index.find(std::string(canonicalFieldName)); if (it == fFieldName2Index.end()) { @@ -51,10 +51,10 @@ ROOT::Experimental::Internal::RNTupleProcessorEntry::FindFieldIndex(std::string_ return std::nullopt; } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t -ROOT::Experimental::Internal::RNTupleProcessorEntry::AddField(const std::string &qualifiedFieldName, - std::unique_ptr field, void *valuePtr, - const RNTupleProcessorProvenance &provenance) +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t +ROOT::Internal::RNTupleProcessorEntry::AddField(const std::string &qualifiedFieldName, + std::unique_ptr field, void *valuePtr, + const RNTupleProcessorProvenance &provenance) { auto fieldNameWithProcessorPrefix = qualifiedFieldName; if (const auto &processorPrefix = provenance.Get(); !processorPrefix.empty()) @@ -76,14 +76,13 @@ ROOT::Experimental::Internal::RNTupleProcessorEntry::AddField(const std::string return fieldIdx; } -const ROOT::RFieldBase &ROOT::Experimental::Internal::RNTupleProcessorEntry::GetField(FieldIndex_t fieldIdx) const +const ROOT::RFieldBase &ROOT::Internal::RNTupleProcessorEntry::GetField(FieldIndex_t fieldIdx) const { assert(fieldIdx < fProcessorValues.size()); return *fProcessorValues[fieldIdx].fField; } -void ROOT::Experimental::Internal::RNTupleProcessorEntry::UpdateField(FieldIndex_t fieldIdx, - std::unique_ptr field) +void ROOT::Internal::RNTupleProcessorEntry::UpdateField(FieldIndex_t fieldIdx, std::unique_ptr field) { assert(fieldIdx < fProcessorValues.size()); @@ -101,19 +100,19 @@ void ROOT::Experimental::Internal::RNTupleProcessorEntry::UpdateField(FieldIndex } } -void ROOT::Experimental::Internal::RNTupleProcessorEntry::BindRawPtr(FieldIndex_t fieldIdx, void *valuePtr) +void ROOT::Internal::RNTupleProcessorEntry::BindRawPtr(FieldIndex_t fieldIdx, void *valuePtr) { assert(fieldIdx < fProcessorValues.size()); fProcessorValues[fieldIdx].fValue.BindRawPtr(valuePtr); } -void ROOT::Experimental::Internal::RNTupleProcessorEntry::Bind(FieldIndex_t fieldIdx, std::shared_ptr valuePtr) +void ROOT::Internal::RNTupleProcessorEntry::Bind(FieldIndex_t fieldIdx, std::shared_ptr valuePtr) { assert(fieldIdx < fProcessorValues.size()); fProcessorValues[fieldIdx].fValue.Bind(std::move(valuePtr)); } -void ROOT::Experimental::Internal::RNTupleProcessorEntry::ReadValue(FieldIndex_t fieldIdx, ROOT::NTupleSize_t entryIdx) +void ROOT::Internal::RNTupleProcessorEntry::ReadValue(FieldIndex_t fieldIdx, ROOT::NTupleSize_t entryIdx) { assert(fieldIdx < fProcessorValues.size()); @@ -122,8 +121,8 @@ void ROOT::Experimental::Internal::RNTupleProcessorEntry::ReadValue(FieldIndex_t } } -std::unordered_set -ROOT::Experimental::Internal::RNTupleProcessorEntry::GetFieldIndices() const +std::unordered_set +ROOT::Internal::RNTupleProcessorEntry::GetFieldIndices() const { // Field indices are sequentially assigned, and the entry (currently) offers no way to remove fields, so we can just // generate and return a set {0, ..., |fProcessorValues| - 1}. diff --git a/tree/ntuple/test/ntuple_processor.cxx b/tree/ntuple/test/ntuple_processor.cxx index 55c7e0853d810..98c41161989f8 100644 --- a/tree/ntuple/test/ntuple_processor.cxx +++ b/tree/ntuple/test/ntuple_processor.cxx @@ -387,7 +387,7 @@ TEST_F(RNTupleProcessorTest, Subfields) TEST_F(RNTupleProcessorTest, AddAllFields) { auto proc = RNTupleProcessor::Create({fNTupleNames[0], fFileNames[0]}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); auto fieldIdxs = entry->GetFieldIndices(); EXPECT_EQ(fieldIdxs.size(), 4); @@ -396,7 +396,7 @@ TEST_F(RNTupleProcessorTest, AddAllFields) TEST_F(RNTupleProcessorTest, AddAllFieldsAndSubfields) { auto proc = RNTupleProcessor::Create({fNTupleNames[0], fFileNames[0]}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); auto fieldIdxs = entry->GetFieldIndices(); EXPECT_EQ(fieldIdxs.size(), 13); @@ -918,7 +918,7 @@ TEST_F(RNTupleProcessorTest, AddAllFieldsComposed) auto proc = CreateRNTupleJoinProcessor(std::move(primaryProc), std::move(auxProc), {}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); auto fieldIdxs = entry->GetFieldIndices(); // 11 fields instead of 10, because the join field is also included. @@ -939,7 +939,7 @@ TEST_F(RNTupleProcessorTest, AddAllFieldsAndSubfieldsComposed) auto proc = CreateRNTupleJoinProcessor(std::move(primaryProc), std::move(auxProc), {}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); auto fieldIdxs = entry->GetFieldIndices(); // 36 fields instead of 25, because the join field is also included. diff --git a/tree/ntuple/test/ntuple_processor_chain.cxx b/tree/ntuple/test/ntuple_processor_chain.cxx index 8219816457359..0f672c192048e 100644 --- a/tree/ntuple/test/ntuple_processor_chain.cxx +++ b/tree/ntuple/test/ntuple_processor_chain.cxx @@ -148,7 +148,7 @@ TEST_F(RNTupleChainProcessorTest, AddAllFields) { auto proc = RNTupleProcessor::CreateChain( {{fNTupleName, fFileNames[0]}, {fNTupleName, fFileNames[2]}, {fNTupleName, fFileNames[1]}}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); auto fieldIdxs = entry->GetFieldIndices(); EXPECT_EQ(fieldIdxs.size(), 2); @@ -158,7 +158,7 @@ TEST_F(RNTupleChainProcessorTest, AddAllFieldsAndSubfields) { auto proc = RNTupleProcessor::CreateChain( {{fNTupleName, fFileNames[0]}, {fNTupleName, fFileNames[2]}, {fNTupleName, fFileNames[1]}}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); auto fieldIdxs = entry->GetFieldIndices(); EXPECT_EQ(fieldIdxs.size(), 3); @@ -191,7 +191,7 @@ TEST_F(RNTupleChainProcessorTest, EmptyNTuples) EXPECT_EQ(10, proc->GetNEntriesProcessed()); } -namespace ROOT::Experimental::Internal { +namespace ROOT::Internal { struct RNTupleProcessorEntryLoader { static ROOT::RResult LoadEntry(RNTupleProcessor &processor, ROOT::NTupleSize_t entryNumber) { @@ -204,11 +204,11 @@ struct RNTupleProcessorEntryLoader { return RResult::Success(); } }; -} // namespace ROOT::Experimental::Internal +} // namespace ROOT::Internal TEST_F(RNTupleChainProcessorTest, LoadRandomEntry) { - using ROOT::Experimental::Internal::RNTupleProcessorEntryLoader; + using ROOT::Internal::RNTupleProcessorEntryLoader; auto proc = RNTupleProcessor::CreateChain({{fNTupleName, fFileNames[0]}, {fNTupleName, fFileNames[1]}}); diff --git a/tree/ntuple/test/ntuple_processor_join.cxx b/tree/ntuple/test/ntuple_processor_join.cxx index 7e7de819f79b9..b65ea920519b3 100644 --- a/tree/ntuple/test/ntuple_processor_join.cxx +++ b/tree/ntuple/test/ntuple_processor_join.cxx @@ -170,7 +170,7 @@ TEST(RNTupleJoinProcessor, NameConflict) TEST_F(RNTupleJoinProcessorTest, AddAllFields) { auto proc = CreateRNTupleJoinProcessor({fNTupleNames[1], fFileNames[1]}, {fNTupleNames[2], fFileNames[2]}, {}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/false); auto fieldIdxs = entry->GetFieldIndices(); EXPECT_EQ(fieldIdxs.size(), 5); @@ -179,7 +179,7 @@ TEST_F(RNTupleJoinProcessorTest, AddAllFields) TEST_F(RNTupleJoinProcessorTest, AddAllFieldsAndSubfields) { auto proc = CreateRNTupleJoinProcessor({fNTupleNames[1], fFileNames[1]}, {fNTupleNames[2], fFileNames[2]}, {}); - auto entry = ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); + auto entry = ROOT::Internal::LoadFullRNTupleProcessorEntry(*proc, /*includeSubfields=*/true); auto fieldIdxs = entry->GetFieldIndices(); EXPECT_EQ(fieldIdxs.size(), 6); From 32af19b346375a5f4ab92f70d197b8531b05ae1d Mon Sep 17 00:00:00 2001 From: Florine de Geus Date: Fri, 16 Oct 2026 21:47:51 +0200 Subject: [PATCH 2/6] [ntuple] Move RNTupleOpenSpec out of Experimental --- .../test/datasource_ntuple_processor.cxx | 2 +- tree/ntuple/inc/ROOT/RNTupleProcessor.hxx | 15 +++++++-------- tree/ntuple/src/RNTupleProcessor.cxx | 2 +- tree/ntuple/test/ntuple_test.hxx | 2 +- tutorials/io/ntuple/ntpl012_processor_chain.C | 5 ++--- tutorials/io/ntuple/ntpl015_processor_join.C | 1 - 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tree/dataframe/test/datasource_ntuple_processor.cxx b/tree/dataframe/test/datasource_ntuple_processor.cxx index 760178085384f..01ae76979b57d 100644 --- a/tree/dataframe/test/datasource_ntuple_processor.cxx +++ b/tree/dataframe/test/datasource_ntuple_processor.cxx @@ -233,7 +233,7 @@ static void ChainTest(const std::string &name, const std::string &fname) // Causes "Too many open files" errors on Windows // TODO(fdegeus) Investigate root cause + fix #if !defined(_MSC_VER) || defined(R__ENABLE_BROKEN_WIN_TESTS) - std::vector openSpecs(1000, {name, fname}); + std::vector openSpecs(1000, {name, fname}); auto proc1000 = RNTupleProcessor::CreateChain(openSpecs); auto df1000 = ROOT::Experimental::RDF::FromRNTupleProcessor(std::move(proc1000)); EXPECT_DOUBLE_EQ(42000.0, df1000.Sum("pt").GetValue()); diff --git a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx index 6f44e50ed41ad..f3afa3e8d6c54 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx @@ -32,6 +32,7 @@ namespace ROOT { namespace Experimental { class RNTupleProcessor; +class RNTupleSingleProcessor; namespace Internal { namespace RDF { @@ -47,10 +48,9 @@ const RNTupleProcessorEntry * LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields); // for unit tests } // namespace Internal -namespace Experimental { // clang-format off /** -\class ROOT::Experimental::RNTupleOpenSpec +\class ROOT::RNTupleOpenSpec \ingroup NTuple \brief Specification of the name and location of an RNTuple, used for creating a new RNTupleProcessor. @@ -61,9 +61,8 @@ Note that the RNTupleOpenSpec is *write-only*, to prevent usability issues with */ // clang-format on class RNTupleOpenSpec { - friend class RNTupleProcessor; - friend class RNTupleSingleProcessor; - friend class RNTupleJoinProcessor; + friend class Experimental::RNTupleProcessor; + friend class Experimental::RNTupleSingleProcessor; private: std::string fNTupleName; @@ -73,9 +72,10 @@ public: RNTupleOpenSpec(std::string_view n, TDirectory *s) : fNTupleName(n), fStorage(s) {} RNTupleOpenSpec(std::string_view n, const std::string &s) : fNTupleName(n), fStorage(s) {} - std::unique_ptr CreatePageSource() const; + std::unique_ptr CreatePageSource() const; }; +namespace Experimental { class RNTupleProcessorOptions { private: /// By default, the processor name is the name of the underlying RNTuple for RNTupleSingleProcessor, the name of the @@ -317,9 +317,8 @@ Example usage (see ntpl012_processor_chain.C and ntpl015_processor_join.C for bi ~~~{.cpp} #include using ROOT::Experimental::RNTupleProcessor; -using ROOT::Experimental::RNTupleOpenSpec; -std::vector ntuples = {{"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}}; +std::vector ntuples = {{"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}}; auto processor = RNTupleProcessor::CreateChain(ntuples); auto pt = processor->RequestField("pt"); diff --git a/tree/ntuple/src/RNTupleProcessor.cxx b/tree/ntuple/src/RNTupleProcessor.cxx index 720567a0996c6..b9c90b088c408 100644 --- a/tree/ntuple/src/RNTupleProcessor.cxx +++ b/tree/ntuple/src/RNTupleProcessor.cxx @@ -32,7 +32,7 @@ ROOT::Internal::LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcess //------------------------------------------------------------------------------ -std::unique_ptr ROOT::Experimental::RNTupleOpenSpec::CreatePageSource() const +std::unique_ptr ROOT::RNTupleOpenSpec::CreatePageSource() const { if (const std::string *storagePath = std::get_if(&fStorage)) return ROOT::Internal::RPageSource::Create(fNTupleName, *storagePath); diff --git a/tree/ntuple/test/ntuple_test.hxx b/tree/ntuple/test/ntuple_test.hxx index 1a12aa84bdd0a..8b22e50131d54 100644 --- a/tree/ntuple/test/ntuple_test.hxx +++ b/tree/ntuple/test/ntuple_test.hxx @@ -94,7 +94,7 @@ using RNTupleMerger = ROOT::Experimental::Internal::RNTupleMerger; using RNTupleMergeOptions = ROOT::Experimental::Internal::RNTupleMergeOptions; using ENTupleMergingMode = ROOT::Experimental::Internal::ENTupleMergingMode; using RNTupleModel = ROOT::RNTupleModel; -using RNTupleOpenSpec = ROOT::Experimental::RNTupleOpenSpec; +using RNTupleOpenSpec = ROOT::RNTupleOpenSpec; using RNTuplePlainCounter = ROOT::Experimental::Detail::RNTuplePlainCounter; using RNTuplePlainTimer = ROOT::Experimental::Detail::RNTuplePlainTimer; using RNTupleProcessor = ROOT::Experimental::RNTupleProcessor; diff --git a/tutorials/io/ntuple/ntpl012_processor_chain.C b/tutorials/io/ntuple/ntpl012_processor_chain.C index f9eee0812f35c..a38c7e16a8657 100644 --- a/tutorials/io/ntuple/ntpl012_processor_chain.C +++ b/tutorials/io/ntuple/ntpl012_processor_chain.C @@ -21,7 +21,6 @@ #include // Import classes from the `Experimental` namespace for the time being. -using ROOT::Experimental::RNTupleOpenSpec; using ROOT::Experimental::RNTupleProcessor; // Number of events to generate for each ntuple. @@ -58,7 +57,7 @@ void Write(std::string_view ntupleName, std::string_view fileName) } } -void Read(const std::vector &ntuples) +void Read(const std::vector &ntuples) { auto c = new TCanvas("c", "RNTupleProcessor Example", 200, 10, 700, 500); TH1F hPx("h", "This is the px distribution", 100, -4, 4); @@ -96,7 +95,7 @@ void ntpl012_processor_chain() // The ntuples to generate and subsequently process. The model of the first ntuple will be used to construct the // entry used by the processor. - std::vector ntuples = { + std::vector ntuples = { {"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}, {"ntuple3", "ntuple3.root"}}; Read(ntuples); diff --git a/tutorials/io/ntuple/ntpl015_processor_join.C b/tutorials/io/ntuple/ntpl015_processor_join.C index 7164aa25b7a6a..070b6590f733e 100644 --- a/tutorials/io/ntuple/ntpl015_processor_join.C +++ b/tutorials/io/ntuple/ntpl015_processor_join.C @@ -22,7 +22,6 @@ // Import classes from the `Experimental` namespace for the time being. using ROOT::Experimental::CreateRNTupleJoinProcessor; -using ROOT::Experimental::RNTupleOpenSpec; const std::string kPrimaryNTupleName = "mainNTuple"; const std::string kMainNTuplePath = "main_ntuple.root"; From e426468f7a0ce08e801ae2af98aa4edec3539e8d Mon Sep 17 00:00:00 2001 From: Florine de Geus Date: Fri, 16 Oct 2026 21:58:01 +0200 Subject: [PATCH 3/6] [ntuple] Move RNTupleProcessorOptions out of Experimental --- tree/ntuple/inc/ROOT/RNTupleProcessor.hxx | 18 +++++++++++++++++- tree/ntuple/test/ntuple_test.hxx | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx index f3afa3e8d6c54..b49c2d1173a84 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx @@ -75,7 +75,13 @@ public: std::unique_ptr CreatePageSource() const; }; -namespace Experimental { +// clang-format off +/** +\class ROOT::RNTupleProcessorOptions +\ingroup NTuple +\brief Options to pass to an RNTupleProcessor upon creation +*/ +// clang-format on class RNTupleProcessorOptions { private: /// By default, the processor name is the name of the underlying RNTuple for RNTupleSingleProcessor, the name of the @@ -83,11 +89,21 @@ private: std::string fProcessorName = ""; public: + ///////////////////////////////////////////////////////////////////////////// + /// \brief Get the processor's name. const std::string &GetProcessorName() const { return fProcessorName; } + ///////////////////////////////////////////////////////////////////////////// + /// \brief Set the processor's name. + /// + /// \param[in] name Name to assign to the processor. + /// + /// By default, the processor name is the name of the underlying RNTuple for RNTupleSingleProcessor, the name of the + /// first processor for RNTupleChainProcessor, or the name of the primary RNTuple for RNTupleJoinProcessor. void SetProcessorName(std::string_view name) { fProcessorName = name; } }; +namespace Experimental { // clang-format off /** \class ROOT::Experimental::RNTupleProcessorOptionalPtr diff --git a/tree/ntuple/test/ntuple_test.hxx b/tree/ntuple/test/ntuple_test.hxx index 8b22e50131d54..a76242d4e28a9 100644 --- a/tree/ntuple/test/ntuple_test.hxx +++ b/tree/ntuple/test/ntuple_test.hxx @@ -98,7 +98,7 @@ using RNTupleOpenSpec = ROOT::RNTupleOpenSpec; using RNTuplePlainCounter = ROOT::Experimental::Detail::RNTuplePlainCounter; using RNTuplePlainTimer = ROOT::Experimental::Detail::RNTuplePlainTimer; using RNTupleProcessor = ROOT::Experimental::RNTupleProcessor; -using RNTupleProcessorOptions = ROOT::Experimental::RNTupleProcessorOptions; +using RNTupleProcessorOptions = ROOT::RNTupleProcessorOptions; using RNTupleSerializer = ROOT::Internal::RNTupleSerializer; using RPage = ROOT::Internal::RPage; using RPageAllocatorHeap = ROOT::Internal::RPageAllocatorHeap; From 78c20e51073f55329fbd7ba6cd9de2a0344fd341 Mon Sep 17 00:00:00 2001 From: Florine de Geus Date: Fri, 16 Oct 2026 22:54:01 +0200 Subject: [PATCH 4/6] [ntuple] Move RNTupleProcessorOptionalPtr out of Experimental --- tree/ntuple/inc/ROOT/RNTupleProcessor.hxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx index b49c2d1173a84..f47979387927b 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx @@ -103,10 +103,9 @@ public: void SetProcessorName(std::string_view name) { fProcessorName = name; } }; -namespace Experimental { // clang-format off /** -\class ROOT::Experimental::RNTupleProcessorOptionalPtr +\class ROOT::RNTupleProcessorOptionalPtr \ingroup NTuple \brief The RNTupleProcessorOptionalPtr provides access to values from fields present in an RNTupleProcessor, with support and checks for missing values. @@ -117,11 +116,11 @@ class RNTupleProcessorOptionalPtr { friend class RNTupleProcessor; private: - ROOT::Internal::RNTupleProcessorEntry *fProcessorEntry; - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; + Internal::RNTupleProcessorEntry *fProcessorEntry; + Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; - RNTupleProcessorOptionalPtr(ROOT::Internal::RNTupleProcessorEntry *processorEntry, - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) + RNTupleProcessorOptionalPtr(Internal::RNTupleProcessorEntry *processorEntry, + Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) : fProcessorEntry(processorEntry), fFieldIndex(fieldIdx) { } @@ -209,7 +208,7 @@ public: // clang-format off /** -\class ROOT::Experimental::RNTupleProcessorOptionalPtr +\class ROOT::RNTupleProcessorOptionalPtr \ingroup NTuple \brief Specialization of RNTupleProcessorOptionalPtr for `void`-type pointers. */ @@ -219,11 +218,11 @@ class RNTupleProcessorOptionalPtr { friend class RNTupleProcessor; private: - ROOT::Internal::RNTupleProcessorEntry *fProcessorEntry; - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; + Internal::RNTupleProcessorEntry *fProcessorEntry; + Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex; - RNTupleProcessorOptionalPtr(ROOT::Internal::RNTupleProcessorEntry *processorEntry, - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) + RNTupleProcessorOptionalPtr(Internal::RNTupleProcessorEntry *processorEntry, + Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx) : fProcessorEntry(processorEntry), fFieldIndex(fieldIdx) { } From 6c72aa9aa74de410ed0f98ce492baaf4bf5af3e7 Mon Sep 17 00:00:00 2001 From: Florine de Geus Date: Fri, 16 Oct 2026 22:54:35 +0200 Subject: [PATCH 5/6] [ntuple] Move RNTuple(Single,Chain)Processor out of Experimental --- .../dataframe/inc/ROOT/RNTupleProcessorDS.hxx | 4 +- tree/dataframe/src/RNTupleProcessorDS.cxx | 5 +- .../test/datasource_ntuple_processor.cxx | 2 +- tree/ntuple/inc/ROOT/RNTupleProcessor.hxx | 204 +++++++++--------- tree/ntuple/src/RNTupleProcessor.cxx | 126 +++++------ tree/ntuple/test/ntuple_test.hxx | 2 +- tutorials/io/ntuple/ntpl012_processor_chain.C | 5 +- 7 files changed, 167 insertions(+), 181 deletions(-) diff --git a/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx b/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx index 21fbdf264a5b0..d294b7704ef23 100644 --- a/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx +++ b/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx @@ -96,7 +96,7 @@ class RNTupleProcessorDS final : public ROOT::RDF::RDataSource { bool convertToRVec = true); public: - RNTupleProcessorDS(std::unique_ptr processor); + RNTupleProcessorDS(std::unique_ptr processor); RNTupleProcessorDS(const RNTupleProcessorDS &) = delete; RNTupleProcessorDS &operator=(const RNTupleProcessorDS &) = delete; RNTupleProcessorDS(RNTupleProcessorDS &&) = delete; @@ -132,7 +132,7 @@ protected: } // namespace ROOT::Experimental::Internal::RDF namespace ROOT::Experimental::RDF { -RDataFrame FromRNTupleProcessor(std::unique_ptr processor); +RDataFrame FromRNTupleProcessor(std::unique_ptr processor); } // namespace ROOT::Experimental::RDF #endif // ROOT_RNTupleProcessorDS diff --git a/tree/dataframe/src/RNTupleProcessorDS.cxx b/tree/dataframe/src/RNTupleProcessorDS.cxx index ada246247352e..e899aa3a6d42b 100644 --- a/tree/dataframe/src/RNTupleProcessorDS.cxx +++ b/tree/dataframe/src/RNTupleProcessorDS.cxx @@ -228,7 +228,7 @@ void RNTupleProcessorDS::AddField(const ROOT::RFieldBase &field, std::string_vie } } -RNTupleProcessorDS::RNTupleProcessorDS(std::unique_ptr processor) +RNTupleProcessorDS::RNTupleProcessorDS(std::unique_ptr processor) : fProcessor(std::move(processor)) { // Do not add the subfields now, this is handled by AddField. @@ -425,8 +425,7 @@ ROOT::RDF::RSampleInfo RNTupleProcessorDS::CreateSampleInfo( } } // namespace ROOT::Experimental::Internal::RDF -ROOT::RDataFrame -ROOT::Experimental::RDF::FromRNTupleProcessor(std::unique_ptr processor) +ROOT::RDataFrame ROOT::Experimental::RDF::FromRNTupleProcessor(std::unique_ptr processor) { return ROOT::RDataFrame( std::make_unique(std::move(processor))); diff --git a/tree/dataframe/test/datasource_ntuple_processor.cxx b/tree/dataframe/test/datasource_ntuple_processor.cxx index 01ae76979b57d..a3247de4af8f3 100644 --- a/tree/dataframe/test/datasource_ntuple_processor.cxx +++ b/tree/dataframe/test/datasource_ntuple_processor.cxx @@ -18,9 +18,9 @@ using ROOT::TestSupport::FileRaii; using ROOT::RNTupleModel; +using ROOT::RNTupleProcessor; using ROOT::RNTupleWriter; using ROOT::Experimental::CreateRNTupleJoinProcessor; -using ROOT::Experimental::RNTupleProcessor; using ROOT::Experimental::Internal::RDF::RNTupleProcessorDS; /* diff --git a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx index f47979387927b..f733b825214bb 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx @@ -30,9 +30,10 @@ #include namespace ROOT { -namespace Experimental { class RNTupleProcessor; -class RNTupleSingleProcessor; + +namespace Experimental { +class RNTupleJoinProcessor; namespace Internal { namespace RDF { @@ -45,7 +46,7 @@ class RNTupleProcessorDS; namespace Internal { struct RNTupleProcessorEntryLoader; // for unit tests const RNTupleProcessorEntry * -LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields); // for unit tests +LoadFullRNTupleProcessorEntry(ROOT::RNTupleProcessor &processor, bool includeSubfields); // for unit tests } // namespace Internal // clang-format off @@ -61,8 +62,8 @@ Note that the RNTupleOpenSpec is *write-only*, to prevent usability issues with */ // clang-format on class RNTupleOpenSpec { - friend class Experimental::RNTupleProcessor; - friend class Experimental::RNTupleSingleProcessor; + friend class RNTupleProcessor; + friend class RNTupleSingleProcessor; private: std::string fNTupleName; @@ -282,48 +283,9 @@ public: } }; -///////////////////////////////////////////////////////////////////////////// -/// \brief Create an RNTupleProcessor for a *join* (i.e., a horizontal combination) of RNTuples. -/// -/// \param[in] primaryNTuple The name and location of the primary RNTuple. Its entries are processed in sequential -/// order. -/// \param[in] auxNTuple The name and location of the RNTuple to join the primary RNTuple with. The order in which -/// its entries are processed is determined by the primary RNTuple and doesn't necessarily have to be sequential. -/// \param[in] joinFields The names of the fields on which to join, in case the specified RNTuples are unaligned. -/// The join is made based on the combined join field values, and therefore each field has to be present in each -/// specified RNTuple. If an empty list is provided, it is assumed that the specified ntuple are fully aligned. -/// \param[in] opts Options for the processor. -/// -/// \return A pointer to the newly created RNTupleProcessor. -// TODO(fdegeus) Move back to RNTupleProcessor::CreateJoin once RNTupleProcessor moves out of Experimental. -std::unique_ptr -CreateRNTupleJoinProcessor(RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTuple, - const std::vector &joinFields, - const RNTupleProcessorOptions &opts = RNTupleProcessorOptions()); - -///////////////////////////////////////////////////////////////////////////// -/// \brief Create an RNTupleProcessor for a *join* (i.e., a horizontal combination) of RNTuples. -/// -/// \param[in] primaryProcessor The primary processor. Its entries are processed in sequential order. -/// \param[in] auxProcessor The processor to join the primary processor with. The order in which its entries are -/// processed is determined by the primary processor and doesn't necessarily have to be sequential. -/// \param[in] joinFields The names of the fields on which to join, in case the specified processors are unaligned. -/// The join is made based on the combined join field values, and therefore each field has to be present in each -/// specified processors. If an empty list is provided, it is assumed that the specified processors are fully -/// aligned. -/// \param[in] opts Options for the processor. -/// -/// \return A pointer to the newly created RNTupleProcessor. -// TODO(fdegeus) Move back to RNTupleProcessor::CreateJoin once RNTupleProcessor moves out of Experimental. -std::unique_ptr -CreateRNTupleJoinProcessor(std::unique_ptr primaryProcessor, - std::unique_ptr auxProcessor, - const std::vector &joinFields, - const RNTupleProcessorOptions &opts = RNTupleProcessorOptions()); - // clang-format off /** -\class ROOT::Experimental::RNTupleProcessor +\class ROOT::RNTupleProcessor \ingroup NTuple \brief Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combined RNTuples. @@ -331,10 +293,9 @@ Example usage (see ntpl012_processor_chain.C and ntpl015_processor_join.C for bi ~~~{.cpp} #include -using ROOT::Experimental::RNTupleProcessor; std::vector ntuples = {{"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}}; -auto processor = RNTupleProcessor::CreateChain(ntuples); +auto processor = ROOT::RNTupleProcessor::CreateChain(ntuples); auto pt = processor->RequestField("pt"); @@ -364,8 +325,8 @@ class RNTupleProcessor { bool includeSubfields); // For unit tests friend class RNTupleSingleProcessor; friend class RNTupleChainProcessor; - friend class RNTupleJoinProcessor; - friend class Internal::RDF::RNTupleProcessorDS; + friend class Experimental::RNTupleJoinProcessor; + friend class Experimental::Internal::RDF::RNTupleProcessorDS; protected: ///////////////////////////////////////////////////////////////////////////// @@ -373,7 +334,7 @@ protected: class REntryMapping { friend class RNTupleSingleProcessor; friend class RNTupleChainProcessor; - friend class RNTupleJoinProcessor; + friend class Experimental::RNTupleJoinProcessor; private: ROOT::NTupleSize_t fEntryNumber = ROOT::kInvalidNTupleIndex; @@ -452,7 +413,7 @@ protected: RNTupleProcessorOptions fOptions; std::shared_ptr fEntry = nullptr; - std::unordered_set fFieldIdxs; + std::unordered_set fFieldIdxs; /// Total number of entries. Only to be used internally by the processor, not meant to be exposed in the public /// interface. @@ -475,8 +436,8 @@ protected: /// \param[in] provenance Provenance of the processor. /// \param[in] updateFields Whether the fields in the entry need to be updated, because the current underlying /// RNTuple source changed. - virtual void Connect(const std::unordered_set &fieldIdxs, - const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool updateFields) = 0; + virtual void Connect(const std::unordered_set &fieldIdxs, + const Internal::RNTupleProcessorProvenance &provenance, bool updateFields) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Disconnect the processor from associated physical storage. @@ -533,9 +494,9 @@ protected: /// \return The index of the newly added field in the entry. /// /// In case the field was already present in the entry, the index of the existing field is returned. - virtual ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + virtual Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(const std::string &canonicalFieldName, const std::string &typeName, void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) = 0; + const Internal::RNTupleProcessorProvenance &provenance) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. @@ -552,17 +513,16 @@ protected: /// \return The index of the newly added field in the entry. /// /// In case the field was already present in the entry, the index of the existing field is returned. - virtual ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + virtual Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &canonicalFieldName, void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) = 0; + const Internal::RNTupleProcessorProvenance &provenance) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \param[in] provenance Provenance of the processor. /// \param[in] addFieldMode Bitfield indicating how the fields should be added. - virtual void - AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) = 0; + virtual void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. @@ -570,7 +530,8 @@ protected: /// \param[in] joinTable the join table to map the entries to. /// \param[in] entryOffset In case the entry mapping is added from a chain, the offset of the entry indexes to use /// with respect to the processor's position in the chain. - virtual void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) = 0; + virtual void + AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) = 0; ///////////////////////////////////////////////////////////////////////////// /// \brief Processor-specific implementation for printing its structure, called by PrintStructure(). @@ -640,7 +601,7 @@ public: return RNTupleProcessorOptionalPtr(fEntry.get(), *fieldIdx); } - auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, ROOT::Internal::RNTupleProcessorProvenance()); + auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, Internal::RNTupleProcessorProvenance()); return RNTupleProcessorOptionalPtr(fEntry.get(), fieldIdx); } @@ -663,7 +624,7 @@ public: RequestField(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr) { Initialize(fEntry); - auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, ROOT::Internal::RNTupleProcessorProvenance()); + auto fieldIdx = AddFieldToEntry(fieldName, typeName, valuePtr, Internal::RNTupleProcessorProvenance()); return RNTupleProcessorOptionalPtr(fEntry.get(), fieldIdx); } @@ -695,7 +656,7 @@ public: // clang-format off /** - \class ROOT::Experimental::RNTupleProcessor::RIterator + \class ROOT::RNTupleProcessor::RIterator \ingroup NTuple \brief Iterator over the entries of an RNTuple, or vertical concatenation thereof. */ @@ -714,7 +675,7 @@ public: RIterator(RNTupleProcessor &processor, ROOT::NTupleSize_t firstEntryIdx) : fProcessor(processor) { if (fProcessor.fEntry && firstEntryIdx != ROOT::kInvalidNTupleIndex) { - fProcessor.Connect(fProcessor.fEntry->GetFieldIndices(), ROOT::Internal::RNTupleProcessorProvenance(), + fProcessor.Connect(fProcessor.fEntry->GetFieldIndices(), Internal::RNTupleProcessorProvenance(), /*updateFields=*/false); fProcessor.SetEntryMapping(firstEntryIdx, fEntryMapping); } @@ -785,7 +746,7 @@ public: // clang-format off /** -\class ROOT::Experimental::RNTupleSingleProcessor +\class ROOT::RNTupleSingleProcessor \ingroup NTuple \brief Processor specialization for processing a single RNTuple. */ @@ -826,10 +787,9 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \brief Connect the provided fields indices in the entry to their on-disk fields. - void - Connect(const std::unordered_set &fieldIdxs, - const ROOT::Internal::RNTupleProcessorProvenance &provenance = ROOT::Internal::RNTupleProcessorProvenance(), - bool updateFields = false) final; + void Connect(const std::unordered_set &fieldIdxs, + const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance(), + bool updateFields = false) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Disconnect the processor from associated physical storage. @@ -838,13 +798,13 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \brief Set the local entry mapping (for nested processors), according to a global entry number. /// - /// \sa ROOT::Experimental::RNTupleProcessor::SetEntryMapping + /// \sa ROOT::RNTupleProcessor::SetEntryMapping void SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Load the entry identified by the entry mapping. /// - /// \sa ROOT::Experimental::RNTupleProcessor::LoadEntryImpl + /// \sa ROOT::RNTupleProcessor::LoadEntryImpl void LoadEntryImpl(const REntryMapping &mapping) final; ///////////////////////////////////////////////////////////////////////////// @@ -866,35 +826,35 @@ private: /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t - AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance = - ROOT::Internal::RNTupleProcessorProvenance()) final; + Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry( + const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, + const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance()) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) final; + const Internal::RNTupleProcessorProvenance &provenance) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \sa RNTupleProcessor::AddAllFieldsToEntry() - void AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; + void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. /// - /// \sa ROOT::Experimental::RNTupleProcessor::AddEntriesToJoinTable - void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) final; + /// \sa ROOT::RNTupleProcessor::AddEntriesToJoinTable + void + AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Processor-specific implementation for printing its structure, called by PrintStructure(). /// - /// \sa ROOT::Experimental::RNTupleProcessor::PrintStructureImpl + /// \sa ROOT::RNTupleProcessor::PrintStructureImpl void PrintStructureImpl(std::ostream &output) const final; ///////////////////////////////////////////////////////////////////////////// @@ -919,7 +879,7 @@ public: // clang-format off /** -\class ROOT::Experimental::RNTupleChainProcessor +\class ROOT::RNTupleChainProcessor \ingroup NTuple \brief Processor specialization for vertically combined (*chained*) RNTupleProcessors. */ @@ -934,7 +894,7 @@ private: ROOT::NTupleSize_t fLastLoadedEntry = 0; //< Last (global) entry number that was loaded std::size_t fCurrentProcessorNumber = 0; //< Number of the currently open inner processor - ROOT::Internal::RNTupleProcessorProvenance fProvenance; + Internal::RNTupleProcessorProvenance fProvenance; ///////////////////////////////////////////////////////////////////////////// /// \brief Initialize the processor by creating an (initially empty) `fEntry`, or setting an existing one. @@ -944,10 +904,9 @@ private: /// \brief Connect the provided fields indices in the entry to their on-disk fields. /// /// \sa RNTupleProcessor::Connect() - void - Connect(const std::unordered_set &fieldIdxs, - const ROOT::Internal::RNTupleProcessorProvenance &provenance = ROOT::Internal::RNTupleProcessorProvenance(), - bool updateFields = false) final; + void Connect(const std::unordered_set &fieldIdxs, + const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance(), + bool updateFields = false) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Update the entry to reflect any missing fields in the current inner processor. @@ -960,13 +919,13 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \brief Set the local entry mapping (for nested processors), according to a global entry number. /// - /// \sa ROOT::Experimental::RNTupleProcessor::SetEntryMapping + /// \sa ROOT::RNTupleProcessor::SetEntryMapping void SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Load the entry identified by the entry mapping. /// - /// \sa ROOT::Experimental::RNTupleProcessor::LoadEntryImpl + /// \sa ROOT::RNTupleProcessor::LoadEntryImpl void LoadEntryImpl(const REntryMapping &mapping) final; ///////////////////////////////////////////////////////////////////////////// @@ -988,35 +947,35 @@ private: /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t - AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance = - ROOT::Internal::RNTupleProcessorProvenance()) final; + Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry( + const std::string &fieldName, const std::string &typeName, void *valuePtr = nullptr, + const Internal::RNTupleProcessorProvenance &provenance = Internal::RNTupleProcessorProvenance()) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add a field to the entry. /// /// \sa RNTupleProcessor::AddFieldToEntry() - ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t + Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) final; + const Internal::RNTupleProcessorProvenance &provenance) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add all known fields (from on-disk information) to the entry. /// /// \sa RNTupleProcessor::AddAllFieldsToEntry() - void AddAllFieldsToEntry(const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; + void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. /// - /// \sa ROOT::Experimental::RNTupleProcessor::AddEntriesToJoinTable - void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) final; + /// \sa ROOT::RNTupleProcessor::AddEntriesToJoinTable + void + AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Processor-specific implementation for printing its structure, called by PrintStructure(). /// - /// \sa ROOT::Experimental::RNTupleProcessor::PrintStructureImpl + /// \sa ROOT::RNTupleProcessor::PrintStructureImpl void PrintStructureImpl(std::ostream &output) const final; ///////////////////////////////////////////////////////////////////////////// @@ -1037,6 +996,45 @@ public: ~RNTupleChainProcessor() override = default; }; +namespace Experimental { +///////////////////////////////////////////////////////////////////////////// +/// \brief Create an RNTupleProcessor for a *join* (i.e., a horizontal combination) of RNTuples. +/// +/// \param[in] primaryNTuple The name and location of the primary RNTuple. Its entries are processed in sequential +/// order. +/// \param[in] auxNTuple The name and location of the RNTuple to join the primary RNTuple with. The order in which +/// its entries are processed is determined by the primary RNTuple and doesn't necessarily have to be sequential. +/// \param[in] joinFields The names of the fields on which to join, in case the specified RNTuples are unaligned. +/// The join is made based on the combined join field values, and therefore each field has to be present in each +/// specified RNTuple. If an empty list is provided, it is assumed that the specified ntuple are fully aligned. +/// \param[in] opts Options for the processor. +/// +/// \return A pointer to the newly created RNTupleProcessor. +// TODO(fdegeus) Move back to RNTupleProcessor::CreateJoin once RNTupleProcessor moves out of Experimental. +std::unique_ptr +CreateRNTupleJoinProcessor(RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTuple, + const std::vector &joinFields, + const RNTupleProcessorOptions &opts = RNTupleProcessorOptions()); + +///////////////////////////////////////////////////////////////////////////// +/// \brief Create an RNTupleProcessor for a *join* (i.e., a horizontal combination) of RNTuples. +/// +/// \param[in] primaryProcessor The primary processor. Its entries are processed in sequential order. +/// \param[in] auxProcessor The processor to join the primary processor with. The order in which its entries are +/// processed is determined by the primary processor and doesn't necessarily have to be sequential. +/// \param[in] joinFields The names of the fields on which to join, in case the specified processors are unaligned. +/// The join is made based on the combined join field values, and therefore each field has to be present in each +/// specified processors. If an empty list is provided, it is assumed that the specified processors are fully +/// aligned. +/// \param[in] opts Options for the processor. +/// +/// \return A pointer to the newly created RNTupleProcessor. +// TODO(fdegeus) Move back to RNTupleProcessor::CreateJoin once RNTupleProcessor moves out of Experimental. +std::unique_ptr +CreateRNTupleJoinProcessor(std::unique_ptr primaryProcessor, + std::unique_ptr auxProcessor, const std::vector &joinFields, + const RNTupleProcessorOptions &opts = RNTupleProcessorOptions()); + // clang-format off /** \class ROOT::Experimental::RNTupleJoinProcessor @@ -1082,13 +1080,13 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \brief Set the local entry mapping (for nested processors), according to a global entry number. /// - /// \sa ROOT::Experimental::RNTupleProcessor::SetEntryMapping + /// \sa ROOT::RNTupleProcessor::SetEntryMapping void SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Load the entry identified by the entry mapping. /// - /// \sa ROOT::Experimental::RNTupleProcessor::LoadEntryImpl + /// \sa ROOT::RNTupleProcessor::LoadEntryImpl void LoadEntryImpl(const REntryMapping &mapping) final; ///////////////////////////////////////////////////////////////////////////// @@ -1140,13 +1138,13 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \brief Add the entry mappings for this processor to the provided join table. /// - /// \sa ROOT::Experimental::RNTupleProcessor::AddEntriesToJoinTable + /// \sa ROOT::RNTupleProcessor::AddEntriesToJoinTable void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset = 0) final; ///////////////////////////////////////////////////////////////////////////// /// \brief Processor-specific implementation for printing its structure, called by PrintStructure(). /// - /// \sa ROOT::Experimental::RNTupleProcessor::PrintStructureImpl + /// \sa ROOT::RNTupleProcessor::PrintStructureImpl void PrintStructureImpl(std::ostream &output) const final; ///////////////////////////////////////////////////////////////////////////// diff --git a/tree/ntuple/src/RNTupleProcessor.cxx b/tree/ntuple/src/RNTupleProcessor.cxx index b9c90b088c408..2455906cc5ad8 100644 --- a/tree/ntuple/src/RNTupleProcessor.cxx +++ b/tree/ntuple/src/RNTupleProcessor.cxx @@ -24,7 +24,7 @@ #include const ROOT::Internal::RNTupleProcessorEntry * -ROOT::Internal::LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields) +ROOT::Internal::LoadFullRNTupleProcessorEntry(ROOT::RNTupleProcessor &processor, bool includeSubfields) { processor.AddAllFieldsToEntry(RNTupleProcessorProvenance(), includeSubfields); return processor.fEntry.get(); @@ -42,15 +42,14 @@ std::unique_ptr ROOT::RNTupleOpenSpec::CreatePageSo return ROOT::Internal::RPageSourceFile::CreateFromAnchor(*ntuple); } -std::unique_ptr -ROOT::Experimental::RNTupleProcessor::Create(RNTupleOpenSpec ntuple, const RNTupleProcessorOptions &options) +std::unique_ptr +ROOT::RNTupleProcessor::Create(RNTupleOpenSpec ntuple, const RNTupleProcessorOptions &options) { return std::unique_ptr(new RNTupleSingleProcessor(std::move(ntuple), options)); } -std::unique_ptr -ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector ntuples, - const RNTupleProcessorOptions &options) +std::unique_ptr +ROOT::RNTupleProcessor::CreateChain(std::vector ntuples, const RNTupleProcessorOptions &options) { if (ntuples.empty()) throw RException(R__FAIL("at least one RNTuple must be provided")); @@ -65,9 +64,9 @@ ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector n return CreateChain(std::move(innerProcessors), options); } -std::unique_ptr -ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector> innerProcessors, - const RNTupleProcessorOptions &options) +std::unique_ptr +ROOT::RNTupleProcessor::CreateChain(std::vector> innerProcessors, + const RNTupleProcessorOptions &options) { if (innerProcessors.empty()) throw RException(R__FAIL("at least one inner processor must be provided")); @@ -75,7 +74,7 @@ ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector(new RNTupleChainProcessor(std::move(innerProcessors), options)); } -std::unique_ptr +std::unique_ptr ROOT::Experimental::CreateRNTupleJoinProcessor(RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTuple, const std::vector &joinFields, const RNTupleProcessorOptions &options) @@ -95,7 +94,7 @@ ROOT::Experimental::CreateRNTupleJoinProcessor(RNTupleOpenSpec primaryNTuple, RN return CreateRNTupleJoinProcessor(std::move(primaryProcessor), std::move(auxProcessor), joinFields, options); } -std::unique_ptr +std::unique_ptr ROOT::Experimental::CreateRNTupleJoinProcessor(std::unique_ptr primaryProcessor, std::unique_ptr auxProcessor, const std::vector &joinFields, @@ -115,8 +114,7 @@ ROOT::Experimental::CreateRNTupleJoinProcessor(std::unique_ptr //------------------------------------------------------------------------------ -ROOT::Experimental::RNTupleSingleProcessor::RNTupleSingleProcessor(RNTupleOpenSpec ntuple, - const RNTupleProcessorOptions &options) +ROOT::RNTupleSingleProcessor::RNTupleSingleProcessor(RNTupleOpenSpec ntuple, const RNTupleProcessorOptions &options) : RNTupleProcessor(options), fNTupleSpec(std::move(ntuple)) { if (fOptions.GetProcessorName().empty()) { @@ -124,15 +122,14 @@ ROOT::Experimental::RNTupleSingleProcessor::RNTupleSingleProcessor(RNTupleOpenSp } } -void ROOT::Experimental::RNTupleSingleProcessor::Initialize( - std::shared_ptr entry) +void ROOT::RNTupleSingleProcessor::Initialize(std::shared_ptr entry) { // The processor has already been initialized. if (IsInitialized() && fPageSource) return; if (!entry) - fEntry = std::make_shared(); + fEntry = std::make_shared(); else fEntry = std::move(entry); @@ -142,7 +139,7 @@ void ROOT::Experimental::RNTupleSingleProcessor::Initialize( fNEntries = fPageSource->GetNEntries(); } -bool ROOT::Experimental::RNTupleSingleProcessor::CanReadFieldFromDisk(std::string_view fieldName) +bool ROOT::RNTupleSingleProcessor::CanReadFieldFromDisk(std::string_view fieldName) { Initialize(); auto desc = fPageSource->GetSharedDescriptorGuard(); @@ -153,8 +150,7 @@ bool ROOT::Experimental::RNTupleSingleProcessor::CanReadFieldFromDisk(std::strin } std::unique_ptr -ROOT::Experimental::RNTupleSingleProcessor::CreateAndConnectField(const std::string &qualifiedFieldName, - const std::string &typeName) +ROOT::RNTupleSingleProcessor::CreateAndConnectField(const std::string &qualifiedFieldName, const std::string &typeName) { assert(fPageSource); @@ -189,8 +185,7 @@ ROOT::Experimental::RNTupleSingleProcessor::CreateAndConnectField(const std::str return ConnectField(std::move(field)); } -std::unique_ptr -ROOT::Experimental::RNTupleSingleProcessor::ConnectField(std::unique_ptr field) +std::unique_ptr ROOT::RNTupleSingleProcessor::ConnectField(std::unique_ptr field) { ROOT::RFieldZero fieldZero; ROOT::Internal::SetAllowFieldSubstitutions(fieldZero, true); @@ -199,9 +194,9 @@ ROOT::Experimental::RNTupleSingleProcessor::ConnectField(std::unique_ptrFindFieldIndex(canonicalFieldName, typeName); if (!fieldIdx) { @@ -225,9 +220,10 @@ ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleS return *fieldIdx; } -ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry( - std::unique_ptr field, const std::string &canonicalFieldName, void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t +ROOT::RNTupleSingleProcessor::AddFieldToEntry(std::unique_ptr field, + const std::string &canonicalFieldName, void *valuePtr, + const Internal::RNTupleProcessorProvenance &provenance) { auto fieldIdx = fEntry->FindFieldIndex(canonicalFieldName, field->GetTypeName()); if (!fieldIdx) { @@ -251,8 +247,8 @@ ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t ROOT::Experimental::RNTupleS return *fieldIdx; } -void ROOT::Experimental::RNTupleSingleProcessor::AddAllFieldsToEntry( - const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) +void ROOT::RNTupleSingleProcessor::AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, + bool includeSubfields) { Initialize(); auto descGuard = fPageSource->GetSharedDescriptorGuard(); @@ -281,8 +277,7 @@ void ROOT::Experimental::RNTupleSingleProcessor::AddAllFieldsToEntry( } } -void ROOT::Experimental::RNTupleSingleProcessor::SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, - REntryMapping &mapping) +void ROOT::RNTupleSingleProcessor::SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) { if (globalEntryNumber >= fNEntries || !fEntry) mapping.SetEntryNumber(kInvalidNTupleIndex); @@ -290,7 +285,7 @@ void ROOT::Experimental::RNTupleSingleProcessor::SetEntryMapping(ROOT::NTupleSiz mapping.SetEntryNumber(globalEntryNumber); } -void ROOT::Experimental::RNTupleSingleProcessor::LoadEntryImpl(const REntryMapping &mapping) +void ROOT::RNTupleSingleProcessor::LoadEntryImpl(const REntryMapping &mapping) { assert(mapping.GetEntryNumber() != kInvalidNTupleIndex); @@ -301,9 +296,9 @@ void ROOT::Experimental::RNTupleSingleProcessor::LoadEntryImpl(const REntryMappi fNEntriesProcessed++; } -void ROOT::Experimental::RNTupleSingleProcessor::Connect( - const std::unordered_set &fieldIdxs, - const ROOT::Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields) +void ROOT::RNTupleSingleProcessor::Connect( + const std::unordered_set &fieldIdxs, + const Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields) { Initialize(fEntry); @@ -319,7 +314,7 @@ void ROOT::Experimental::RNTupleSingleProcessor::Connect( } } -void ROOT::Experimental::RNTupleSingleProcessor::Disconnect() +void ROOT::RNTupleSingleProcessor::Disconnect() { if (fPageSource) { fEntry->ResetFields(fFieldIdxs); @@ -327,14 +322,14 @@ void ROOT::Experimental::RNTupleSingleProcessor::Disconnect() } } -void ROOT::Experimental::RNTupleSingleProcessor::AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, - ROOT::NTupleSize_t entryOffset) +void ROOT::RNTupleSingleProcessor::AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, + ROOT::NTupleSize_t entryOffset) { Connect(fFieldIdxs); - joinTable.Add(*fPageSource, Internal::RNTupleJoinTable::kDefaultPartitionKey, entryOffset); + joinTable.Add(*fPageSource, Experimental::Internal::RNTupleJoinTable::kDefaultPartitionKey, entryOffset); } -void ROOT::Experimental::RNTupleSingleProcessor::PrintStructureImpl(std::ostream &output) const +void ROOT::RNTupleSingleProcessor::PrintStructureImpl(std::ostream &output) const { static constexpr int width = 32; @@ -360,8 +355,8 @@ void ROOT::Experimental::RNTupleSingleProcessor::PrintStructureImpl(std::ostream //------------------------------------------------------------------------------ -ROOT::Experimental::RNTupleChainProcessor::RNTupleChainProcessor( - std::vector> processors, const RNTupleProcessorOptions &options) +ROOT::RNTupleChainProcessor::RNTupleChainProcessor(std::vector> processors, + const RNTupleProcessorOptions &options) : RNTupleProcessor(options), fInnerProcessors(std::move(processors)) { if (fOptions.GetProcessorName().empty()) { @@ -372,20 +367,20 @@ ROOT::Experimental::RNTupleChainProcessor::RNTupleChainProcessor( fInnerNEntries.assign(fInnerProcessors.size(), kInvalidNTupleIndex); } -void ROOT::Experimental::RNTupleChainProcessor::Initialize(std::shared_ptr entry) +void ROOT::RNTupleChainProcessor::Initialize(std::shared_ptr entry) { if (IsInitialized()) return; if (!entry) - fEntry = std::make_shared(); + fEntry = std::make_shared(); else fEntry = std::move(entry); fInnerProcessors[0]->Initialize(fEntry); } -ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::GetNEntries() +ROOT::NTupleSize_t ROOT::RNTupleChainProcessor::GetNEntries() { if (fNEntries == kInvalidNTupleIndex) { fNEntries = 0; @@ -403,9 +398,9 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::GetNEntries() return fNEntries; } -void ROOT::Experimental::RNTupleChainProcessor::Connect( - const std::unordered_set &fieldIdxs, - const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */) +void ROOT::RNTupleChainProcessor::Connect( + const std::unordered_set &fieldIdxs, + const Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */) { Initialize(); fFieldIdxs = fieldIdxs; @@ -413,14 +408,14 @@ void ROOT::Experimental::RNTupleChainProcessor::Connect( ConnectInnerProcessor(fCurrentProcessorNumber); } -void ROOT::Experimental::RNTupleChainProcessor::Disconnect() +void ROOT::RNTupleChainProcessor::Disconnect() { for (const auto &innerProc : fInnerProcessors) { innerProc->Disconnect(); } } -void ROOT::Experimental::RNTupleChainProcessor::ConnectInnerProcessor(std::size_t processorNumber) +void ROOT::RNTupleChainProcessor::ConnectInnerProcessor(std::size_t processorNumber) { if (fCurrentProcessorNumber != processorNumber) { fInnerProcessors[fCurrentProcessorNumber]->Disconnect(); @@ -433,30 +428,27 @@ void ROOT::Experimental::RNTupleChainProcessor::ConnectInnerProcessor(std::size_ } ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t -ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName, - void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) +ROOT::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr, + const Internal::RNTupleProcessorProvenance &provenance) { return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(fieldName, typeName, valuePtr, provenance); } ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t -ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(std::unique_ptr field, - const std::string &fieldName, void *valuePtr, - const ROOT::Internal::RNTupleProcessorProvenance &provenance) +ROOT::RNTupleChainProcessor::AddFieldToEntry(std::unique_ptr field, const std::string &fieldName, + void *valuePtr, const Internal::RNTupleProcessorProvenance &provenance) { return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(std::move(field), fieldName, valuePtr, provenance); } -void ROOT::Experimental::RNTupleChainProcessor::AddAllFieldsToEntry( - const ROOT::Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) +void ROOT::RNTupleChainProcessor::AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, + bool includeSubfields) { Initialize(); fInnerProcessors[0]->AddAllFieldsToEntry(provenance, includeSubfields); } -void ROOT::Experimental::RNTupleChainProcessor::SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, - REntryMapping &mapping) +void ROOT::RNTupleChainProcessor::SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) { std::size_t currProcessorIdx = mapping.GetInnerProcessorIdx(); @@ -508,7 +500,7 @@ void ROOT::Experimental::RNTupleChainProcessor::SetEntryMapping(ROOT::NTupleSize mapping.SetInnerProcessorIdx(currProcessorIdx); } -void ROOT::Experimental::RNTupleChainProcessor::LoadEntryImpl(const REntryMapping &mapping) +void ROOT::RNTupleChainProcessor::LoadEntryImpl(const REntryMapping &mapping) { assert(mapping.GetEntryNumber() != kInvalidNTupleIndex); @@ -519,8 +511,8 @@ void ROOT::Experimental::RNTupleChainProcessor::LoadEntryImpl(const REntryMappin fNEntriesProcessed++; } -void ROOT::Experimental::RNTupleChainProcessor::AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, - ROOT::NTupleSize_t entryOffset) +void ROOT::RNTupleChainProcessor::AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, + ROOT::NTupleSize_t entryOffset) { for (unsigned i = 0; i < fInnerProcessors.size(); ++i) { const auto &innerProc = fInnerProcessors[i]; @@ -531,7 +523,7 @@ void ROOT::Experimental::RNTupleChainProcessor::AddEntriesToJoinTable(Internal:: } } -void ROOT::Experimental::RNTupleChainProcessor::PrintStructureImpl(std::ostream &output) const +void ROOT::RNTupleChainProcessor::PrintStructureImpl(std::ostream &output) const { for (const auto &innerProc : fInnerProcessors) { innerProc->PrintStructure(output); @@ -586,7 +578,7 @@ void ROOT::Experimental::RNTupleJoinProcessor::Initialize(std::shared_ptrAddEntriesToJoinTable(joinTable, entryOffset); } diff --git a/tree/ntuple/test/ntuple_test.hxx b/tree/ntuple/test/ntuple_test.hxx index a76242d4e28a9..69f9fecbead62 100644 --- a/tree/ntuple/test/ntuple_test.hxx +++ b/tree/ntuple/test/ntuple_test.hxx @@ -97,7 +97,7 @@ using RNTupleModel = ROOT::RNTupleModel; using RNTupleOpenSpec = ROOT::RNTupleOpenSpec; using RNTuplePlainCounter = ROOT::Experimental::Detail::RNTuplePlainCounter; using RNTuplePlainTimer = ROOT::Experimental::Detail::RNTuplePlainTimer; -using RNTupleProcessor = ROOT::Experimental::RNTupleProcessor; +using RNTupleProcessor = ROOT::RNTupleProcessor; using RNTupleProcessorOptions = ROOT::RNTupleProcessorOptions; using RNTupleSerializer = ROOT::Internal::RNTupleSerializer; using RPage = ROOT::Internal::RPage; diff --git a/tutorials/io/ntuple/ntpl012_processor_chain.C b/tutorials/io/ntuple/ntpl012_processor_chain.C index a38c7e16a8657..e793ada813ca6 100644 --- a/tutorials/io/ntuple/ntpl012_processor_chain.C +++ b/tutorials/io/ntuple/ntpl012_processor_chain.C @@ -20,9 +20,6 @@ #include #include -// Import classes from the `Experimental` namespace for the time being. -using ROOT::Experimental::RNTupleProcessor; - // Number of events to generate for each ntuple. constexpr int kNEvents = 10000; @@ -65,7 +62,7 @@ void Read(const std::vector &ntuples) // The chain-based processor can be created by passing a list of RNTupleOpenSpecs, describing the name and location // of each ntuple in the chain. - auto processor = RNTupleProcessor::CreateChain(ntuples); + auto processor = ROOT::RNTupleProcessor::CreateChain(ntuples); int prevProcessorNumber{-1}; // Access to the processor's fields is done by first requesting them through RNTupleProcessor::RequestField(). The From 60027062add1793125e8614b5c0df73ce20d4aab Mon Sep 17 00:00:00 2001 From: Florine de Geus Date: Fri, 16 Oct 2026 22:47:10 +0200 Subject: [PATCH 6/6] [ntuple] Remove unused variable --- tutorials/io/ntuple/ntpl012_processor_chain.C | 1 - 1 file changed, 1 deletion(-) diff --git a/tutorials/io/ntuple/ntpl012_processor_chain.C b/tutorials/io/ntuple/ntpl012_processor_chain.C index e793ada813ca6..59226eb980027 100644 --- a/tutorials/io/ntuple/ntpl012_processor_chain.C +++ b/tutorials/io/ntuple/ntpl012_processor_chain.C @@ -63,7 +63,6 @@ void Read(const std::vector &ntuples) // The chain-based processor can be created by passing a list of RNTupleOpenSpecs, describing the name and location // of each ntuple in the chain. auto processor = ROOT::RNTupleProcessor::CreateChain(ntuples); - int prevProcessorNumber{-1}; // Access to the processor's fields is done by first requesting them through RNTupleProcessor::RequestField(). The // returned value can be used to read the current entry's value for that particular field.