Logo ROOT   6.15/01
Reference Guide
TFile.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Rene Brun 28/11/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 #ifndef ROOT_TFile
13 #define ROOT_TFile
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TFile //
19 // //
20 // ROOT file. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include <atomic>
25 
26 #include "TDirectoryFile.h"
27 #include "TMap.h"
28 #include "TUrl.h"
29 
30 #ifdef R__USE_IMT
31 #include "ROOT/TRWSpinLock.hxx"
32 #include <mutex>
33 #endif
34 
35 
36 class TFree;
37 class TArrayC;
38 class TArchiveFile;
39 class TFileOpenHandle;
40 class TFileCacheRead;
41 class TFileCacheWrite;
42 class TProcessID;
43 class TStopwatch;
44 class TFilePrefetch;
45 
46 class TFile : public TDirectoryFile {
47  friend class TDirectoryFile;
48  friend class TFilePrefetch;
49 // TODO: We need to make sure only one TBasket is being written at a time
50 // if we are writing multiple baskets in parallel.
51 #ifdef R__USE_IMT
52  friend class TBasket;
53 #endif
54 
55 public:
56  /// Asynchronous open request status
59  /// Open timeout constants
60  enum EOpenTimeOut { kInstantTimeout = 0, kEternalTimeout = 999999999 };
61 
62  /// TTreeCache flushing semantics
64 
65 protected:
66  Double_t fSumBuffer; ///<Sum of buffer sizes of objects written so far
67  Double_t fSum2Buffer; ///<Sum of squares of buffer sizes of objects written so far
68  Long64_t fBytesWrite; ///<Number of bytes written to this file
69  Long64_t fBytesRead; ///<Number of bytes read from this file
70  Long64_t fBytesReadExtra; ///<Number of extra bytes (overhead) read by the readahead buffer
71  Long64_t fBEGIN; ///<First used byte in file
72  Long64_t fEND; ///<Last used byte in file
73  Long64_t fSeekFree; ///<Location on disk of free segments structure
74  Long64_t fSeekInfo; ///<Location on disk of StreamerInfo record
75  Int_t fD; ///<File descriptor
76  Int_t fVersion; ///<File format version
77  Int_t fCompress; ///<Compression level and algorithm
78  Int_t fNbytesFree; ///<Number of bytes for free segments structure
79  Int_t fNbytesInfo; ///<Number of bytes for StreamerInfo record
80  Int_t fWritten; ///<Number of objects written so far
81  Int_t fNProcessIDs; ///<Number of TProcessID written to this file
82  Int_t fReadCalls; ///<Number of read calls ( not counting the cache calls )
83  TString fRealName; ///<Effective real file name (not original url)
84  TString fOption; ///<File options
85  Char_t fUnits; ///<Number of bytes for file pointers
86  TList *fFree; ///<Free segments linked list table
87  TArrayC *fClassIndex; ///<!Index of TStreamerInfo classes written to this file
88  TObjArray *fProcessIDs; ///<!Array of pointers to TProcessIDs
89  Long64_t fOffset; ///<!Seek offset cache
90  TArchiveFile *fArchive; ///<!Archive file from which we read this file
91  TFileCacheRead *fCacheRead; ///<!Pointer to the read cache (if any)
92  TMap *fCacheReadMap; ///<!Pointer to the read cache (if any)
93  TFileCacheWrite *fCacheWrite; ///<!Pointer to the write cache (if any)
94  Long64_t fArchiveOffset; ///<!Offset at which file starts in archive
95  Bool_t fIsArchive : 1; ///<!True if this is a pure archive file
96  Bool_t fNoAnchorInName : 1; ///<!True if we don't want to force the anchor to be appended to the file name
97  Bool_t fIsRootFile : 1; ///<!True is this is a ROOT file, raw file otherwise
98  Bool_t fInitDone : 1; ///<!True if the file has been initialized
99  Bool_t fMustFlush : 1; ///<!True if the file buffers must be flushed
100  Bool_t fIsPcmFile : 1; ///<!True if the file is a ROOT pcm file.
101  TFileOpenHandle *fAsyncHandle; ///<!For proper automatic cleanup
102  EAsyncOpenStatus fAsyncOpenStatus; ///<!Status of an asynchronous open request
103  TUrl fUrl; ///<!URL of file
104 
105  TList *fInfoCache; ///<!Cached list of the streamer infos in this file
106  TList *fOpenPhases; ///<!Time info about open phases
107 
108 #ifdef R__USE_IMT
109  static ROOT::TRWSpinLock fgRwLock; ///<!Read-write lock to protect global PID list
110  std::mutex fWriteMutex; ///<!Lock for writing baskets / keys into the file.
111 #endif
112 
113  static TList *fgAsyncOpenRequests; //List of handles for pending open requests
114 
115  static TString fgCacheFileDir; ///<Directory where to locally stage files
116  static Bool_t fgCacheFileDisconnected; ///<Indicates, we trust in the files in the cache dir without stat on the cached file
117  static Bool_t fgCacheFileForce; ///<Indicates, to force all READ to CACHEREAD
118  static UInt_t fgOpenTimeout; ///<Timeout for open operations in ms - 0 corresponds to blocking i/o
119  static Bool_t fgOnlyStaged ; ///<Before the file is opened, it is checked, that the file is staged, if not, the open fails
120 
121  static std::atomic<Long64_t> fgBytesWrite; ///<Number of bytes written by all TFile objects
122  static std::atomic<Long64_t> fgBytesRead; ///<Number of bytes read by all TFile objects
123  static std::atomic<Long64_t> fgFileCounter; ///<Counter for all opened files
124  static std::atomic<Int_t> fgReadCalls; ///<Number of bytes read from all TFile objects
125  static Int_t fgReadaheadSize; ///<Readahead buffer size
126  static Bool_t fgReadInfo; ///<if true (default) ReadStreamerInfo is called when opening a file
128  virtual void Init(Bool_t create);
130  Int_t ReadBufferViaCache(char *buf, Int_t len);
131  Int_t WriteBufferViaCache(const char *buf, Int_t len);
132 
133  // Creating projects
134  Int_t MakeProjectParMake(const char *packname, const char *filename);
135  Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir);
136 
137  // Interface to basic system I/O routines
138  virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
139  virtual Int_t SysClose(Int_t fd);
140  virtual Int_t SysRead(Int_t fd, void *buf, Int_t len);
141  virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
142  virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
143  virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
144  virtual Int_t SysSync(Int_t fd);
145 
146  // Interface for text-based TDirectory I/O
147  virtual Long64_t DirCreateEntry(TDirectory*) { return 0; }
148  virtual Int_t DirReadKeys(TDirectory*) { return 0; }
149  virtual void DirWriteKeys(TDirectory*) {}
150  virtual void DirWriteHeader(TDirectory*) {}
151 
152 private:
153  TFile(const TFile &); //Files cannot be copied
154  void operator=(const TFile &);
155 
156  static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch);
157  static TFile *OpenFromCache(const char *name, Option_t * = "",
158  const char *ftitle = "", Int_t compress = 1,
159  Int_t netopt = 0);
160 
161 public:
162  /// TFile status bits. BIT(13) is taken up by TObject
163  enum EStatusBits {
166  kDevNull = BIT(12),
170  };
171  enum ERelativeTo { kBeg = 0, kCur = 1, kEnd = 2 };
172  enum { kStartBigFile = 2000000000 };
173  /// File type
174  enum EFileType { kDefault = 0, kLocal = 1, kNet = 2, kWeb = 3, kFile = 4, kMerge = 5};
175 
176  TFile();
177  TFile(const char *fname, Option_t *option="", const char *ftitle="", Int_t compress=4);
178  virtual ~TFile();
179  virtual void Close(Option_t *option=""); // *MENU*
180  virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
181  virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t buffersize = 1000000);
182  virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize);
183  virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl,
184  const char* name, Int_t bufsize);
185  static TFile *&CurrentFile(); // Return the current file for this thread.
186  virtual void Delete(const char *namecycle="");
187  virtual void Draw(Option_t *option="");
188  virtual void DrawMap(const char *keys="*",Option_t *option=""); // *MENU*
189  virtual void FillBuffer(char *&buffer);
190  virtual void Flush();
191  TArchiveFile *GetArchive() const { return fArchive; }
193  Int_t GetBestBuffer() const;
194  virtual Int_t GetBytesToPrefetch() const;
197  TArrayC *GetClassIndex() const { return fClassIndex; }
199  Int_t GetCompressionLevel() const;
202  virtual Long64_t GetEND() const { return fEND; }
203  virtual Int_t GetErrno() const;
204  virtual void ResetErrno() const;
205  Int_t GetFd() const { return fD; }
206  virtual const TUrl *GetEndpointUrl() const { return &fUrl; }
208  TList *GetListOfFree() const { return fFree; }
209  virtual Int_t GetNfree() const { return fFree->GetSize(); }
210  virtual Int_t GetNProcessIDs() const { return fNProcessIDs; }
211  Option_t *GetOption() const { return fOption.Data(); }
212  virtual Long64_t GetBytesRead() const { return fBytesRead; }
213  virtual Long64_t GetBytesReadExtra() const { return fBytesReadExtra; }
214  virtual Long64_t GetBytesWritten() const;
215  virtual Int_t GetReadCalls() const { return fReadCalls; }
216  Int_t GetVersion() const { return fVersion; }
217  Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes,
218  Int_t &nbytes, Int_t &objlen, Int_t &keylen);
219  virtual Int_t GetNbytesInfo() const {return fNbytesInfo;}
220  virtual Int_t GetNbytesFree() const {return fNbytesFree;}
221  virtual TString GetNewUrl() { return ""; }
222  Long64_t GetRelOffset() const { return fOffset - fArchiveOffset; }
223  virtual Long64_t GetSeekFree() const {return fSeekFree;}
224  virtual Long64_t GetSeekInfo() const {return fSeekInfo;}
225  virtual Long64_t GetSize() const;
226  virtual TList *GetStreamerInfoList();
227  const TList *GetStreamerInfoCache();
228  virtual void IncrementProcessIDs() { fNProcessIDs++; }
229  virtual Bool_t IsArchive() const { return fIsArchive; }
230  Bool_t IsBinary() const { return TestBit(kBinaryFile); }
231  Bool_t IsRaw() const { return !fIsRootFile; }
232  virtual Bool_t IsOpen() const;
233  virtual void ls(Option_t *option="") const;
234  virtual void MakeFree(Long64_t first, Long64_t last);
235  virtual void MakeProject(const char *dirname, const char *classes="*",
236  Option_t *option="new"); // *MENU*
237  virtual void Map(Option_t *opt); // *MENU*
238  virtual void Map() { Map(""); }; // *MENU*
239  virtual Bool_t Matches(const char *name);
240  virtual Bool_t MustFlush() const {return fMustFlush;}
241  virtual void Paint(Option_t *option="");
242  virtual void Print(Option_t *option="") const;
243  virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
244  virtual Bool_t ReadBuffer(char *buf, Int_t len);
245  virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
246  virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
247  virtual void ReadFree();
248  virtual TProcessID *ReadProcessID(UShort_t pidf);
249  virtual void ReadStreamerInfo();
250  virtual Int_t Recover();
251  virtual Int_t ReOpen(Option_t *mode);
252  virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
253  virtual void SetCacheRead(TFileCacheRead *cache, TObject* tree = 0, ECacheAction action = kDisconnect);
254  virtual void SetCacheWrite(TFileCacheWrite *cache);
255  virtual void SetCompressionAlgorithm(Int_t algorithm=0);
256  virtual void SetCompressionLevel(Int_t level=4);
257  virtual void SetCompressionSettings(Int_t settings=4);
258  virtual void SetEND(Long64_t last) { fEND = last; }
259  virtual void SetOffset(Long64_t offset, ERelativeTo pos = kBeg);
260  virtual void SetOption(Option_t *option=">") { fOption = option; }
261  virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; }
262  virtual void ShowStreamerInfo();
263  virtual Int_t Sizeof() const;
264  void SumBuffer(Int_t bufsize);
265  virtual Bool_t WriteBuffer(const char *buf, Int_t len);
266  virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0);
267  virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0) const;
268  virtual void WriteFree();
269  virtual void WriteHeader();
270  virtual UShort_t WriteProcessID(TProcessID *pid);
271  virtual void WriteStreamerInfo();
272 
273  static TFileOpenHandle
274  *AsyncOpen(const char *name, Option_t *option = "",
275  const char *ftitle = "", Int_t compress = 1,
276  Int_t netopt = 0);
277  static TFile *Open(const char *name, Option_t *option = "",
278  const char *ftitle = "", Int_t compress = 1,
279  Int_t netopt = 0);
280  static TFile *Open(TFileOpenHandle *handle);
281 
282  static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = 0);
283 
284  static EAsyncOpenStatus GetAsyncOpenStatus(const char *name);
286  static const TUrl *GetEndpointUrl(const char *name);
287 
288  static Long64_t GetFileBytesRead();
289  static Long64_t GetFileBytesWritten();
290  static Int_t GetFileReadCalls();
291  static Int_t GetReadaheadSize();
292 
293  static void SetFileBytesRead(Long64_t bytes = 0);
294  static void SetFileBytesWritten(Long64_t bytes = 0);
295  static void SetFileReadCalls(Int_t readcalls = 0);
296  static void SetReadaheadSize(Int_t bufsize = 256000);
297  static void SetReadStreamerInfo(Bool_t readinfo=kTRUE);
298  static Bool_t GetReadStreamerInfo();
299 
300  static Long64_t GetFileCounter();
301  static void IncrementFileCounter();
302 
303  static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected = kTRUE,
304  Bool_t forceCacheread = kFALSE)
305  { return SetCacheFileDir(std::string_view(cacheDir), operateDisconnected, forceCacheread); }
306  static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected = kTRUE,
307  Bool_t forceCacheread = kFALSE);
308  static const char *GetCacheFileDir();
309  static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval = 0);
310  static Bool_t Cp(const char *src, const char *dst, Bool_t progressbar = kTRUE,
311  UInt_t buffersize = 1000000);
312 
313  static UInt_t SetOpenTimeout(UInt_t timeout); // in ms
314  static UInt_t GetOpenTimeout(); // in ms
315  static Bool_t SetOnlyStaged(Bool_t onlystaged);
316  static Bool_t GetOnlyStaged();
317 
318  ClassDef(TFile,8) //ROOT file
319 };
320 
321 #ifndef __CINT__
322 #define gFile (TFile::CurrentFile())
323 
324 #elif defined(__MAKECINT__)
325 // To properly handle the use of gFile in header files (in static declarations)
327 #endif
328 
329 /**
330 \class TFileOpenHandle
331 \ingroup IO
332 Class holding info about the file being opened
333 */
334 class TFileOpenHandle : public TNamed {
335 
336 friend class TFile;
337 friend class TAlienFile;
338 
339 private:
340  TString fOpt; ///< Options
341  Int_t fCompress; ///< Compression level and algorithm
342  Int_t fNetOpt; ///< Network options
343  TFile *fFile; ///< TFile instance of the file being opened
344 
345  TFileOpenHandle(TFile *f) : TNamed("",""), fOpt(""), fCompress(1),
346  fNetOpt(0), fFile(f) { }
347  TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp,
348  Int_t no) : TNamed(n,t), fOpt(o), fCompress(cmp),
349  fNetOpt(no), fFile(0) { }
352 
353  TFile *GetFile() const { return fFile; }
354 
355 public:
357 
358  Bool_t Matches(const char *name);
359 
360  const char *GetOpt() const { return fOpt; }
361  Int_t GetCompress() const { return fCompress; }
362  Int_t GetNetOpt() const { return fNetOpt; }
363 };
364 
365 //______________________________________________________________________________
367 {
368  return (fCompress < 0) ? -1 : fCompress / 100;
369 }
370 
371 //______________________________________________________________________________
373 {
374  return (fCompress < 0) ? -1 : fCompress % 100;
375 }
376 
377 //______________________________________________________________________________
379 {
380  return (fCompress < 0) ? -1 : fCompress;
381 }
382 
383 #endif
Long64_t GetRelOffset() const
Definition: TFile.h:222
virtual void DirWriteKeys(TDirectory *)
Definition: TFile.h:149
Bool_t fIsArchive
!True if this is a pure archive file
Definition: TFile.h:95
static ROOT::TRWSpinLock fgRwLock
!Read-write lock to protect global PID list
Definition: TFile.h:109
Bool_t fIsPcmFile
!True if the file is a ROOT pcm file.
Definition: TFile.h:100
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive...
Definition: TArchiveFile.h:24
virtual void DrawMap(const char *keys="*", Option_t *option="")
Draw map of objects in this file.
Definition: TFile.cxx:1083
virtual Int_t Recover()
Attempt to recover file if not correctly closed.
Definition: TFile.cxx:1920
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:91
An array of TObjects.
Definition: TObjArray.h:37
Char_t fUnits
Number of bytes for file pointers.
Definition: TFile.h:85
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Return file stat information.
Definition: TFile.cxx:4385
void operator=(const TFile &)
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition: TFile.h:88
Long64_t fBEGIN
First used byte in file.
Definition: TFile.h:71
long long Long64_t
Definition: RtypesCore.h:69
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
Definition: TFile.h:126
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
Definition: TFile.cxx:4367
Long64_t fBytesWrite
Number of bytes written to this file.
Definition: TFile.h:68
EAsyncOpenStatus
Asynchronous open request status.
Definition: TFile.h:57
virtual void FillBuffer(char *&buffer)
Encode file output buffer.
Definition: TFile.cxx:1125
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:66
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Definition: TFile.h:122
virtual Long64_t GetSeekInfo() const
Definition: TFile.h:224
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
Definition: TFile.cxx:2034
float Float_t
Definition: RtypesCore.h:53
Int_t fCompress
Compression level and algorithm.
Definition: TFile.h:77
TArchiveFile * GetArchive() const
Definition: TFile.h:191
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition: TFile.h:87
static void IncrementFileCounter()
Definition: TFile.cxx:4462
virtual void ReadFree()
Read the FREE linked list.
Definition: TFile.cxx:1800
A cache when reading files over the network.
const char Option_t
Definition: RtypesCore.h:62
Int_t GetNetOpt() const
Definition: TFile.h:362
TString fOpt
Options.
Definition: TFile.h:340
virtual void Flush()
Synchronize a file&#39;s in-memory and on-disk states.
Definition: TFile.cxx:1096
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
Definition: TFile.cxx:2240
static TList * fgAsyncOpenRequests
Definition: TFile.h:113
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TFile.cxx:2127
This class represents a WWW compatible URL.
Definition: TUrl.h:35
virtual void SetEND(Long64_t last)
Definition: TFile.h:258
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
Creates key for object and converts data to buffer.
Definition: TFile.cxx:1011
unsigned short UShort_t
Definition: RtypesCore.h:36
Class holding info about the file being opened.
Definition: TFile.h:334
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
Definition: TFile.h:118
#define BIT(n)
Definition: Rtypes.h:78
virtual void SetCompressionSettings(Int_t settings=4)
Used to specify the compression level and algorithm.
Definition: TFile.cxx:2213
TArrayC * GetClassIndex() const
Definition: TFile.h:197
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
Definition: TFile.cxx:2148
virtual void DirWriteHeader(TDirectory *)
Definition: TFile.h:150
TObjArray * GetListOfProcessIDs() const
Definition: TFile.h:207
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
static void SetFileReadCalls(Int_t readcalls=0)
Definition: TFile.cxx:4456
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition: TFile.cxx:1645
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Definition: TFile.h:303
virtual void SetReadCalls(Int_t readcalls=0)
Definition: TFile.h:261
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual Long64_t GetBytesWritten() const
Return the total number of bytes written so far to the file.
Definition: TFile.cxx:4408
TFileOpenHandle(TFile *f)
Definition: TFile.h:345
Basic string class.
Definition: TString.h:131
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Try to shrink the cache to the desired size.
Definition: TFile.cxx:4508
~TFileOpenHandle()
Definition: TFile.h:356
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition: TFile.cxx:2394
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition: TFile.h:70
ERelativeTo
Definition: TFile.h:171
TList * fInfoCache
!Cached list of the streamer infos in this file
Definition: TFile.h:105
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
Specify if the streamerinfos must be read at file opening.
Definition: TFile.cxx:3591
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:74
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:82
TArchiveFile * fArchive
!Archive file from which we read this file
Definition: TFile.h:90
static void SetReadaheadSize(Int_t bufsize=256000)
Definition: TFile.cxx:4447
Long64_t GetArchiveOffset() const
Definition: TFile.h:192
Int_t fNetOpt
Network options.
Definition: TFile.h:342
virtual void SetCompressionLevel(Int_t level=4)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2194
virtual Bool_t IsArchive() const
Definition: TFile.h:229
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
Definition: TFile.cxx:2292
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3948
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
Definition: TFile.cxx:4846
#define gFile
Definition: TFile.h:322
static void SetFileBytesWritten(Long64_t bytes=0)
Definition: TFile.cxx:4453
virtual Long64_t GetSeekFree() const
Definition: TFile.h:223
virtual Int_t GetErrno() const
Method returning errno. Is overriden in TRFIOFile.
Definition: TFile.cxx:1196
Bool_t IsBinary() const
Definition: TFile.h:230
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition: TFile.h:79
TMap * fCacheReadMap
!Pointer to the read cache (if any)
Definition: TFile.h:92
virtual void ResetErrno() const
Method resetting the errno. Is overridden in TRFIOFile.
Definition: TFile.cxx:1204
Int_t GetVersion() const
Definition: TFile.h:216
TUrl fUrl
!URL of file
Definition: TFile.h:103
Int_t fD
File descriptor.
Definition: TFile.h:75
#define ClassDef(name, id)
Definition: Rtypes.h:320
Service class for TFile.
Definition: TFree.h:27
static Bool_t GetReadStreamerInfo()
If the streamerinfos are to be read at file opening.
Definition: TFile.cxx:3601
virtual void MakeProject(const char *dirname, const char *classes="*", Option_t *option="new")
Generate source code necessary to access the objects stored in the file.
Definition: TFile.cxx:2598
virtual void WriteFree()
Write FREE linked list on the file.
Definition: TFile.cxx:2418
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TString fRealName
Effective real file name (not original url)
Definition: TFile.h:83
std::mutex fWriteMutex
!Lock for writing baskets / keys into the file.
Definition: TFile.h:110
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition: TFile.cxx:4416
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=0)
Resolve the file type as a function of the protocol field in &#39;name&#39;.
Definition: TFile.cxx:4663
static TFile * OpenFromCache(const char *name, Option_t *="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Open a file for reading through the file cache.
Definition: TFile.cxx:3739
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
Definition: TFile.cxx:4425
virtual Int_t GetReadCalls() const
Definition: TFile.h:215
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:933
TFile * GetFile() const
Definition: TFile.h:353
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
virtual TString GetNewUrl()
Definition: TFile.h:221
virtual void Map()
Definition: TFile.h:238
virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write().
Definition: TFile.cxx:4356
virtual void IncrementProcessIDs()
Definition: TFile.h:228
virtual Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
Definition: TFile.cxx:4394
A doubly linked list.
Definition: TList.h:44
Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen)
Read the logical record header starting at a certain postion.
Definition: TFile.cxx:1249
virtual Long64_t DirCreateEntry(TDirectory *)
Definition: TFile.h:147
TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp, Int_t no)
Definition: TFile.h:347
virtual Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
Definition: TFile.cxx:4339
Int_t GetCompressionAlgorithm() const
Definition: TFile.h:366
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
Definition: TFile.cxx:4576
virtual void ShowStreamerInfo()
Show the StreamerInfo of all classes written to this file.
Definition: TFile.cxx:3609
EFileType
File type.
Definition: TFile.h:174
virtual Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read().
Definition: TFile.cxx:4348
const char * GetOpt() const
Definition: TFile.h:360
virtual Int_t GetNfree() const
Definition: TFile.h:209
Long64_t fEND
Last used byte in file.
Definition: TFile.h:72
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open().
Definition: TFile.cxx:4323
virtual void WriteStreamerInfo()
Write the list of TStreamerInfo as a single object in this file The class Streamer description for al...
Definition: TFile.cxx:3651
A ROOT file is structured in Directories (like a file system).
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:2311
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
Definition: TFile.cxx:5066
virtual void SetOption(Option_t *option=">")
Definition: TFile.h:260
virtual void Delete(const char *namecycle="")
Delete object namecycle.
Definition: TFile.cxx:1062
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
Definition: TFile.cxx:2351
virtual Bool_t MustFlush() const
Definition: TFile.h:240
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
Definition: TFile.h:102
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void MakeFree(Long64_t first, Long64_t last)
Mark unused bytes on the file.
Definition: TFile.cxx:1408
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
Definition: TFile.h:123
Manages buffers for branches of a Tree.
Definition: TBasket.h:34
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
Definition: TFile.h:121
virtual Int_t DirReadKeys(TDirectory *)
Definition: TFile.h:148
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
Print file copy progress.
Definition: TFile.cxx:4818
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition: TFile.h:124
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
virtual void Draw(Option_t *option="")
Fill Graphics Structure and Paint.
Definition: TFile.cxx:1075
virtual TList * GetStreamerInfoList()
Read the list of TStreamerInfo objects written to this file.
Definition: TFile.cxx:1339
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Definition: TFile.cxx:4433
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition: TFile.cxx:594
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition: TFile.cxx:1764
static TFile *& CurrentFile()
Return the current ROOT file if any.
Definition: TFile.cxx:1031
Option_t * GetOption() const
Definition: TFile.h:211
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual Long64_t GetBytesRead() const
Definition: TFile.h:212
static Bool_t fgOnlyStaged
Before the file is opened, it is checked, that the file is staged, if not, the open fails...
Definition: TFile.h:119
static Bool_t GetOnlyStaged()
Returns staged only flag.
Definition: TFile.cxx:4596
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition: TFile.cxx:3474
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition: TFile.h:67
virtual Int_t GetNbytesFree() const
Definition: TFile.h:220
long Long_t
Definition: RtypesCore.h:50
TFile()
File default Constructor.
Definition: TFile.cxx:173
TList * fFree
Free segments linked list table.
Definition: TFile.h:86
TFile * fFile
Pointer to current file in memory.
virtual Int_t GetNbytesInfo() const
Definition: TFile.h:219
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
Definition: TFile.cxx:1393
Int_t fNbytesFree
Number of bytes for free segments structure.
Definition: TFile.h:78
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
Definition: TFile.h:117
TFile * fFile
TFile instance of the file being opened.
Definition: TFile.h:343
double Double_t
Definition: RtypesCore.h:55
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Definition: TFile.cxx:4441
Describe directory structure in memory.
Definition: TDirectory.h:34
EStatusBits
Definition: TObject.h:57
TFileCacheWrite * GetCacheWrite() const
Return a pointer to the current write cache.
Definition: TFile.cxx:1229
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TFile.cxx:1295
Bool_t fNoAnchorInName
!True if we don&#39;t want to force the anchor to be appended to the file name
Definition: TFile.h:96
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
Definition: TFile.h:116
TList * fOpenPhases
!Time info about open phases
Definition: TFile.h:106
basic_string_view< char > string_view
Definition: RStringView.hxx:35
TString fOption
File options.
Definition: TFile.h:84
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
Definition: TFilePrefetch.h:31
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition: TFile.h:99
Float_t GetCompressionFactor()
Return the file compression factor.
Definition: TFile.cxx:1152
Int_t GetCompress() const
Definition: TFile.h:361
virtual Long64_t GetBytesReadExtra() const
Definition: TFile.h:213
Bool_t fIsRootFile
!True is this is a ROOT file, raw file otherwise
Definition: TFile.h:97
const TList * GetStreamerInfoCache()
Returns the cached list of StreamerInfos used in this file.
Definition: TFile.cxx:1314
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition: TFile.cxx:1113
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Sets only staged flag.
Definition: TFile.cxx:4586
virtual Long64_t GetEND() const
Definition: TFile.h:202
virtual void Paint(Option_t *option="")
Paint all objects in the file.
Definition: TFile.cxx:1573
#define R__EXTERN
Definition: DllImport.h:27
char Char_t
Definition: RtypesCore.h:29
static TString fgCacheFileDir
Directory where to locally stage files.
Definition: TFile.h:115
virtual const TUrl * GetEndpointUrl() const
Definition: TFile.h:206
virtual ~TFile()
File destructor.
Definition: TFile.cxx:544
static TFileOpenHandle * AsyncOpen(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Submit an asynchronous open request.
Definition: TFile.cxx:4188
Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir)
Create BUILD.sh and SETUP.C under &#39;proofinf&#39; for PAR package &#39;pack&#39;.
Definition: TFile.cxx:3355
virtual void Print(Option_t *option="") const
Print all objects in the file.
Definition: TFile.cxx:1581
TList * GetListOfFree() const
Definition: TFile.h:208
virtual UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pidd is already in the file, if not, add it and return the index number in the...
Definition: TFile.cxx:3622
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
Definition: TFile.cxx:1696
virtual Int_t GetNProcessIDs() const
Definition: TFile.h:210
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition: TFile.h:81
virtual Int_t Sizeof() const
Return the size in bytes of the file header.
Definition: TFile.cxx:2272
static UInt_t SetOpenTimeout(UInt_t timeout)
Sets open timeout time (in ms). Returns previous timeout value.
Definition: TFile.cxx:4566
virtual void SetCompressionAlgorithm(Int_t algorithm=0)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2179
Definition: tree.py:1
Int_t GetFd() const
Definition: TFile.h:205
TFileCacheRead * GetCacheRead(TObject *tree=0) const
Return a pointer to the current read cache.
Definition: TFile.cxx:1212
Int_t fVersion
File format version.
Definition: TFile.h:76
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition: TFile.h:94
Int_t fCompress
Compression level and algorithm.
Definition: TFile.h:341
Definition: first.py:1
Int_t fWritten
Number of objects written so far.
Definition: TFile.h:80
static Int_t fgReadaheadSize
Readahead buffer size.
Definition: TFile.h:125
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:89
virtual void WriteHeader()
Write File Header.
Definition: TFile.cxx:2490
Bool_t fInitDone
!True if the file has been initialized
Definition: TFile.h:98
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
Definition: TFile.h:101
EOpenTimeOut
Open timeout constants.
Definition: TFile.h:60
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
static void SetFileBytesRead(Long64_t bytes=0)
Definition: TFile.cxx:4450
virtual void ls(Option_t *option="") const
List file contents.
Definition: TFile.cxx:1381
const Bool_t kTRUE
Definition: RtypesCore.h:87
Long64_t fSeekFree
Location on disk of free segments structure.
Definition: TFile.h:73
static Long64_t GetFileCounter()
Definition: TFile.cxx:4459
const Int_t n
Definition: legend1.C:16
virtual void SetCacheWrite(TFileCacheWrite *cache)
Set a pointer to the write cache.
Definition: TFile.cxx:2263
Int_t GetCompressionLevel() const
Definition: TFile.h:372
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:69
char name[80]
Definition: TGX11.cxx:109
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4496
virtual TProcessID * ReadProcessID(UShort_t pidf)
The TProcessID with number pidf is read from this file.
Definition: TFile.cxx:1826
A cache when writing files over the network.
Int_t GetCompressionSettings() const
Definition: TFile.h:378
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
Definition: TFile.cxx:1138
virtual void Copy(TObject &) const
Copy this to obj.
Definition: TFile.h:180
Int_t MakeProjectParMake(const char *packname, const char *filename)
Create makefile at &#39;filemake&#39; for PAR package &#39;pack&#39;.
Definition: TFile.cxx:3233
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TFile.cxx:5052
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Definition: TFile.h:93
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:914
virtual Bool_t Matches(const char *name)
Return kTRUE if &#39;url&#39; matches the coordinates of this file.
Definition: TFile.cxx:4608
Bool_t IsRaw() const
Definition: TFile.h:231
const char * Data() const
Definition: TString.h:364
Array of chars or bytes (8 bits per element).
Definition: TArrayC.h:27
ECacheAction
TTreeCache flushing semantics.
Definition: TFile.h:63
Stopwatch class.
Definition: TStopwatch.h:28
virtual EAsyncOpenStatus GetAsyncOpenStatus()
Definition: TFile.h:127