diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index 07c1bd1b6e63f..67b4367d89bd0 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -153,6 +153,10 @@ Replace `obj.Connect(signal, "TPyDispatcher", disp, "Dispatch()")` with * Reading a collection without its dictionary no longer crashes when the elements hold a `std::string` or a `TString`. The emulated collection proxy relocated its elements with a raw memory copy when its buffer had to grow, which corrupts an object that points into itself, such as a `std::string` using the small string optimization; the invalid pointer was then freed when the object was destroyed. Such elements are now destroyed and reconstructed at the new location instead. This affected for instance a `std::vector>` read back without a dictionary. +### RFile + +RFile, ROOT's modern interface to ROOT file, has moved out of the `ROOT::Experimental` namespace. + ### RNTupleProcessor The RNTupleProcessor is a new, standalone interface for creating *chains* (similar to TTree's `TChain`) and *joins* (similar to TTree friends) from RNTuples in a composable way, and iterating over their entries. diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rfile.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rfile.py index 727835e1618ea..849da65996d7f 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rfile.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rfile.py @@ -32,7 +32,7 @@ def __call__(self, namecycle): key = self._rfile.GetKeyInfo(namecycle) if key: - obj = ROOT.Experimental.Internal.RFile_GetObjectFromKey(self._rfile, key) + obj = ROOT.Internal.RFile_GetObjectFromKey(self._rfile, key) return ROOT._cppyy.bind_object(obj, key.GetClassName()) # No key return None @@ -151,7 +151,7 @@ def _ListKeys(rfile, basePath="", **kwargs): print(key.GetPath()) ~~~ """ - from ROOT.Experimental import RFile + from ROOT import RFile listObjects = kwargs['listObjects'] if 'listObjects' in kwargs else True listDirs = kwargs['listDirs'] if 'listDirs' in kwargs else False @@ -162,7 +162,7 @@ def _ListKeys(rfile, basePath="", **kwargs): return iter -@pythonization("RFile", ns="ROOT::Experimental") +@pythonization("RFile", ns="ROOT") def pythonize_rfile(klass): # Explicitly prevent to create a RFile via ctor klass.__init__ = _RFileInit diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py index d18220d9198de..abb435adbe1b0 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py @@ -234,9 +234,6 @@ def _RNTupleWriter_Append(model, *args): model = model.Clone() import ROOT - if len(args) > 1 and isinstance(args[1], ROOT.Experimental.RFile): - return RNTupleContextWrapper(ROOT.Experimental.RNTupleWriter_Append(model, *args), "RNTupleWriter", on_ctx_exit = _RNTupleWriter_exit) - return RNTupleContextWrapper(ROOT.RNTupleWriter._Append(model, *args), "RNTupleWriter", on_ctx_exit = _RNTupleWriter_exit) diff --git a/io/io/inc/ROOT/RFile.hxx b/io/io/inc/ROOT/RFile.hxx index af9c9c77e5b3b..c98cb09a42024 100644 --- a/io/io/inc/ROOT/RFile.hxx +++ b/io/io/inc/ROOT/RFile.hxx @@ -25,7 +25,6 @@ class TKey; class TTree; namespace ROOT { -namespace Experimental { class RKeyInfo; class RFile; @@ -59,7 +58,7 @@ std::pair DecomposePath(std::string_view pat class RFileKeyIterable; /** -\class ROOT::Experimental::RKeyInfo +\class ROOT::RKeyInfo \ingroup io_files \brief Information about an RFile object's Key. @@ -69,8 +68,8 @@ Querying this information can be done via RFile::ListKeys(). Reading an object's doesn't deserialize the full object, so it's a relatively lightweight operation. */ class RKeyInfo final { - friend class ROOT::Experimental::RFile; - friend class ROOT::Experimental::RFileKeyIterable; + friend class ROOT::RFile; + friend class ROOT::RFileKeyIterable; public: enum class ECategory : std::uint16_t { @@ -186,7 +185,7 @@ public: }; /** -\class ROOT::Experimental::RFile +\class ROOT::RFile \ingroup io_files \brief An interface to read from, or write to, a ROOT file, as well as performing other common operations. @@ -434,7 +433,6 @@ public: void Print(std::ostream &out = std::cout) const; }; -} // namespace Experimental } // namespace ROOT #endif diff --git a/io/io/src/RFile.cxx b/io/io/src/RFile.cxx index d1095eebf4e43..6ceab8e99db55 100644 --- a/io/io/src/RFile.cxx +++ b/io/io/src/RFile.cxx @@ -21,14 +21,14 @@ #include #include -ROOT::RLogChannel &ROOT::Experimental::Internal::RFileLog() +ROOT::RLogChannel &ROOT::Internal::RFileLog() { static ROOT::RLogChannel sLog("ROOT.File"); return sLog; } -using ROOT::Experimental::RFile; -using ROOT::Experimental::Internal::RFileLog; +using ROOT::RFile; +using ROOT::Internal::RFileLog; namespace { enum class ENameCycleError { @@ -190,7 +190,7 @@ static std::string ReconstructFullKeyPath(const TKey &key) } ///////////////////////////////////////////////////////////////////////////////////////////////// -std::pair ROOT::Experimental::Detail::DecomposePath(std::string_view path) +std::pair ROOT::Detail::DecomposePath(std::string_view path) { auto lastSlashIdx = path.rfind('/'); if (lastSlashIdx == std::string_view::npos) @@ -399,14 +399,14 @@ void RFile::PutUntyped(std::string_view pathSV, const std::type_info &type, cons } } -ROOT::Experimental::RFileKeyIterable::RIterator::RIterStackElem::RIterStackElem(TIterator *it, const std::string &path) +ROOT::RFileKeyIterable::RIterator::RIterStackElem::RIterStackElem(TIterator *it, const std::string &path) : fIter(it), fDirPath(path) { } -ROOT::Experimental::RFileKeyIterable::RIterator::RIterStackElem::~RIterStackElem() = default; +ROOT::RFileKeyIterable::RIterator::RIterStackElem::~RIterStackElem() = default; -ROOT::Experimental::RFileKeyIterable::RIterator::RIterator(TIterator *iter, Pattern_t pattern, std::uint32_t flags) +ROOT::RFileKeyIterable::RIterator::RIterator(TIterator *iter, Pattern_t pattern, std::uint32_t flags) : fPattern(pattern), fFlags(flags) { if (iter) { @@ -425,17 +425,17 @@ ROOT::Experimental::RFileKeyIterable::RIterator::RIterator(TIterator *iter, Patt } } -ROOT::Experimental::RFileKeyIterable::RIterator ROOT::Experimental::RFileKeyIterable::begin() const +ROOT::RFileKeyIterable::RIterator ROOT::RFileKeyIterable::begin() const { return {fFile->GetListOfKeys()->MakeIterator(), fPattern, fFlags}; } -ROOT::Experimental::RFileKeyIterable::RIterator ROOT::Experimental::RFileKeyIterable::end() const +ROOT::RFileKeyIterable::RIterator ROOT::RFileKeyIterable::end() const { return {nullptr, fPattern, fFlags}; } -void ROOT::Experimental::RFileKeyIterable::RIterator::Advance() +void ROOT::RFileKeyIterable::RIterator::Advance() { fCurKey = nullptr; @@ -498,7 +498,7 @@ void ROOT::Experimental::RFileKeyIterable::RIterator::Advance() } } -ROOT::Experimental::RKeyInfo ROOT::Experimental::RFileKeyIterable::RIterator::operator*() +ROOT::RKeyInfo ROOT::RFileKeyIterable::RIterator::operator*() { if (fIterStack.empty()) throw ROOT::RException(R__FAIL("tried to dereference an invalid iterator")); @@ -547,7 +547,7 @@ void RFile::Close() fFile.reset(); } -ROOT::Experimental::RKeyInfo::RKeyInfo(const TKey &key) +ROOT::RKeyInfo::RKeyInfo(const TKey &key) : fPath(ReconstructFullKeyPath(key)), fTitle(key.GetTitle()), fClassName(key.GetClassName()), @@ -560,7 +560,7 @@ ROOT::Experimental::RKeyInfo::RKeyInfo(const TKey &key) { } -std::optional RFile::GetKeyInfo(std::string_view path) const +std::optional RFile::GetKeyInfo(std::string_view path) const { const TKey *key = GetTKey(path); if (!key) @@ -570,13 +570,13 @@ std::optional RFile::GetKeyInfo(std::string_view p return keyInfo; } -void *ROOT::Experimental::Internal::RFile_GetObjectFromKey(RFile &file, const RKeyInfo &key) +void *ROOT::Internal::RFile_GetObjectFromKey(RFile &file, const RKeyInfo &key) { void *obj = file.GetUntyped(key.GetPath(), key.GetClassName().c_str()); return obj; } -TFile *ROOT::Experimental::Internal::GetRFileTFile(RFile &file) +TFile *ROOT::Internal::GetRFileTFile(RFile &file) { return file.fFile.get(); } diff --git a/io/io/test/rfile.cxx b/io/io/test/rfile.cxx index 0bd70c8aeeede..48dc835a9a283 100644 --- a/io/io/test/rfile.cxx +++ b/io/io/test/rfile.cxx @@ -18,10 +18,10 @@ #include "RFileTestIncludes.hxx" -using ROOT::Experimental::RFile; +using ROOT::RFile; using ROOT::TestSupport::FileRaii; -static std::string JoinKeyNames(const ROOT::Experimental::RFileKeyIterable &iterable) +static std::string JoinKeyNames(const ROOT::RFileKeyIterable &iterable) { auto beg = iterable.begin(); if (beg == iterable.end()) @@ -32,7 +32,7 @@ static std::string JoinKeyNames(const ROOT::Experimental::RFileKeyIterable &iter TEST(RFile, DecomposePath) { - using ROOT::Experimental::Detail::DecomposePath; + using ROOT::Detail::DecomposePath; auto Pair = [](std::string_view a, std::string_view b) { return std::make_pair(a, b); }; @@ -648,7 +648,7 @@ TEST(RFile, GetAfterOverwriteNoBackup) auto ss = file->Get("s"); EXPECT_EQ(*ss, s); - std::vector keys; + std::vector keys; for (const auto &key : file->ListKeys()) keys.push_back(key); @@ -778,7 +778,7 @@ TEST(RFile, RNTuple) auto model = ROOT::RNTupleModel::Create(); *model->MakeField("x") = 42; - auto writer = ROOT::Experimental::RNTupleWriter_Append(std::move(model), "data", *file); + auto writer = ROOT::RNTupleWriter::Append(std::move(model), "data", *file); writer->Fill(); } @@ -808,7 +808,7 @@ TEST(RFile, TTreeRead) } { - auto file = ROOT::Experimental::RFile::Open(fileGuard.GetPath()); + auto file = ROOT::RFile::Open(fileGuard.GetPath()); auto tree = file->Get("tree"); ASSERT_NE(tree, nullptr); EXPECT_EQ(tree->GetEntries(), 10); @@ -838,7 +838,7 @@ TEST(RFile, TTreeReadAfterClose) } { - auto file = ROOT::Experimental::RFile::Open(fileGuard.GetPath()); + auto file = ROOT::RFile::Open(fileGuard.GetPath()); auto tree = file->Get("tree"); file.reset(); // close the file ASSERT_NE(tree, nullptr); @@ -867,7 +867,7 @@ TEST(RFile, TTreeNoDoubleFree) EXPECT_EQ(TTreeDestructorCounter::GetTimesDestructed(), 1); { - auto file = ROOT::Experimental::RFile::Open(fileGuard.GetPath()); + auto file = ROOT::RFile::Open(fileGuard.GetPath()); auto tree = file->Get("tree"); file.reset(); // close the file (does not delete the three) // tree is deleted here diff --git a/io/io/test/rfile.py b/io/io/test/rfile.py index 30d78872665b1..992288befce56 100644 --- a/io/io/test/rfile.py +++ b/io/io/test/rfile.py @@ -4,8 +4,6 @@ import ROOT -RFile = ROOT.Experimental.RFile - class RFileTests(unittest.TestCase): def test_open_for_reading(self): @@ -19,7 +17,7 @@ def test_open_for_reading(self): hist.FillRandom("gaus", 100) tfile.WriteObject(hist, "hist") - with RFile.Open(fileName) as rfile: + with ROOT.RFile.Open(fileName) as rfile: hist = rfile.Get("hist") self.assertNotEqual(hist, None) self.assertEqual(rfile.Get[ROOT.TH1D]("inexistent"), None) @@ -39,7 +37,7 @@ def test_writing_reading(self): fileName = "test_rfile_writeread_py.root" try: - with RFile.Recreate(fileName) as rfile: + with ROOT.RFile.Recreate(fileName) as rfile: hist = ROOT.TH1D("hist", "", 100, -10, 10) hist.FillRandom("gaus", 10) rfile.Put("hist", hist) @@ -48,7 +46,7 @@ def test_writing_reading(self): with self.assertRaises(ROOT.RException): rfile.Put("hist/2", hist) - with RFile.Open(fileName) as rfile: + with ROOT.RFile.Open(fileName) as rfile: hist = rfile.Get("hist") self.assertNotEqual(hist, None) @@ -60,7 +58,7 @@ def test_getkeyinfo(self): fileName = "test_rfile_getkeyinfo_py.root" try: - with RFile.Recreate(fileName) as rfile: + with ROOT.RFile.Recreate(fileName) as rfile: hist = ROOT.TH1D("hist", "", 100, -10, 10) hist.FillRandom("gaus", 10) rfile.Put("hist", hist) @@ -69,7 +67,7 @@ def test_getkeyinfo(self): rfile.Put("foo/bar/hist2", hist) rfile.Put("foo/hist2", hist) - with RFile.Open(fileName) as rfile: + with ROOT.RFile.Open(fileName) as rfile: key = rfile.GetKeyInfo("hist") self.assertEqual(key.GetPath(), "hist") self.assertEqual(key.GetClassName(), "TH1D") @@ -85,7 +83,7 @@ def test_listkeys(self): fileName = "test_rfile_listkeys_py.root" try: - with RFile.Recreate(fileName) as rfile: + with ROOT.RFile.Recreate(fileName) as rfile: hist = ROOT.TH1D("hist", "", 100, -10, 10) hist.FillRandom("gaus", 10) rfile.Put("hist", hist) @@ -94,7 +92,7 @@ def test_listkeys(self): rfile.Put("foo/bar/hist2", hist) rfile.Put("foo/hist2", hist) - with RFile.Open(fileName) as rfile: + with ROOT.RFile.Open(fileName) as rfile: keys = [key.GetPath() for key in rfile.ListKeys()] self.assertEqual(keys, ["hist", "foo/hist", "foo/bar/hist", "foo/bar/hist2", "foo/hist2"]) @@ -128,7 +126,7 @@ def test_listkeys(self): def test_putUnsupportedType(self): fileName = "test_rfile_putunsupported_py.root" try: - with RFile.Recreate(fileName) as rfile: + with ROOT.RFile.Recreate(fileName) as rfile: # Storing integers is unsupported with self.assertRaises(TypeError): rfile.Put("foo", 2) @@ -143,7 +141,7 @@ def test_putUnsupportedType(self): # Storing strings is supported rfile.Put("str", "foobar") - with RFile.Open(fileName) as rfile: + with ROOT.RFile.Open(fileName) as rfile: self.assertEqual(rfile.Get("str"), b"foobar") finally: os.remove(fileName) @@ -162,7 +160,7 @@ def test_getTree(self): tree.Fill() tree.Write() - with RFile.Open(fileName) as rfile: + with ROOT.RFile.Open(fileName) as rfile: tree = rfile.Get("tree") self.assertIsNot(tree, None) self.assertEqual(tree.GetEntries(), 10) diff --git a/tree/ntuple/inc/ROOT/RMiniFile.hxx b/tree/ntuple/inc/ROOT/RMiniFile.hxx index 3ecec64f83059..f61f2004e008b 100644 --- a/tree/ntuple/inc/ROOT/RMiniFile.hxx +++ b/tree/ntuple/inc/ROOT/RMiniFile.hxx @@ -33,13 +33,8 @@ class TVirtualStreamerInfo; namespace ROOT { class RNTupleWriteOptions; - -namespace Experimental { - class RFile; -} - namespace Internal { class RRawFile; @@ -139,7 +134,7 @@ private: }; struct RImplRFile { - ROOT::Experimental::RFile *fFile = nullptr; + ROOT::RFile *fFile = nullptr; std::string fDir; /// Low-level writing using a TFile void Write(const void *buffer, size_t nbytes, std::int64_t offset); @@ -273,8 +268,8 @@ public: static std::unique_ptr Append(std::string_view ntupleName, TDirectory &fileOrDirectory, std::uint64_t maxKeySize, bool isHidden); - static std::unique_ptr Append(std::string_view ntupleName, ROOT::Experimental::RFile &file, - std::string_view dirPath, std::uint64_t maxKeySize); + static std::unique_ptr + Append(std::string_view ntupleName, ROOT::RFile &file, std::string_view dirPath, std::uint64_t maxKeySize); RNTupleFileWriter(const RNTupleFileWriter &other) = delete; RNTupleFileWriter(RNTupleFileWriter &&other) = delete; diff --git a/tree/ntuple/inc/ROOT/RNTupleWriter.hxx b/tree/ntuple/inc/ROOT/RNTupleWriter.hxx index fef31b7304684..321a2a0116153 100644 --- a/tree/ntuple/inc/ROOT/RNTupleWriter.hxx +++ b/tree/ntuple/inc/ROOT/RNTupleWriter.hxx @@ -35,22 +35,11 @@ class TDirectory; namespace ROOT { class RNTupleWriteOptions; +class RFile; namespace Experimental { class RNTupleAttrSetWriterHandle; -class RFile; -/// Creates an RNTupleWriter that writes into the given `file`, appending to it. The RNTuple is written under the -/// path `ntuplePath`. -/// `ntuplePath` may have the form `"path/to/ntuple"`, in which case the ntuple's name will be `"ntuple"` and it will -/// be stored under the given `ntuplePath` in the RFile. -/// Throws an exception if the model is null. -/// NOTE: this is a temporary, experimental API that will be replaced by an overload of RNTupleWriter::Append in the -/// future. -std::unique_ptr -RNTupleWriter_Append(std::unique_ptr model, std::string_view ntuplePath, - ROOT::Experimental::RFile &file, - const ROOT::RNTupleWriteOptions &options = ROOT::RNTupleWriteOptions()); } // namespace Experimental namespace Internal { @@ -118,9 +107,6 @@ class RNTupleWriter { friend ROOT::RNTupleModel::RUpdater; friend std::unique_ptr Internal::CreateRNTupleWriter(std::unique_ptr, std::unique_ptr); - friend std::unique_ptr - Experimental::RNTupleWriter_Append(std::unique_ptr model, std::string_view ntuplePath, - ROOT::Experimental::RFile &file, const ROOT::RNTupleWriteOptions &options); private: RNTupleFillContext fFillContext; @@ -176,6 +162,15 @@ public: TDirectory &fileOrDirectory, const ROOT::RNTupleWriteOptions &options = ROOT::RNTupleWriteOptions()); + /// Creates an RNTupleWriter that writes into the given `file`, appending to it. The RNTuple is written under the + /// path `ntuplePath`. + /// `ntuplePath` may have the form `"path/to/ntuple"`, in which case the ntuple's name will be `"ntuple"` and it will + /// be stored under the given `ntuplePath` in the RFile. + /// Throws an exception if the model is null. + static std::unique_ptr Append(std::unique_ptr model, std::string_view ntupleName, + ROOT::RFile &file, + const ROOT::RNTupleWriteOptions &options = ROOT::RNTupleWriteOptions()); + RNTupleWriter(const RNTupleWriter &) = delete; RNTupleWriter &operator=(const RNTupleWriter &) = delete; RNTupleWriter(RNTupleWriter &&) = delete; diff --git a/tree/ntuple/inc/ROOT/RPageStorageFile.hxx b/tree/ntuple/inc/ROOT/RPageStorageFile.hxx index 38b4aa7905aa9..a0a9926f7ae41 100644 --- a/tree/ntuple/inc/ROOT/RPageStorageFile.hxx +++ b/tree/ntuple/inc/ROOT/RPageStorageFile.hxx @@ -34,10 +34,7 @@ class TDirectory; namespace ROOT { class RNTuple; // for making RPageSourceFile a friend of RNTuple class RNTupleLocator; - -namespace Experimental { class RFile; -} namespace Internal { class RRawFile; @@ -102,7 +99,7 @@ protected: public: RPageSinkFile(std::string_view ntupleName, std::string_view path, const ROOT::RNTupleWriteOptions &options); RPageSinkFile(std::string_view ntupleName, TDirectory &fileOrDirectory, const ROOT::RNTupleWriteOptions &options); - RPageSinkFile(std::string_view ntupleName, ROOT::Experimental::RFile &file, std::string_view ntupleDir, + RPageSinkFile(std::string_view ntupleName, ROOT::RFile &file, std::string_view ntupleDir, const ROOT::RNTupleWriteOptions &options); RPageSinkFile(const RPageSinkFile &) = delete; RPageSinkFile &operator=(const RPageSinkFile &) = delete; diff --git a/tree/ntuple/src/RMiniFile.cxx b/tree/ntuple/src/RMiniFile.cxx index c5a89d2deab22..243f939b4bf57 100644 --- a/tree/ntuple/src/RMiniFile.cxx +++ b/tree/ntuple/src/RMiniFile.cxx @@ -1218,7 +1218,7 @@ std::uint64_t ROOT::Internal::RNTupleFileWriter::RImplTFile::ReserveBlobKey(size void ROOT::Internal::RNTupleFileWriter::RImplRFile::Write(const void *buffer, size_t nbytes, std::int64_t offset) { - auto *file = ROOT::Experimental::Internal::GetRFileTFile(*fFile); + auto *file = ROOT::Internal::GetRFileTFile(*fFile); file->Seek(offset); bool rv = file->WriteBuffer((char *)(buffer), nbytes); if (rv) @@ -1228,7 +1228,7 @@ void ROOT::Internal::RNTupleFileWriter::RImplRFile::Write(const void *buffer, si std::uint64_t ROOT::Internal::RNTupleFileWriter::RImplRFile::ReserveBlobKey(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen]) { - auto *file = ROOT::Experimental::Internal::GetRFileTFile(*fFile); + auto *file = ROOT::Internal::GetRFileTFile(*fFile); auto offsetData = RNTupleFileWriter::ReserveBlobKey(*this, *file, nbytes, len, keyBuffer); return offsetData; } @@ -1319,8 +1319,8 @@ ROOT::Internal::RNTupleFileWriter::Append(std::string_view ntupleName, TDirector } std::unique_ptr -ROOT::Internal::RNTupleFileWriter::Append(std::string_view ntupleName, ROOT::Experimental::RFile &file, - std::string_view ntupleDir, std::uint64_t maxKeySize) +ROOT::Internal::RNTupleFileWriter::Append(std::string_view ntupleName, ROOT::RFile &file, std::string_view ntupleDir, + std::uint64_t maxKeySize) { auto writer = std::unique_ptr(new RNTupleFileWriter(ntupleName, maxKeySize, /*isHidden=*/false)); auto &rfile = writer->fFile.emplace(); @@ -1400,7 +1400,7 @@ ROOT::Internal::RNTupleLink ROOT::Internal::RNTupleFileWriter::Commit(int compre } else if (auto fileRFile = std::get_if(&fFile)) { // Same as the case above but handled via RFile fileRFile->fFile->Put(fileRFile->fDir + fNTupleName, fNTupleAnchor); - WriteStreamerInfoToFile(ROOT::Experimental::Internal::GetRFileTFile(*fileRFile->fFile)); + WriteStreamerInfoToFile(ROOT::Internal::GetRFileTFile(*fileRFile->fFile)); auto key = fileRFile->fFile->GetKeyInfo(fNTupleName); R__ASSERT(key); anchorInfo.fLocator.SetPosition(key->GetSeekKey() + key->GetNBytesKey()); diff --git a/tree/ntuple/src/RNTupleWriter.cxx b/tree/ntuple/src/RNTupleWriter.cxx index 2c320794a6e69..c66472939c2a2 100644 --- a/tree/ntuple/src/RNTupleWriter.cxx +++ b/tree/ntuple/src/RNTupleWriter.cxx @@ -163,11 +163,11 @@ ROOT::Internal::CreateRNTupleWriter(std::unique_ptr model, return std::unique_ptr(new ROOT::RNTupleWriter(std::move(model), std::move(sink))); } -std::unique_ptr -ROOT::Experimental::RNTupleWriter_Append(std::unique_ptr model, std::string_view ntupleName, - ROOT::Experimental::RFile &file, const ROOT::RNTupleWriteOptions &options) +std::unique_ptr ROOT::RNTupleWriter::Append(std::unique_ptr model, + std::string_view ntupleName, ROOT::RFile &file, + const ROOT::RNTupleWriteOptions &options) { - auto [ntupleDir, ntupleBasename] = ROOT::Experimental::Detail::DecomposePath(ntupleName); + auto [ntupleDir, ntupleBasename] = ROOT::Detail::DecomposePath(ntupleName); auto sink = std::make_unique(ntupleBasename, file, ntupleDir, options); return ROOT::RNTupleWriter::Create(std::move(model), std::move(sink), options); } diff --git a/tree/ntuple/src/RPageStorageFile.cxx b/tree/ntuple/src/RPageStorageFile.cxx index 7fdb8f4a400eb..64506d4da9c10 100644 --- a/tree/ntuple/src/RPageStorageFile.cxx +++ b/tree/ntuple/src/RPageStorageFile.cxx @@ -70,8 +70,8 @@ ROOT::Internal::RPageSinkFile::RPageSinkFile(std::string_view ntupleName, TDirec fWriter = RNTupleFileWriter::Append(ntupleName, fileOrDirectory, options.GetMaxKeySize(), /*isHidden=*/false); } -ROOT::Internal::RPageSinkFile::RPageSinkFile(std::string_view ntupleName, ROOT::Experimental::RFile &file, - std::string_view ntupleDir, const ROOT::RNTupleWriteOptions &options) +ROOT::Internal::RPageSinkFile::RPageSinkFile(std::string_view ntupleName, ROOT::RFile &file, std::string_view ntupleDir, + const ROOT::RNTupleWriteOptions &options) : RPageSinkFile(ntupleName, options) { fWriter = RNTupleFileWriter::Append(ntupleName, file, ntupleDir, options.GetMaxKeySize()); diff --git a/tutorials/CMakeLists.txt b/tutorials/CMakeLists.txt index b584e74307c0e..932b3de90b8ea 100644 --- a/tutorials/CMakeLists.txt +++ b/tutorials/CMakeLists.txt @@ -155,7 +155,7 @@ if (NOT dataframe) list(APPEND dataframe_veto io/ntuple/ntpl004_dimuon.C) list(APPEND dataframe_veto io/ntuple/ntpl008_import.C) # RFile tutorials depending on RDataFrame - list(APPEND dataframe_veto io/experimental/rfile/rfile003_ttree.C) + list(APPEND dataframe_veto io/rfile/rfile003_ttree.C) endif() if(NOT sqlite) diff --git a/tutorials/io/index.md b/tutorials/io/index.md index 1e91aa74ea1b3..ccca29e73c1e6 100644 --- a/tutorials/io/index.md +++ b/tutorials/io/index.md @@ -9,7 +9,7 @@ - [SQL](\ref tutorial_sql) - [XML](\ref tutorial_xml) - [Various I/O related topics](\ref miscl) -- [New experimental ROOT File interface](\ref rfile) +- [New ROOT File interface](\ref rfile) \anchor file ## ROOT File @@ -45,7 +45,7 @@ The following tutorials illustrate various useful ROOT I/O features. | | tfile_context_manager.py | Usage of TFile class as a Python context manager.| \anchor rfile -## New experimental ROOT file interface +## New ROOT file interface The following tutorials illustrate how to use RFile, the new interface to ROOT files. RFile is a simpler alternative to TFile that makes operations and object ownership explicit. | **Tutorial** | **Description** | diff --git a/tutorials/io/experimental/rfile/rfile001_basics.C b/tutorials/io/rfile/rfile001_basics.C similarity index 88% rename from tutorials/io/experimental/rfile/rfile001_basics.C rename to tutorials/io/rfile/rfile001_basics.C index a3ba9a2c95196..f2f3f07099630 100644 --- a/tutorials/io/experimental/rfile/rfile001_basics.C +++ b/tutorials/io/rfile/rfile001_basics.C @@ -5,9 +5,6 @@ /// \macro_code /// \macro_output /// -/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -/// is welcome! -/// /// \date 2025-11-06 /// \author Giacomo Parolini @@ -18,7 +15,7 @@ void write_hist_to_rfile(const char *fileName) hist.FillRandom("gaus", 1000); // Create a new ROOT file for writing - auto file = ROOT::Experimental::RFile::Recreate(fileName); + auto file = ROOT::RFile::Recreate(fileName); // Put objects into the file (in this case we write the same object multiple times // under different paths). Note that the ownership of `hist` is untouched by `file->Put`. @@ -33,7 +30,7 @@ void write_hist_to_rfile(const char *fileName) void read_hist_from_rfile(const char *fileName) { // Open an existing ROOT file for reading (will throw an exception if `fileName` cannot be read). - auto file = ROOT::Experimental::RFile::Open(fileName); + auto file = ROOT::RFile::Open(fileName); // Iterate all keys of all objects in the file (this excludes directories by default - see the documentation of // ListKeys() for all the options). for (auto key : file->ListKeys()) { diff --git a/tutorials/io/experimental/rfile/rfile001_basics.py b/tutorials/io/rfile/rfile001_basics.py similarity index 88% rename from tutorials/io/experimental/rfile/rfile001_basics.py rename to tutorials/io/rfile/rfile001_basics.py index 779ce3a51f5ac..21a8748085639 100644 --- a/tutorials/io/experimental/rfile/rfile001_basics.py +++ b/tutorials/io/rfile/rfile001_basics.py @@ -5,9 +5,6 @@ # \macro_code # \macro_output # -# \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -# is welcome! -# # \date 2025-11-06 # \author Giacomo Parolini @@ -22,7 +19,7 @@ def write_hist_to_rfile(fileName): hist.FillRandom("gaus", 1000) # Create a new ROOT file for writing - with ROOT.Experimental.RFile.Recreate(fileName) as file: + with ROOT.RFile.Recreate(fileName) as file: # Put objects into the file (in this case we write the same object multiple times # under different paths). Note that the ownership of `hist` is untouched by `file.Put`. file.Put(hist.GetName(), hist) @@ -35,7 +32,7 @@ def write_hist_to_rfile(fileName): def read_hist_from_rfile(fileName): # Open an existing ROOT file for reading (will raise an exception if `fileName` cannot be read). - with ROOT.Experimental.RFile.Open(fileName) as file: + with ROOT.RFile.Open(fileName) as file: # Iterate all keys of all objects in the file (this excludes directories by default - see the documentation of # ListKeys() for all the options). for key in file.ListKeys(): diff --git a/tutorials/io/experimental/rfile/rfile002_rntuple.C b/tutorials/io/rfile/rfile002_rntuple.C similarity index 81% rename from tutorials/io/experimental/rfile/rfile002_rntuple.C rename to tutorials/io/rfile/rfile002_rntuple.C index f0c61fba7618c..861baf0b33f26 100644 --- a/tutorials/io/experimental/rfile/rfile002_rntuple.C +++ b/tutorials/io/rfile/rfile002_rntuple.C @@ -5,23 +5,20 @@ /// \macro_code /// \macro_output /// -/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -/// is welcome! -/// /// \date 2026-10-12 /// \author Giacomo Parolini void write_rntuple_to_rfile(const char *fileName) { // Create a new ROOT file for writing - auto file = ROOT::Experimental::RFile::Recreate(fileName); + auto file = ROOT::RFile::Recreate(fileName); // Define the RNTuple schema auto model = ROOT::RNTupleModel::Create(); auto pInt = model->MakeField("intField"); // Create an RNTupleWriter to append to the RFile - auto writer = ROOT::Experimental::RNTupleWriter_Append(std::move(model), "ntuple", *file); + auto writer = ROOT::RNTupleWriter::Append(std::move(model), "ntuple", *file); // Fill the RNTuple with data for (int i = 0; i < 10; ++i) { @@ -35,7 +32,7 @@ void write_rntuple_to_rfile(const char *fileName) void read_rntuple_from_rfile(const char *fileName) { // Open an existing ROOT file for reading (will throw an exception if `fileName` cannot be read). - auto file = ROOT::Experimental::RFile::Open(fileName); + auto file = ROOT::RFile::Open(fileName); // Get back the RNTuple anchor from the file auto rntuple = file->Get("ntuple"); diff --git a/tutorials/io/experimental/rfile/rfile002_rntuple.py b/tutorials/io/rfile/rfile002_rntuple.py similarity index 86% rename from tutorials/io/experimental/rfile/rfile002_rntuple.py rename to tutorials/io/rfile/rfile002_rntuple.py index f41df2827fc53..d5ab9a46e1a45 100644 --- a/tutorials/io/experimental/rfile/rfile002_rntuple.py +++ b/tutorials/io/rfile/rfile002_rntuple.py @@ -5,9 +5,6 @@ # \macro_code # \macro_output # -# \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -# is welcome! -# # \date 2026-10-12 # \author Giacomo Parolini @@ -18,7 +15,7 @@ def write_rntuple_to_rfile(fileName): # Create a new ROOT file for writing - with ROOT.Experimental.RFile.Recreate(fileName) as file: + with ROOT.RFile.Recreate(fileName) as file: # Define the RNTuple schema model = ROOT.RNTupleModel.Create() model.MakeField["int"]("intField") @@ -37,7 +34,7 @@ def write_rntuple_to_rfile(fileName): def read_rntuple_from_rfile(fileName): # Open an existing ROOT file for reading (will throw an exception if `fileName` cannot be read). - with ROOT.Experimental.RFile.Open(fileName) as file: + with ROOT.RFile.Open(fileName) as file: # Get back the RNTuple anchor from the file rntuple = file.Get("ntuple") diff --git a/tutorials/io/experimental/rfile/rfile003_ttree.C b/tutorials/io/rfile/rfile003_ttree.C similarity index 87% rename from tutorials/io/experimental/rfile/rfile003_ttree.C rename to tutorials/io/rfile/rfile003_ttree.C index d8b4c37816979..0127a1c3f2e81 100644 --- a/tutorials/io/experimental/rfile/rfile003_ttree.C +++ b/tutorials/io/rfile/rfile003_ttree.C @@ -8,9 +8,6 @@ /// \macro_code /// \macro_output /// -/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -/// is welcome! -/// /// \date 2026-10-12 /// \author Giacomo Parolini #include @@ -23,7 +20,7 @@ void read_tree_from_rfile(const char *fileName) { // Open an existing ROOT file for reading (will throw an exception if `fileName` cannot be read). // IMPORTANT! This file must remain open while reading data from the tree. - auto file = ROOT::Experimental::RFile::Open(fileName); + auto file = ROOT::RFile::Open(fileName); // Get back the TTree from the file auto tree = file->Get("tree"); diff --git a/tutorials/io/experimental/rfile/rfile003_ttree.py b/tutorials/io/rfile/rfile003_ttree.py similarity index 86% rename from tutorials/io/experimental/rfile/rfile003_ttree.py rename to tutorials/io/rfile/rfile003_ttree.py index e5dde167c773c..a90f0220b092e 100644 --- a/tutorials/io/experimental/rfile/rfile003_ttree.py +++ b/tutorials/io/rfile/rfile003_ttree.py @@ -8,9 +8,6 @@ # \macro_code # \macro_output # -# \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback -# is welcome! -# # \date 2026-10-12 # \author Giacomo Parolini @@ -23,7 +20,7 @@ def read_ttree_from_rfile(fileName): # Open an existing ROOT file for reading (will throw an exception if `fileName` cannot be read). # IMPORTANT! This file must remain open while reading data from the tree. - with ROOT.Experimental.RFile.Open(fileName) as file: + with ROOT.RFile.Open(fileName) as file: # Get back the TTree from the file tree = file.Get("tree") floatVal = array.array("f", [0])