ROOT 6.16/01 Reference Guide |
TBufferMerger is a class to facilitate writing data in parallel from multiple threads, while writing to a single output file.
A TBufferMergerFile is similar to a TMemFile, but when data is written to it, it is appended to the TBufferMerger queue.
Its purpose is similar to TParallelMergingFile, but instead of using processes that connect to a network socket, TBufferMerger uses threads that each write to a TBufferMergerFile, which in turn push data into a queue managed by the TBufferMerger.
The TBufferMerger merges all data into the output file on disk.
Definition at line 41 of file TBufferMerger.hxx.
Public Member Functions | |
TBufferMerger (const char *name, Option_t *option="RECREATE", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose) | |
Constructor. More... | |
TBufferMerger (std::unique_ptr< TFile > output) | |
Constructor. More... | |
virtual | ~TBufferMerger () |
Destructor. More... | |
size_t | GetAutoSave () const |
Returns the current value of the auto save setting in bytes (default = 0). More... | |
std::shared_ptr< TBufferMergerFile > | GetFile () |
Returns a TBufferMergerFile to which data can be written. More... | |
size_t | GetQueueSize () const |
Returns the number of buffers currently in the queue. More... | |
void | SetAutoSave (size_t size) |
By default, TBufferMerger will call TFileMerger::PartialMerge() for each buffer pushed onto its merge queue. More... | |
Private Member Functions | |
TBufferMerger () | |
TBufferMerger has no default constructor. More... | |
TBufferMerger (const TBufferMerger &) | |
TBufferMerger has no copy constructor. More... | |
void | Init (std::unique_ptr< TFile >) |
void | Merge () |
TBufferMerger & | operator= (const TBufferMerger &) |
TBufferMerger has no copy operator. More... | |
void | Push (TBufferFile *buffer) |
Private Attributes | |
std::vector< std::weak_ptr< TBufferMergerFile > > | fAttachedFiles |
size_t | fAutoSave {0} |
size_t | fBuffered {0} |
std::mutex | fMergeMutex |
TFileMerger | fMerger {false, false} |
std::queue< TBufferFile * > | fQueue |
std::mutex | fQueueMutex |
Friends | |
class | TBufferMergerFile |
#include <ROOT/TBufferMerger.hxx>
ROOT::Experimental::TBufferMerger::TBufferMerger | ( | const char * | name, |
Option_t * | option = "RECREATE" , |
||
Int_t | compress = ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose |
||
) |
Constructor.
name | Output file name |
option | Output file creation options |
compression | Output file compression level |
Definition at line 24 of file TBufferMerger.cxx.
ROOT::Experimental::TBufferMerger::TBufferMerger | ( | std::unique_ptr< TFile > | output | ) |
|
virtual |
Destructor.
Definition at line 45 of file TBufferMerger.cxx.
|
private |
TBufferMerger has no default constructor.
|
private |
TBufferMerger has no copy constructor.
size_t ROOT::Experimental::TBufferMerger::GetAutoSave | ( | ) | const |
Returns the current value of the auto save setting in bytes (default = 0).
Definition at line 80 of file TBufferMerger.cxx.
std::shared_ptr< TBufferMergerFile > ROOT::Experimental::TBufferMerger::GetFile | ( | ) |
Returns a TBufferMergerFile to which data can be written.
At the end, all TBufferMergerFiles get merged into the output file. The user is responsible to "cd" into the file to associate objects such as histograms or trees to it.
After the creation of this file, the user must reset the kMustCleanup bit on any objects attached to it and take care of their deletion, as there is a possibility that a race condition will happen that causes a crash if ROOT manages these objects.
Definition at line 54 of file TBufferMerger.cxx.
size_t ROOT::Experimental::TBufferMerger::GetQueueSize | ( | ) | const |
Returns the number of buffers currently in the queue.
Definition at line 63 of file TBufferMerger.cxx.
Definition at line 37 of file TBufferMerger.cxx.
|
private |
Definition at line 90 of file TBufferMerger.cxx.
|
private |
TBufferMerger has no copy operator.
|
private |
Definition at line 68 of file TBufferMerger.cxx.
void ROOT::Experimental::TBufferMerger::SetAutoSave | ( | size_t | size | ) |
By default, TBufferMerger will call TFileMerger::PartialMerge() for each buffer pushed onto its merge queue.
This function lets the user change this behaviour by telling TBufferMerger to accumulate at least size bytes in memory before performing a partial merge and flushing to disk. This can be useful to avoid an excessive amount of work to happen in the output thread, as the number of TTree headers (which require compression) written to disk can be reduced.
Definition at line 85 of file TBufferMerger.cxx.
|
friend |
Definition at line 86 of file TBufferMerger.hxx.
|
private |
Definition at line 109 of file TBufferMerger.hxx.
|
private |
Definition at line 103 of file TBufferMerger.hxx.
|
private |
Definition at line 104 of file TBufferMerger.hxx.
|
private |
Definition at line 106 of file TBufferMerger.hxx.
|
private |
Definition at line 105 of file TBufferMerger.hxx.
|
private |
Definition at line 108 of file TBufferMerger.hxx.
|
private |
Definition at line 107 of file TBufferMerger.hxx.