Skip to content

Commit

Permalink
[df] Move FromRNTuple to separate header
Browse files Browse the repository at this point in the history
For snapshotting RNTuples, we need to include the header file for
RNTupleDS in `ActionHelpers.hxx`. To avoid dependency conflicts related
to including `ROOT/RDataFrame.hxx`, we move the free `FromRNTuple`
functions to a separate header.
  • Loading branch information
enirolf committed Jun 4, 2024
1 parent 291574c commit 7dab2fe
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
1 change: 1 addition & 0 deletions tree/dataframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()

if(root7)
list(APPEND RDATAFRAME_EXTRA_HEADERS ROOT/RNTupleDS.hxx)
list(APPEND RDATAFRAME_EXTRA_HEADERS ROOT/RNTupleDSHelpers.hxx)
list(APPEND RDATAFRAME_EXTRA_DEPS ROOTNTuple)
endif()

Expand Down
10 changes: 0 additions & 10 deletions tree/dataframe/inc/ROOT/RNTupleDS.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef ROOT_RNTupleDS
#define ROOT_RNTupleDS

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RDataSource.hxx>
#include <ROOT/RNTupleUtil.hxx>
#include <string_view>
Expand Down Expand Up @@ -145,15 +144,6 @@ protected:
};

} // ns Experimental

namespace RDF {
namespace Experimental {
RDataFrame FromRNTuple(std::string_view ntupleName, std::string_view fileName);
RDataFrame FromRNTuple(std::string_view ntupleName, const std::vector<std::string> &fileNames);
RDataFrame FromRNTuple(ROOT::Experimental::RNTuple *ntuple);
} // namespace Experimental
} // namespace RDF

} // ns ROOT

#endif
42 changes: 42 additions & 0 deletions tree/dataframe/inc/ROOT/RNTupleDSHelpers.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// \file RNTupleDSHelpers.hxx
/// \ingroup NTuple ROOT7
/// \author Florine de Geus <florine.de.geus@cern.ch>
/// \date 2024-06-04
/// \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. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

#ifndef ROOT_RNTupleDSHelpers
#define ROOT_RNTupleDSHelpers

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RNTupleDS.hxx>

namespace ROOT {
namespace RDF {
namespace Experimental {
////////////////////////////////////////////////////////////////////////////////
/// \brief Create an RDataFrame from an RNTuple.
///
/// \param[in] ntupleName The ntuple name
/// \param[in] fileName The file name
///
/// \return An RDataFrame based on the provided RNTuple
///
/// \note It is possible to create RNTuple-based dataframes with the standard RDataFrame constructor!
///
ROOT::RDataFrame FromRNTuple(std::string_view ntupleName, std::string_view fileName);
ROOT::RDataFrame FromRNTuple(std::string_view ntupleName, const std::vector<std::string> &fileNames);
ROOT::RDataFrame FromRNTuple(ROOT::Experimental::RNTuple *ntuple);
} // namespace Experimental
} // namespace RDF
} // namespace ROOT

#endif // ROOT_RNTupleDSHelpers
1 change: 1 addition & 0 deletions tree/dataframe/src/RNTupleDS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ROOT/RPageStorageFile.hxx>
#include <ROOT/RNTupleDescriptor.hxx>
#include <ROOT/RNTupleDS.hxx>
#include <ROOT/RNTupleDSHelpers.hxx>
#include <ROOT/RNTupleUtil.hxx>
#include <ROOT/RPageStorage.hxx>
#include <string_view>
Expand Down
1 change: 1 addition & 0 deletions tree/dataframe/test/datasource_ntuple.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <ROOT/RDataFrame.hxx>
#include <ROOT/RNTupleDS.hxx>
#include <ROOT/RNTupleDSHelpers.hxx>
#include <ROOT/RVec.hxx>

#include <ROOT/RNTupleModel.hxx>
Expand Down

0 comments on commit 7dab2fe

Please sign in to comment.