From 06f6f863821909d189511e48324aab3df139e30e Mon Sep 17 00:00:00 2001 From: Philippe Canal <pcanal@fnal.gov> Date: Fri, 12 Feb 2021 10:44:07 -0600 Subject: [PATCH] TBufferMerger: Allow to disable explict call to Flush when no tree in file --- io/io/inc/ROOT/TBufferMerger.hxx | 14 ++++++++++++++ io/io/inc/TFileMerger.h | 1 + io/io/src/TBufferMergerFile.cxx | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/io/io/inc/ROOT/TBufferMerger.hxx b/io/io/inc/ROOT/TBufferMerger.hxx index 1746c54e664..9440d25d9ca 100644 --- a/io/io/inc/ROOT/TBufferMerger.hxx +++ b/io/io/inc/ROOT/TBufferMerger.hxx @@ -96,6 +96,20 @@ public: */ void SetMergeOptions(const TString& options); + /** Indicates that the file will not contain any TTree objects + * and thus that steps that are specific to TTree can be skipped */ + void SetNotrees(Bool_t notrees=kFALSE) + { + fMerger.SetNotrees(notrees); + } + + /** Returns whether the the file has been marked as not containing any TTree objects + * and thus that steps that are specific to TTree can be skipped */ + Bool_t GetNotrees() const + { + return fMerger.GetNotrees(); + } + friend class TBufferMergerFile; private: diff --git a/io/io/inc/TFileMerger.h b/io/io/inc/TFileMerger.h index c2d4e6414e8..85959ed44a3 100644 --- a/io/io/inc/TFileMerger.h +++ b/io/io/inc/TFileMerger.h @@ -122,6 +122,7 @@ public: virtual Bool_t Merge(Bool_t = kTRUE); virtual Bool_t PartialMerge(Int_t type = kAll | kIncremental); virtual void SetFastMethod(Bool_t fast=kTRUE) {fFastMethod = fast;} + Bool_t GetNotrees() const { return fNoTrees; } virtual void SetNotrees(Bool_t notrees=kFALSE) {fNoTrees = notrees;} virtual void RecursiveRemove(TObject *obj); diff --git a/io/io/src/TBufferMergerFile.cxx b/io/io/src/TBufferMergerFile.cxx index 634fa8a5064..9c09d081b11 100644 --- a/io/io/src/TBufferMergerFile.cxx +++ b/io/io/src/TBufferMergerFile.cxx @@ -31,7 +31,8 @@ Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize) { // Make sure the compression of the basket is done in the unlocked thread and // not in the locked section. - TMemFile::Write(name, opt | TObject::kOnlyPrepStep, bufsize); + if (!fMerger.GetNotrees()) + TMemFile::Write(name, opt | TObject::kOnlyPrepStep, bufsize); // Instead of Writing the TTree, doing a memcpy, Pushing to the queue // then Reading and then deleting, let's see if we can just merge using -- GitLab