Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions tree/dataframe/src/RDFSnapshotHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void EnsureValidSnapshotOutput(const ROOT::RDF::RSnapshotOptions &opts, const st
return;

// output file opened in "update" mode: must check whether target object name is already present in file
std::unique_ptr<TFile> outFile{TFile::Open(fileName.c_str(), "update")};
std::unique_ptr<TFile> outFile{TFile::Open(fileName.c_str(), "UPDATE_WITHOUT_GLOBALREGISTRATION")};
if (!outFile || outFile->IsZombie())
throw std::invalid_argument("Snapshot: cannot open file \"" + fileName + "\" in update mode");

Expand Down Expand Up @@ -338,6 +338,15 @@ auto GetSnapshotCompressionSettings(const ROOT::RDF::RSnapshotOptions &options)
throw std::invalid_argument("RDataFrame::Snapshot: unrecognized output format");
}
}

std::string ModeWithoutGlobalRegistration(const std::string &mode)
{
if (mode.find("_WITHOUT_GLOBALREGISTRATION") != std::string::npos) {
return mode;
}
return mode + "_WITHOUT_GLOBALREGISTRATION";
}

} // namespace

ROOT::Internal::RDF::RBranchData::RBranchData(std::string inputBranchName, std::string outputBranchName, bool isDefine,
Expand Down Expand Up @@ -508,8 +517,8 @@ void ROOT::Internal::RDF::UntypedSnapshotTTreeHelper::SetEmptyBranches(TTree *in

void ROOT::Internal::RDF::UntypedSnapshotTTreeHelper::Initialize()
{
fOutputFile.reset(
TFile::Open(fFileName.c_str(), fOptions.fMode.c_str(), /*ftitle=*/"", GetSnapshotCompressionSettings(fOptions)));
fOutputFile.reset(TFile::Open(fFileName.c_str(), ModeWithoutGlobalRegistration(fOptions.fMode).c_str(),
/*ftitle=*/"", GetSnapshotCompressionSettings(fOptions)));
if (!fOutputFile)
throw std::runtime_error("Snapshot: could not create output file " + fFileName);

Expand Down Expand Up @@ -748,8 +757,8 @@ void ROOT::Internal::RDF::UntypedSnapshotTTreeHelperMT::SetEmptyBranches(TTree *
void ROOT::Internal::RDF::UntypedSnapshotTTreeHelperMT::Initialize()
{
auto outFile =
std::unique_ptr<TFile>{TFile::Open(fFileName.c_str(), fOptions.fMode.c_str(), /*ftitle=*/fFileName.c_str(),
GetSnapshotCompressionSettings(fOptions))};
std::unique_ptr<TFile>{TFile::Open(fFileName.c_str(), ModeWithoutGlobalRegistration(fOptions.fMode).c_str(),
/*ftitle=*/fFileName.c_str(), GetSnapshotCompressionSettings(fOptions))};
if (!outFile)
throw std::runtime_error("Snapshot: could not create output file " + fFileName);
fOutputFile = outFile.get();
Expand Down Expand Up @@ -911,7 +920,7 @@ void ROOT::Internal::RDF::UntypedSnapshotRNTupleHelper::Initialize()
writeOptions.SetEnablePageChecksums(fOptions.fEnablePageChecksums);
writeOptions.SetEnableSamePageMerging(fOptions.fEnableSamePageMerging);

fOutputFile.reset(TFile::Open(fFileName.c_str(), fOptions.fMode.c_str()));
fOutputFile.reset(TFile::Open(fFileName.c_str(), ModeWithoutGlobalRegistration(fOptions.fMode).c_str()));
if (!fOutputFile)
throw std::runtime_error("Snapshot: could not create output file " + fFileName);

Expand Down Expand Up @@ -1125,7 +1134,8 @@ ROOT::Internal::RDF::SnapshotHelperWithVariations::SnapshotHelperWithVariations(

TDirectory::TContext fileCtxt;
fOutputHandle = std::make_shared<SnapshotOutputWriter>(
TFile::Open(filename.data(), fOptions.fMode.c_str(), /*ftitle=*/"", GetSnapshotCompressionSettings(fOptions)));
TFile::Open(filename.data(), ModeWithoutGlobalRegistration(fOptions.fMode).c_str(), /*ftitle=*/"",
GetSnapshotCompressionSettings(fOptions)));
if (!fOutputHandle->fFile)
throw std::runtime_error(std::string{"Snapshot: could not create output file "} + std::string{filename});

Expand Down
Loading