-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1105,12 +1105,27 @@ ROOT::Experimental::Internal::RNTupleFileWriter::Recreate(std::string_view ntupl | |
return writer; | ||
} | ||
|
||
std::pair<std::string_view, std::string_view> ROOT::Experimental::Internal::RNTupleFileWriter::SplitNTupleName( | ||
std::string_view nameAndDir) | ||
{ | ||
const auto posLastSlash = nameAndDir.find_last_of('/'); | ||
if (posLastSlash == std::string::npos) | ||
return std::make_pair("", nameAndDir); | ||
|
||
if (posLastSlash == nameAndDir.size() - 1) | ||
throw RException(R__FAIL("empty RNTuple name")); | ||
|
||
return std::make_pair(nameAndDir.substr(0, posLastSlash), nameAndDir.substr(posLastSlash + 1)); | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Note that it would also be nice to have:
(oups the type of |
||
auto writer = std::unique_ptr<RNTupleFileWriter>(new RNTupleFileWriter(name, maxKeySize)); | ||
writer->fFileProper.fFile = &file; | ||
writer->fFileProper.fDirectory = dir; | ||
return writer; | ||
} | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. A priori the |
||
dir->WriteObject(&fNTupleAnchor, fNTupleName.c_str()); | ||
|
||
// Make sure the streamer info records used in the RNTuple are written to the file | ||
TBufferFile buf(TBuffer::kWrite); | ||
|
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
or