Warning, file /include/root/TFileMerger.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TFileMerger
0013 #define ROOT_TFileMerger
0014
0015 #include "TObject.h"
0016 #include "TList.h"
0017 #include "TString.h"
0018 #include "TStopwatch.h"
0019 #include <string>
0020
0021 class TFile;
0022 class TDirectory;
0023 class THashList;
0024 class TKey;
0025
0026 namespace ROOT {
0027 class TIOFeatures;
0028 }
0029
0030 class TFileMerger : public TObject {
0031 private:
0032 using TIOFeatures = ROOT::TIOFeatures;
0033
0034 TFileMerger(const TFileMerger&) = delete;
0035 TFileMerger& operator=(const TFileMerger&) = delete;
0036
0037 protected:
0038 TStopwatch fWatch;
0039 TList fFileList;
0040 TFile *fOutputFile{nullptr};
0041 TString fOutputFilename;
0042 Bool_t fFastMethod{kTRUE};
0043 Bool_t fNoTrees{kFALSE};
0044 Bool_t fExplicitCompLevel{kFALSE};
0045 Bool_t fCompressionChange{kFALSE};
0046 Int_t fPrintLevel{0};
0047 TString fMergeOptions;
0048 TIOFeatures *fIOFeatures{nullptr};
0049 TString fMsgPrefix{"TFileMerger"};
0050
0051 Int_t fMaxOpenedFiles;
0052 Bool_t fLocal;
0053 Bool_t fHistoOneGo;
0054 TString fObjectNames;
0055 TList fMergeList;
0056 TList fExcessFiles;
0057
0058 Bool_t OpenExcessFiles();
0059 virtual Bool_t AddFile(TFile *source, Bool_t own, Bool_t cpProgress);
0060 virtual Bool_t MergeRecursive(TDirectory *target, TList *sourcelist, Int_t type = kRegular | kAll);
0061
0062 virtual Bool_t MergeOne(TDirectory *target, TList *sourcelist, Int_t type,
0063 TFileMergeInfo &info, TString &oldkeyname, THashList &allNames, Bool_t &status, Bool_t &onlyListed,
0064 const TString &path,
0065 TDirectory *current_sourcedir, TFile *current_file,
0066 TKey *key, TObject *obj, TIter &nextkey);
0067 public:
0068
0069 enum EPartialMergeType {
0070 kRegular = 0,
0071 kIncremental = BIT(1),
0072 kResetable = BIT(2),
0073 kNonResetable = BIT(3),
0074 kDelayWrite = BIT(4),
0075
0076 kAll = BIT(2)|BIT(3),
0077 kAllIncremental = kIncremental | kAll,
0078
0079 kOnlyListed = BIT(5),
0080 kSkipListed = BIT(6),
0081 kKeepCompression= BIT(7)
0082 };
0083
0084 TFileMerger(Bool_t isLocal = kTRUE, Bool_t histoOneGo = kTRUE);
0085 ~TFileMerger() override;
0086
0087 Int_t GetPrintLevel() const { return fPrintLevel; }
0088 void SetPrintLevel(Int_t level) { fPrintLevel = level; }
0089 Bool_t HasCompressionChange() const { return fCompressionChange; }
0090 const char *GetOutputFileName() const { return fOutputFilename; }
0091 TList *GetMergeList() { return &fMergeList; }
0092 TFile *GetOutputFile() const { return fOutputFile; }
0093 Int_t GetMaxOpenedFiles() const { return fMaxOpenedFiles; }
0094 void SetMaxOpenedFiles(Int_t newmax);
0095 const char *GetMsgPrefix() const { return fMsgPrefix; }
0096 void SetMsgPrefix(const char *prefix);
0097 const char *GetMergeOptions() { return fMergeOptions; }
0098 void SetMergeOptions(const TString &options) { fMergeOptions = options; }
0099 void SetMergeOptions(const std::string_view &options) { fMergeOptions = options; }
0100 void SetIOFeatures(ROOT::TIOFeatures &features) { fIOFeatures = &features; }
0101 void AddObjectNames(const char *name) {fObjectNames += name; fObjectNames += " ";}
0102 const char *GetObjectNames() const {return fObjectNames.Data();}
0103 void ClearObjectNames() {fObjectNames.Clear();}
0104
0105
0106 virtual Bool_t SetCWD(const char * ) { MayNotUse("SetCWD"); return kFALSE; }
0107 virtual const char *GetCWD() { MayNotUse("GetCWD"); return nullptr; }
0108
0109
0110 virtual void Reset();
0111 virtual Bool_t AddFile(const char *url, Bool_t cpProgress = kTRUE);
0112 virtual Bool_t AddFile(TFile *source, Bool_t cpProgress = kTRUE);
0113 virtual Bool_t AddAdoptFile(TFile *source, Bool_t cpProgress = kTRUE);
0114 virtual Bool_t OutputFile(const char *url, Bool_t force);
0115 virtual Bool_t OutputFile(const char *url, Bool_t force, Int_t compressionLevel);
0116 virtual Bool_t OutputFile(const char *url, const char *mode = "RECREATE");
0117 virtual Bool_t OutputFile(const char *url, const char *mode, Int_t compressionLevel);
0118 virtual Bool_t OutputFile(std::unique_ptr<TFile> file);
0119 virtual void PrintFiles(Option_t *options);
0120 virtual Bool_t Merge(Bool_t = kTRUE);
0121 virtual Bool_t PartialMerge(Int_t type = kAll | kIncremental);
0122 virtual void SetFastMethod(Bool_t fast=kTRUE) {fFastMethod = fast;}
0123 Bool_t GetNotrees() const { return fNoTrees; }
0124 virtual void SetNotrees(Bool_t notrees=kFALSE) {fNoTrees = notrees;}
0125 void RecursiveRemove(TObject *obj) override;
0126
0127 ClassDefOverride(TFileMerger, 6)
0128 };
0129
0130 #endif
0131