-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ntuple] allow for writing into TFile subdir (WIP) #16838
base: master
Are you sure you want to change the base?
Conversation
Test Results 17 files 17 suites 3d 17h 29m 37s ⏱️ Results for commit 535f543. |
@@ -1124,7 +1139,9 @@ void ROOT::Experimental::Internal::RNTupleFileWriter::Commit() | |||
{ | |||
if (fFileProper) { | |||
// Easy case, the ROOT file header and the RNTuple streaming is taken care of by TFile | |||
fFileProper.fFile->WriteObject(&fNTupleAnchor, fNTupleName.c_str()); | |||
auto dir = fFileProper.fFile->GetDirectory(fFileProper.fDirectory.c_str()); | |||
dir->cd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A priori the cd
is not needed. If it is then we need to use also a TDirectory::TContext
to make the function have no net effect on gDirectory
.
std::unique_ptr<ROOT::Experimental::Internal::RNTupleFileWriter> | ||
ROOT::Experimental::Internal::RNTupleFileWriter::Append(std::string_view ntupleName, TFile &file, | ||
std::uint64_t maxKeySize) | ||
{ | ||
auto writer = std::unique_ptr<RNTupleFileWriter>(new RNTupleFileWriter(ntupleName, maxKeySize)); | ||
auto [dir, name] = SplitNTupleName(ntupleName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that it would also be nice to have:
ROOT::Experimental::Internal::RNTupleFileWriter::Append(std::string_view ntupleName, TDIrectory &dir,
std::uint64_t maxKeySize)
{
if (!dir.GetFile())
throw "We need a file";
auto writer = std::unique_ptr<RNTupleFileWriter>(new RNTupleFileWriter(name, maxKeySize));
writer->fFileProper.fFile = dir->GetFile();
writer->fFileProper.fDirectory = &dir;
(oups the type of fDirectory
is wrong).
@@ -104,6 +104,7 @@ class RNTupleFileWriter { | |||
private: | |||
struct RFileProper { | |||
TFile *fFile = nullptr; | |||
std::string fDirectory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either
std::string fDirectory; | |
TDirectory* fDirectory; |
or
std::string fDirectory; | |
std::string fDirectoryPath; |
Work in progress.
With the patch,
RNTupleWriter::Append()
can process a directory and a name like "subdir/ntpl". On the reading side, if the RNTupleReader uses the anchor directly, reading already works.Fixes #14007