Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBufferMergerFile.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Philippe Canal, Witold Pokorski, and Guilherme Amadio
3
4/*************************************************************************
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 *************************************************************************/
11
13
14#include "TBufferFile.h"
15
16namespace ROOT {
17namespace Experimental {
18
20 : TMemFile(m.fMerger.GetOutputFile()->GetName(), "RECREATE", "",
21 m.fMerger.GetOutputFile()->GetCompressionSettings()),
22 fMerger(m)
23{
24}
25
27{
28}
29
30Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize)
31{
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())
36
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 }
44
45 auto oldCompLevel = GetCompressionLevel();
48 Int_t nbytes = TMemFile::Write(name, opt, bufsize);
49 SetCompressionLevel(oldCompLevel);
50
51 if (nbytes) {
53 CopyTo(*buffer);
54 buffer->SetReadMode();
55 fMerger.Push(buffer);
57 }
58 return nbytes;
59}
60
61} // namespace Experimental
62} // namespace ROOT
char name[80]
Definition TGX11.cxx:110
TBufferMergerFile()
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:47
@ kWrite
Definition TBuffer.h:73
void SetReadMode()
Set buffer in read mode.
Definition TBuffer.cxx:302
virtual Int_t Write(const char *=nullptr, Int_t=0, Int_t=0) override
Write this object to the current directory.
Definition TDirectory.h:217
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
See comments for function SetCompressionSettings.
Definition TFile.cxx:2235
Int_t GetCompressionLevel() const
Definition TFile.h:393
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...
auto * m
Definition textangle.C:8