Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Philippe Canal, Witold Pokorski, and Guilherme Amadio
5 * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
14#include "TBufferFile.h"
16namespace ROOT {
17namespace Experimental {
20 : TMemFile(m.fMerger.GetOutputFile()->GetName(), "RECREATE", "",
21 m.fMerger.GetOutputFile()->GetCompressionSettings()),
22 fMerger(m)
30Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize)
32 // Make sure the compression of the basket is done in the unlocked thread and
33 // not in the locked section.
34 if (!fMerger.GetNotrees())
37 // Instead of Writing the TTree, doing a memcpy, Pushing to the queue
38 // then Reading and then deleting, let's see if we can just merge using
39 // the live TTree.
40 if (fMerger.TryMerge(this)) {
42 return 0;
43 }
45 auto oldCompLevel = GetCompressionLevel();
48 Int_t nbytes = TMemFile::Write(name, opt, bufsize);
49 SetCompressionLevel(oldCompLevel);
51 if (nbytes) {
53 CopyTo(*buffer);
54 buffer->SetReadMode();
55 fMerger.Push(buffer);
57 }
58 return nbytes;
61} // namespace Experimental
62} // namespace ROOT
int Int_t
Definition: RtypesCore.h:43
char name[80]
Definition: TGX11.cxx:109
TBufferMergerFile has no default constructor.
virtual Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write data into a TBufferFile and append it to TBufferMerger.
TBufferMerger is a class to facilitate writing data in parallel from multiple threads,...
bool TryMerge(TBufferMergerFile *memfile)
void Push(TBufferFile *buffer)
Bool_t GetNotrees() const
Returns whether the the file has been marked as not containing any TTree objects and thus that steps ...
Bool_t GetCompressTemporaryKeys() const
Returns whether to compressed the TKey in the TMemFile for the object held by the TDirectories.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:46
@ kWrite
Definition: TBuffer.h:72
void SetReadMode()
Set buffer in read mode.
Definition: TBuffer.cxx:302
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2180
Int_t GetCompressionLevel() const
Definition: TFile.h:392
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override
Write memory objects to this file.
Definition: TFile.cxx:2297
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Definition: TMemFile.h:19
Long64_t GetSize() const override
Return the current size of the memory file.
Definition: TMemFile.cxx:290
virtual Long64_t CopyTo(void *to, Long64_t maxsize) const
Copy the binary representation of the TMemFile into the memory area starting at 'to' and of length at...
Definition: TMemFile.cxx:255
void ResetAfterMerge(TFileMergeInfo *) override
Wipe all the data from the permanent buffer but keep, the in-memory object alive.
Definition: TMemFile.cxx:320
@ kOnlyPrepStep
Used to request that the class specific implementation of TObject::Write just prepare the objects to ...
Definition: TObject.h:102
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
auto * m
Definition: textangle.C:8