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 {
19 : TMemFile(m.fMerger.GetOutputFile()->GetName(), "RECREATE", "",
20 m.fMerger.GetOutputFile()->GetCompressionSettings()),
21 fMerger(m)
29Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize)
31 // Make sure the compression of the basket is done in the unlocked thread and
32 // not in the locked section.
33 if (!fMerger.GetNotrees())
36 // Instead of Writing the TTree, doing a memcpy, Pushing to the queue
37 // then Reading and then deleting, let's see if we can just merge using
38 // the live TTree.
39 if (fMerger.TryMerge(this)) {
41 return 0;
42 }
44 auto oldCompLevel = GetCompressionLevel();
47 Int_t nbytes = TMemFile::Write(name, opt, bufsize);
48 SetCompressionLevel(oldCompLevel);
50 if (nbytes) {
52 CopyTo(*buffer);
53 buffer->SetReadMode();
54 fMerger.Push(buffer);
56 }
57 return nbytes;
60} // namespace ROOT
char name[80]
Definition: TGX11.cxx:110
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_t GetNotrees() const
Returns whether the file has been marked as not containing any TTree objects and thus that steps that...
bool TryMerge(TBufferMergerFile *memfile)
void Push(TBufferFile *buffer)
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:47
@ kWrite
Definition: TBuffer.h:73
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:2285
Int_t GetCompressionLevel() const
Definition: TFile.h:395
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:2402
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:106
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
TMarker m
Definition: textangle.C:8