Logo ROOT   6.10/09
Reference Guide
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 
12 #include "ROOT/TBufferMerger.hxx"
13 
14 #include "TArrayC.h"
15 #include "TBufferFile.h"
16 
17 namespace ROOT {
18 namespace Experimental {
19 
21  : TMemFile(m.fName.c_str(), "recreate", "", m.fCompress), fMerger(m)
22 {
23 }
24 
26 {
27 }
28 
29 Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize)
30 {
31  Int_t nbytes = TMemFile::Write(name, opt, bufsize);
32 
33  if (nbytes) {
34  TBufferFile *fBuffer = new TBufferFile(TBuffer::kWrite);
35 
36  fBuffer->WriteLong64(GetEND());
37  CopyTo(*fBuffer);
38 
39  fMerger.Push(fBuffer);
40  ResetAfterMerge(0);
41  }
42  return nbytes;
43 }
44 
45 } // namespace Experimental
46 } // namespace ROOT
void ResetAfterMerge(TFileMergeInfo *)
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:293
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:47
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
int Int_t
Definition: RtypesCore.h:41
void Push(TBufferFile *buffer)
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Definition: TMemFile.h:17
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.
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
Definition: TFile.cxx:2272
TMarker * m
Definition: textangle.C:8
TBufferMerger is a class to facilitate writing data in parallel from multiple threads, while writing to a single output file.
virtual Long64_t GetEND() const
Definition: TFile.h:202
virtual void WriteLong64(Long64_t l)
Definition: TBufferFile.h:392
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:228