diff --git a/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx b/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx index 1ca79627a3058..d294b7704ef23 100644 --- a/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx +++ b/tree/dataframe/inc/ROOT/RNTupleProcessorDS.hxx @@ -92,11 +92,11 @@ 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: - 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 04bd48828659a..e899aa3a6d42b 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++) { @@ -228,11 +228,11 @@ 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. - fProcessor->AddAllFieldsToEntry(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); } @@ -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 760178085384f..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; /* @@ -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 d3fbaae230475..f733b825214bb 100644 --- a/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleProcessor.hxx @@ -30,23 +30,28 @@ #include namespace ROOT { -namespace Experimental { class RNTupleProcessor; -namespace Internal { -struct RNTupleProcessorEntryLoader; // for unit tests -const RNTupleProcessorEntry * -LoadFullRNTupleProcessorEntry(ROOT::Experimental::RNTupleProcessor &processor, bool includeSubfields); // for unit tests +namespace Experimental { +class RNTupleJoinProcessor; +namespace Internal { namespace RDF { class RNTupleProcessorColumnReader; class RNTupleProcessorDS; } // namespace RDF } // namespace Internal +} // namespace Experimental + +namespace Internal { +struct RNTupleProcessorEntryLoader; // for unit tests +const RNTupleProcessorEntry * +LoadFullRNTupleProcessorEntry(ROOT::RNTupleProcessor &processor, bool includeSubfields); // for unit tests +} // namespace Internal // 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. @@ -59,7 +64,6 @@ Note that the RNTupleOpenSpec is *write-only*, to prevent usability issues with class RNTupleOpenSpec { friend class RNTupleProcessor; friend class RNTupleSingleProcessor; - friend class RNTupleJoinProcessor; private: std::string fNTupleName; @@ -69,9 +73,16 @@ 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; }; +// 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 @@ -79,14 +90,23 @@ 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; } }; // 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. @@ -189,7 +209,7 @@ public: // clang-format off /** -\class ROOT::Experimental::RNTupleProcessorOptionalPtr +\class ROOT::RNTupleProcessorOptionalPtr \ingroup NTuple \brief Specialization of RNTupleProcessorOptionalPtr for `void`-type pointers. */ @@ -263,47 +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. @@ -311,11 +293,9 @@ 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"}}; -auto processor = RNTupleProcessor::CreateChain(ntuples); +std::vector ntuples = {{"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}}; +auto processor = ROOT::RNTupleProcessor::CreateChain(ntuples); auto pt = processor->RequestField("pt"); @@ -339,14 +319,14 @@ 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; - friend class Internal::RDF::RNTupleProcessorDS; + friend class Experimental::RNTupleJoinProcessor; + friend class Experimental::Internal::RDF::RNTupleProcessorDS; protected: ///////////////////////////////////////////////////////////////////////////// @@ -354,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; @@ -432,7 +412,7 @@ protected: RNTupleProcessorOptions fOptions; - std::shared_ptr fEntry = nullptr; + 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 @@ -443,7 +423,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. @@ -484,11 +464,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 @@ -550,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(). @@ -675,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. */ @@ -765,7 +746,7 @@ public: // clang-format off /** -\class ROOT::Experimental::RNTupleSingleProcessor +\class ROOT::RNTupleSingleProcessor \ingroup NTuple \brief Processor specialization for processing a single RNTuple. */ @@ -802,7 +783,7 @@ 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. @@ -817,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,13 +847,14 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \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; ///////////////////////////////////////////////////////////////////////////// @@ -897,7 +879,7 @@ public: // clang-format off /** -\class ROOT::Experimental::RNTupleChainProcessor +\class ROOT::RNTupleChainProcessor \ingroup NTuple \brief Processor specialization for vertically combined (*chained*) RNTupleProcessors. */ @@ -916,7 +898,7 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \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. @@ -937,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; ///////////////////////////////////////////////////////////////////////////// @@ -986,13 +968,14 @@ private: ///////////////////////////////////////////////////////////////////////////// /// \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; ///////////////////////////////////////////////////////////////////////////// @@ -1013,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 @@ -1032,23 +1054,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. @@ -1057,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; ///////////////////////////////////////////////////////////////////////////// @@ -1093,34 +1116,35 @@ 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. /// - /// \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; ///////////////////////////////////////////////////////////////////////////// @@ -1143,7 +1167,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..2455906cc5ad8 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::RNTupleProcessor &processor, bool includeSubfields) { processor.AddAllFieldsToEntry(RNTupleProcessorProvenance(), includeSubfields); return processor.fEntry.get(); @@ -32,7 +32,7 @@ ROOT::Experimental::Internal::LoadFullRNTupleProcessorEntry(RNTupleProcessor &pr //------------------------------------------------------------------------------ -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); @@ -42,15 +42,14 @@ std::unique_ptr ROOT::Experimental::RNTupleOpenSpec 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,8 +122,7 @@ 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) @@ -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,10 +194,9 @@ ROOT::Experimental::RNTupleSingleProcessor::ConnectField(std::unique_ptrFindFieldIndex(canonicalFieldName, typeName); if (!fieldIdx) { @@ -226,10 +220,10 @@ 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::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) { @@ -253,8 +247,8 @@ ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(std::unique_ptrGetSharedDescriptorGuard(); @@ -283,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); @@ -292,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); @@ -303,8 +296,8 @@ void ROOT::Experimental::RNTupleSingleProcessor::LoadEntryImpl(const REntryMappi fNEntriesProcessed++; } -void ROOT::Experimental::RNTupleSingleProcessor::Connect( - const std::unordered_set &fieldIdxs, +void ROOT::RNTupleSingleProcessor::Connect( + const std::unordered_set &fieldIdxs, const Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields) { Initialize(fEntry); @@ -321,7 +314,7 @@ void ROOT::Experimental::RNTupleSingleProcessor::Connect( } } -void ROOT::Experimental::RNTupleSingleProcessor::Disconnect() +void ROOT::RNTupleSingleProcessor::Disconnect() { if (fPageSource) { fEntry->ResetFields(fFieldIdxs); @@ -329,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; @@ -362,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()) { @@ -374,8 +367,7 @@ 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; @@ -388,7 +380,7 @@ void ROOT::Experimental::RNTupleChainProcessor::Initialize( fInnerProcessors[0]->Initialize(fEntry); } -ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::GetNEntries() +ROOT::NTupleSize_t ROOT::RNTupleChainProcessor::GetNEntries() { if (fNEntries == kInvalidNTupleIndex) { fNEntries = 0; @@ -406,8 +398,8 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::GetNEntries() return fNEntries; } -void ROOT::Experimental::RNTupleChainProcessor::Connect( - const std::unordered_set &fieldIdxs, +void ROOT::RNTupleChainProcessor::Connect( + const std::unordered_set &fieldIdxs, const Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */) { Initialize(); @@ -416,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(); @@ -435,31 +427,28 @@ void ROOT::Experimental::RNTupleChainProcessor::ConnectInnerProcessor(std::size_ innerProc->Connect(fFieldIdxs, fProvenance, /*updateFields=*/true); } -ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t -ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName, - void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t +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::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t -ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(std::unique_ptr field, - const std::string &fieldName, void *valuePtr, - const Internal::RNTupleProcessorProvenance &provenance) +ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t +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 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(); @@ -511,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); @@ -522,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]; @@ -534,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); @@ -557,14 +546,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,18 +572,19 @@ 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); } - fJoinTable = Internal::RNTupleJoinTable::Create(fJoinFieldNames); + fJoinTable = Experimental::Internal::RNTupleJoinTable::Create(fJoinFieldNames); } } 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 +607,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 +638,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 +669,7 @@ ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(std::unique_ptrAddAllFieldsToEntry(provenance, includeSubfields); @@ -763,8 +752,8 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleJoinProcessor::GetNEntries() return fNEntries; } -void ROOT::Experimental::RNTupleJoinProcessor::AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, - ROOT::NTupleSize_t entryOffset) +void ROOT::Experimental::RNTupleJoinProcessor::AddEntriesToJoinTable( + Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset) { fPrimaryProcessor->AddEntriesToJoinTable(joinTable, entryOffset); } 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); diff --git a/tree/ntuple/test/ntuple_test.hxx b/tree/ntuple/test/ntuple_test.hxx index 1a12aa84bdd0a..69f9fecbead62 100644 --- a/tree/ntuple/test/ntuple_test.hxx +++ b/tree/ntuple/test/ntuple_test.hxx @@ -94,11 +94,11 @@ 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; -using RNTupleProcessorOptions = ROOT::Experimental::RNTupleProcessorOptions; +using RNTupleProcessor = ROOT::RNTupleProcessor; +using RNTupleProcessorOptions = ROOT::RNTupleProcessorOptions; using RNTupleSerializer = ROOT::Internal::RNTupleSerializer; using RPage = ROOT::Internal::RPage; using RPageAllocatorHeap = ROOT::Internal::RPageAllocatorHeap; diff --git a/tutorials/io/ntuple/ntpl012_processor_chain.C b/tutorials/io/ntuple/ntpl012_processor_chain.C index f9eee0812f35c..59226eb980027 100644 --- a/tutorials/io/ntuple/ntpl012_processor_chain.C +++ b/tutorials/io/ntuple/ntpl012_processor_chain.C @@ -20,10 +20,6 @@ #include #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. constexpr int kNEvents = 10000; @@ -58,7 +54,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); @@ -66,8 +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); - int prevProcessorNumber{-1}; + auto processor = ROOT::RNTupleProcessor::CreateChain(ntuples); // 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. @@ -96,7 +91,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";