Logo ROOT  
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 "Compression.h"
27#include "TDirectoryFile.h"
28#include "TMap.h"
29#include "TUrl.h"
31
32#ifdef R__USE_IMT
33#include "ROOT/TRWSpinLock.hxx"
34#include <mutex>
35#endif
36
37
38class TFree;
39class TArrayC;
40class TArchiveFile;
41class TFileOpenHandle;
42class TFileCacheRead;
43class TFileCacheWrite;
44class TProcessID;
45class TStopwatch;
46class TFilePrefetch;
47
48class TFile : public TDirectoryFile {
49 friend class TDirectoryFile;
50 friend class TFilePrefetch;
51// TODO: We need to make sure only one TBasket is being written at a time
52// if we are writing multiple baskets in parallel.
53#ifdef R__USE_IMT
54 friend class TBasket;
55#endif
56
57public:
58 /// Asynchronous open request status
61 /// Open timeout constants
62 enum EOpenTimeOut { kInstantTimeout = 0, kEternalTimeout = 999999999 };
63
64 /// TTreeCache flushing semantics
66
67protected:
68 Double_t fSumBuffer{0}; ///<Sum of buffer sizes of objects written so far
69 Double_t fSum2Buffer{0}; ///<Sum of squares of buffer sizes of objects written so far
70 Long64_t fBytesWrite{0}; ///<Number of bytes written to this file
71 Long64_t fBytesRead{0}; ///<Number of bytes read from this file
72 Long64_t fBytesReadExtra{0}; ///<Number of extra bytes (overhead) read by the readahead buffer
73 Long64_t fBEGIN{0}; ///<First used byte in file
74 Long64_t fEND{0}; ///<Last used byte in file
75 Long64_t fSeekFree{0}; ///<Location on disk of free segments structure
76 Long64_t fSeekInfo{0}; ///<Location on disk of StreamerInfo record
77 Int_t fD{-1}; ///<File descriptor
78 Int_t fVersion{0}; ///<File format version
79 Int_t fCompress{0}; ///<Compression level and algorithm
80 Int_t fNbytesFree{0}; ///<Number of bytes for free segments structure
81 Int_t fNbytesInfo{0}; ///<Number of bytes for StreamerInfo record
82 Int_t fWritten{0}; ///<Number of objects written so far
83 Int_t fNProcessIDs{0}; ///<Number of TProcessID written to this file
84 Int_t fReadCalls{0}; ///<Number of read calls ( not counting the cache calls )
85 TString fRealName; ///<Effective real file name (not original url)
86 TString fOption; ///<File options
87 Char_t fUnits{0}; ///<Number of bytes for file pointers
88 TList *fFree{nullptr}; ///<Free segments linked list table
89 TArrayC *fClassIndex{nullptr}; ///<!Index of TStreamerInfo classes written to this file
90 TObjArray *fProcessIDs{nullptr}; ///<!Array of pointers to TProcessIDs
91 Long64_t fOffset{0}; ///<!Seek offset cache
92 TArchiveFile *fArchive{nullptr}; ///<!Archive file from which we read this file
93 TFileCacheRead *fCacheRead{nullptr}; ///<!Pointer to the read cache (if any)
94 TMap *fCacheReadMap{nullptr}; ///<!Pointer to the read cache (if any)
95 TFileCacheWrite *fCacheWrite{nullptr}; ///<!Pointer to the write cache (if any)
96 Long64_t fArchiveOffset{0}; ///<!Offset at which file starts in archive
97 Bool_t fIsArchive{kFALSE}; ///<!True if this is a pure archive file
98 Bool_t fNoAnchorInName{kFALSE}; ///<!True if we don't want to force the anchor to be appended to the file name
99 Bool_t fIsRootFile{kTRUE}; ///<!True is this is a ROOT file, raw file otherwise
100 Bool_t fInitDone{kFALSE}; ///<!True if the file has been initialized
101 Bool_t fMustFlush{kTRUE}; ///<!True if the file buffers must be flushed
102 Bool_t fIsPcmFile{kFALSE}; ///<!True if the file is a ROOT pcm file.
103 TFileOpenHandle *fAsyncHandle{nullptr}; ///<!For proper automatic cleanup
104 EAsyncOpenStatus fAsyncOpenStatus{kAOSNotAsync}; ///<!Status of an asynchronous open request
105 TUrl fUrl; ///<!URL of file
106
107 TList *fInfoCache{nullptr}; ///<!Cached list of the streamer infos in this file
108 TList *fOpenPhases{nullptr}; ///<!Time info about open phases
109
110#ifdef R__USE_IMT
111 static ROOT::TRWSpinLock fgRwLock; ///<!Read-write lock to protect global PID list
112 std::mutex fWriteMutex; ///<!Lock for writing baskets / keys into the file.
113 static ROOT::Internal::RConcurrentHashColl fgTsSIHashes; ///<!TS Set of hashes built from read streamer infos
114#endif
115
116 static TList *fgAsyncOpenRequests; //List of handles for pending open requests
117
118 static TString fgCacheFileDir; ///<Directory where to locally stage files
119 static Bool_t fgCacheFileDisconnected; ///<Indicates, we trust in the files in the cache dir without stat on the cached file
120 static Bool_t fgCacheFileForce; ///<Indicates, to force all READ to CACHEREAD
121 static UInt_t fgOpenTimeout; ///<Timeout for open operations in ms - 0 corresponds to blocking i/o
122 static Bool_t fgOnlyStaged ; ///<Before the file is opened, it is checked, that the file is staged, if not, the open fails
123
124 static std::atomic<Long64_t> fgBytesWrite; ///<Number of bytes written by all TFile objects
125 static std::atomic<Long64_t> fgBytesRead; ///<Number of bytes read by all TFile objects
126 static std::atomic<Long64_t> fgFileCounter; ///<Counter for all opened files
127 static std::atomic<Int_t> fgReadCalls; ///<Number of bytes read from all TFile objects
128 static Int_t fgReadaheadSize; ///<Readahead buffer size
129 static Bool_t fgReadInfo; ///<if true (default) ReadStreamerInfo is called when opening a file
130
132 virtual void Init(Bool_t create);
134 Int_t ReadBufferViaCache(char *buf, Int_t len);
135 Int_t WriteBufferViaCache(const char *buf, Int_t len);
136
137 ////////////////////////////////////////////////////////////////////////////////
138 /// \brief Simple struct of the return value of GetStreamerInfoListImpl
139 struct InfoListRet {
143 };
144
145 virtual InfoListRet GetStreamerInfoListImpl(bool lookupSICache);
146
147 // Creating projects
148 Int_t MakeProjectParMake(const char *packname, const char *filename);
149 Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir);
150
151 // Interface to basic system I/O routines
152 virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
153 virtual Int_t SysClose(Int_t fd);
154 virtual Int_t SysRead(Int_t fd, void *buf, Int_t len);
155 virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
156 virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
157 virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
158 virtual Int_t SysSync(Int_t fd);
159
160 // Interface for text-based TDirectory I/O
161 virtual Long64_t DirCreateEntry(TDirectory*) { return 0; }
162 virtual Int_t DirReadKeys(TDirectory*) { return 0; }
163 virtual void DirWriteKeys(TDirectory*) {}
164 virtual void DirWriteHeader(TDirectory*) {}
165
166private:
167 TFile(const TFile &) = delete; //Files cannot be copied
168 void operator=(const TFile &) = delete;
169
170 static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch);
171 static TFile *OpenFromCache(const char *name, Option_t * = "",
172 const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
173 Int_t netopt = 0);
174
175public:
176 /// TFile status bits. BIT(13) is taken up by TObject
184 kReproducible = BIT(17)
185 };
186 enum ERelativeTo { kBeg = 0, kCur = 1, kEnd = 2 };
187 enum { kStartBigFile = 2000000000 };
188 /// File type
189 enum EFileType { kDefault = 0, kLocal = 1, kNet = 2, kWeb = 3, kFile = 4, kMerge = 5 };
190
191 TFile();
192 TFile(const char *fname, Option_t *option="", const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
193 virtual ~TFile();
194
195 void Close(Option_t *option="") override; // *MENU*
196 void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); }
197 virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t buffersize = 1000000);
198 virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize);
199 virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl,
200 const char* name, Int_t bufsize);
201 static TFile *&CurrentFile(); // Return the current file for this thread.
202 void Delete(const char *namecycle="") override;
203 void Draw(Option_t *option="") override;
204 virtual void DrawMap(const char *keys="*",Option_t *option=""); // *MENU*
205 void FillBuffer(char *&buffer) override;
206 virtual void Flush();
207 TArchiveFile *GetArchive() const { return fArchive; }
209 Int_t GetBestBuffer() const;
210 virtual Int_t GetBytesToPrefetch() const;
211 TFileCacheRead *GetCacheRead(const TObject* tree = nullptr) const;
213 TArrayC *GetClassIndex() const { return fClassIndex; }
218 virtual Long64_t GetEND() const { return fEND; }
219 virtual Int_t GetErrno() const;
220 virtual void ResetErrno() const;
221 Int_t GetFd() const { return fD; }
222 virtual const TUrl *GetEndpointUrl() const { return &fUrl; }
224 TList *GetListOfFree() const { return fFree; }
225 virtual Int_t GetNfree() const { return fFree->GetSize(); }
226 virtual Int_t GetNProcessIDs() const { return fNProcessIDs; }
227 Option_t *GetOption() const override { return fOption.Data(); }
228 virtual Long64_t GetBytesRead() const { return fBytesRead; }
229 virtual Long64_t GetBytesReadExtra() const { return fBytesReadExtra; }
230 virtual Long64_t GetBytesWritten() const;
231 virtual Int_t GetReadCalls() const { return fReadCalls; }
232 Int_t GetVersion() const { return fVersion; }
233 Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes,
234 Int_t &nbytes, Int_t &objlen, Int_t &keylen);
235 virtual Int_t GetNbytesInfo() const {return fNbytesInfo;}
236 virtual Int_t GetNbytesFree() const {return fNbytesFree;}
237 virtual TString GetNewUrl() { return ""; }
239 virtual Long64_t GetSeekFree() const {return fSeekFree;}
240 virtual Long64_t GetSeekInfo() const {return fSeekInfo;}
241 virtual Long64_t GetSize() const;
242 virtual TList *GetStreamerInfoList() final; // Note: to override behavior, please override GetStreamerInfoListImpl
244 virtual void IncrementProcessIDs() { fNProcessIDs++; }
245 virtual Bool_t IsArchive() const { return fIsArchive; }
246 Bool_t IsBinary() const { return TestBit(kBinaryFile); }
247 Bool_t IsRaw() const { return !fIsRootFile; }
248 virtual Bool_t IsOpen() const;
249 void ls(Option_t *option="") const override;
250 virtual void MakeFree(Long64_t first, Long64_t last);
251 virtual void MakeProject(const char *dirname, const char *classes="*",
252 Option_t *option="new"); // *MENU*
253 virtual void Map(Option_t *opt); // *MENU*
254 virtual void Map() { Map(""); }; // *MENU*
255 virtual Bool_t Matches(const char *name);
256 virtual Bool_t MustFlush() const {return fMustFlush;}
257 void Paint(Option_t *option="") override;
258 void Print(Option_t *option="") const override;
259 virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
260 virtual Bool_t ReadBuffer(char *buf, Int_t len);
261 virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
262 virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
263 virtual void ReadFree();
264 virtual TProcessID *ReadProcessID(UShort_t pidf);
265 virtual void ReadStreamerInfo();
266 virtual Int_t Recover();
267 virtual Int_t ReOpen(Option_t *mode);
268 virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
269 virtual void SetCacheRead(TFileCacheRead *cache, TObject* tree = 0, ECacheAction action = kDisconnect);
270 virtual void SetCacheWrite(TFileCacheWrite *cache);
274 virtual void SetEND(Long64_t last) { fEND = last; }
275 virtual void SetOffset(Long64_t offset, ERelativeTo pos = kBeg);
276 virtual void SetOption(Option_t *option=">") { fOption = option; }
277 virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; }
278 virtual void ShowStreamerInfo();
279 Int_t Sizeof() const override;
280 void SumBuffer(Int_t bufsize);
281 virtual Bool_t WriteBuffer(const char *buf, Int_t len);
282 Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override;
283 Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) const override;
284 virtual void WriteFree();
285 virtual void WriteHeader();
286 virtual UShort_t WriteProcessID(TProcessID *pid);
287 virtual void WriteStreamerInfo();
288
289 static TFileOpenHandle
290 *AsyncOpen(const char *name, Option_t *option = "",
291 const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
292 Int_t netopt = 0);
293 static TFile *Open(const char *name, Option_t *option = "",
294 const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
295 Int_t netopt = 0);
296 static TFile *Open(TFileOpenHandle *handle);
297
298 static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = nullptr);
299
300 static EAsyncOpenStatus GetAsyncOpenStatus(const char *name);
302 static const TUrl *GetEndpointUrl(const char *name);
303
304 static Long64_t GetFileBytesRead();
306 static Int_t GetFileReadCalls();
307 static Int_t GetReadaheadSize();
308
309 static void SetFileBytesRead(Long64_t bytes = 0);
310 static void SetFileBytesWritten(Long64_t bytes = 0);
311 static void SetFileReadCalls(Int_t readcalls = 0);
312 static void SetReadaheadSize(Int_t bufsize = 256000);
313 static void SetReadStreamerInfo(Bool_t readinfo=kTRUE);
315
316 static Long64_t GetFileCounter();
317 static void IncrementFileCounter();
318
319 static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected = kTRUE,
320 Bool_t forceCacheread = kFALSE)
321 { return SetCacheFileDir(std::string_view(cacheDir), operateDisconnected, forceCacheread); }
322 static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected = kTRUE,
323 Bool_t forceCacheread = kFALSE);
324 static const char *GetCacheFileDir();
325 static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval = 0);
326 static Bool_t Cp(const char *src, const char *dst, Bool_t progressbar = kTRUE,
327 UInt_t buffersize = 1000000);
328
329 static UInt_t SetOpenTimeout(UInt_t timeout); // in ms
330 static UInt_t GetOpenTimeout(); // in ms
331 static Bool_t SetOnlyStaged(Bool_t onlystaged);
332 static Bool_t GetOnlyStaged();
333
334 ClassDefOverride(TFile,8) //ROOT file
335};
336
337#ifndef __CINT__
338#define gFile (TFile::CurrentFile())
339
340#elif defined(__MAKECINT__)
341// To properly handle the use of gFile in header files (in static declarations)
343#endif
344
345/**
346\class TFileOpenHandle
347\ingroup IO
348Class holding info about the file being opened
349*/
350class TFileOpenHandle : public TNamed {
351
352friend class TFile;
353friend class TAlienFile;
354
355private:
356 TString fOpt; ///< Options
357 Int_t fCompress{0}; ///< Compression level and algorithm
358 Int_t fNetOpt{0}; ///< Network options
359 TFile *fFile{nullptr}; ///< TFile instance of the file being opened
360
361 TFileOpenHandle(TFile *f) : TNamed("",""), fOpt(""), fCompress(ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault),
362 fNetOpt(0), fFile(f) { }
363 TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp,
364 Int_t no) : TNamed(n,t), fOpt(o), fCompress(cmp),
365 fNetOpt(no), fFile(nullptr) { }
368
369 TFile *GetFile() const { return fFile; }
370
371public:
373
374 Bool_t Matches(const char *name);
375
376 const char *GetOpt() const { return fOpt; }
377 Int_t GetCompress() const { return fCompress; }
378 Int_t GetNetOpt() const { return fNetOpt; }
379};
380
381//______________________________________________________________________________
383{
384 return (fCompress < 0) ? -1 : fCompress / 100;
385}
386
387//______________________________________________________________________________
389{
390 return (fCompress < 0) ? -1 : fCompress % 100;
391}
392
393//______________________________________________________________________________
395{
396 return (fCompress < 0) ? -1 : fCompress;
397}
398
399#endif
#define R__EXTERN
Definition: DllImport.h:27
#define f(i)
Definition: RSha256.hxx:104
unsigned short UShort_t
Definition: RtypesCore.h:36
int Int_t
Definition: RtypesCore.h:41
char Char_t
Definition: RtypesCore.h:29
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
long long Long64_t
Definition: RtypesCore.h:69
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:83
#define ClassDefOverride(name, id)
Definition: Rtypes.h:330
#define gFile
Definition: TFile.h:338
char name[80]
Definition: TGX11.cxx:109
This class is a TS set of unsigned set.
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive.
Definition: TArchiveFile.h:24
Array of chars or bytes (8 bits per element).
Definition: TArrayC.h:27
Manages buffers for branches of a Tree.
Definition: TBasket.h:34
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
A ROOT file is structured in Directories (like a file system).
Describe directory structure in memory.
Definition: TDirectory.h:34
A cache when reading files over the network.
A cache when writing files over the network.
Class holding info about the file being opened.
Definition: TFile.h:350
TFile * fFile
TFile instance of the file being opened.
Definition: TFile.h:359
Int_t fNetOpt
Network options.
Definition: TFile.h:358
TFileOpenHandle(TFile *f)
Definition: TFile.h:361
TString fOpt
Options.
Definition: TFile.h:356
TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp, Int_t no)
Definition: TFile.h:363
Int_t GetNetOpt() const
Definition: TFile.h:378
TFileOpenHandle & operator=(const TFileOpenHandle &)=delete
TFile * GetFile() const
Definition: TFile.h:369
~TFileOpenHandle()
Definition: TFile.h:372
Int_t fCompress
Compression level and algorithm.
Definition: TFile.h:357
const char * GetOpt() const
Definition: TFile.h:376
TFileOpenHandle(const TFileOpenHandle &)=delete
Bool_t Matches(const char *name)
Return kTRUE if this async request matches the open request specified by 'url'.
Definition: TFile.cxx:4606
Int_t GetCompress() const
Definition: TFile.h:377
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
Definition: TFilePrefetch.h:31
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Definition: TFile.h:125
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:84
static void SetFileBytesWritten(Long64_t bytes=0)
Definition: TFile.cxx:4427
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
Definition: TFile.h:120
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:71
virtual Long64_t GetSeekFree() const
Definition: TFile.h:239
virtual TProcessID * ReadProcessID(UShort_t pidf)
The TProcessID with number pidf is read from this file.
Definition: TFile.cxx:1795
void ls(Option_t *option="") const override
List file contents.
Definition: TFile.cxx:1350
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:2115
static Bool_t GetOnlyStaged()
Returns staged only flag.
Definition: TFile.cxx:4570
static void IncrementFileCounter()
Definition: TFile.cxx:4436
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Try to shrink the cache to the desired size.
Definition: TFile.cxx:4482
Long64_t fSeekFree
Location on disk of free segments structure.
Definition: TFile.h:75
static Int_t fgReadaheadSize
Readahead buffer size.
Definition: TFile.h:128
void FillBuffer(char *&buffer) override
Encode file output buffer.
Definition: TFile.cxx:1067
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition: TFile.h:69
static void SetReadaheadSize(Int_t bufsize=256000)
Definition: TFile.cxx:4421
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
Definition: TFile.h:119
const TList * GetStreamerInfoCache()
Returns the cached list of StreamerInfos used in this file.
Definition: TFile.cxx:1261
Int_t GetVersion() const
Definition: TFile.h:232
static Bool_t GetReadStreamerInfo()
If the streamerinfos are to be read at file opening.
Definition: TFile.cxx:3581
TArchiveFile * fArchive
!Archive file from which we read this file
Definition: TFile.h:92
virtual Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
Definition: TFile.cxx:4368
virtual Long64_t DirCreateEntry(TDirectory *)
Definition: TFile.h:161
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
Definition: TFile.cxx:2003
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition: TFile.cxx:3446
virtual Bool_t Matches(const char *name)
Return kTRUE if 'url' matches the coordinates of this file.
Definition: TFile.cxx:4582
Bool_t IsBinary() const
Definition: TFile.h:246
Bool_t IsRaw() const
Definition: TFile.h:247
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition: TFile.h:89
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
Definition: TFile.cxx:4399
virtual InfoListRet GetStreamerInfoListImpl(bool lookupSICache)
See documentation of GetStreamerInfoList for more details.
Definition: TFile.cxx:1271
Int_t GetCompressionSettings() const
Definition: TFile.h:394
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
Specify if the streamerinfos must be read at file opening.
Definition: TFile.cxx:3571
Bool_t fNoAnchorInName
!True if we don't want to force the anchor to be appended to the file name
Definition: TFile.h:98
virtual Int_t DirReadKeys(TDirectory *)
Definition: TFile.h:162
static void SetFileBytesRead(Long64_t bytes=0)
Definition: TFile.cxx:4424
TArrayC * GetClassIndex() const
Definition: TFile.h:213
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:76
void Paint(Option_t *option="") override
Paint all objects in the file.
Definition: TFile.cxx:1542
TList * GetListOfFree() const
Definition: TFile.h:224
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
Definition: TFile.cxx:1080
TList * fOpenPhases
!Time info about open phases
Definition: TFile.h:108
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2160
TFileCacheWrite * GetCacheWrite() const
Return a pointer to the current write cache.
Definition: TFile.cxx:1176
static void SetFileReadCalls(Int_t readcalls=0)
Definition: TFile.cxx:4430
static TString fgCacheFileDir
Directory where to locally stage files.
Definition: TFile.h:118
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:4322
Int_t fVersion
File format version.
Definition: TFile.h:78
void Print(Option_t *option="") const override
Print all objects in the file.
Definition: TFile.cxx:1550
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
Definition: TFile.h:126
virtual EAsyncOpenStatus GetAsyncOpenStatus()
Definition: TFile.h:131
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
Definition: TFile.cxx:4550
void Copy(TObject &) const override
Copy this to obj.
Definition: TFile.h:196
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
Print file copy progress.
Definition: TFile.cxx:4792
Long64_t GetArchiveOffset() const
Definition: TFile.h:208
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:122
virtual Int_t GetNProcessIDs() const
Definition: TFile.h:226
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition: TFile.h:101
TUrl fUrl
!URL of file
Definition: TFile.h:105
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition: TFile.cxx:2360
static ROOT::TRWSpinLock fgRwLock
!Read-write lock to protect global PID list
Definition: TFile.h:111
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition: TFile.cxx:4390
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition: TFile.cxx:1733
void operator=(const TFile &)=delete
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:953
virtual void Map()
Definition: TFile.h:254
virtual void WriteFree()
Write FREE linked list on the file.
Definition: TFile.cxx:2384
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Definition: TFile.cxx:4415
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:1665
static Long64_t GetFileCounter()
Definition: TFile.cxx:4433
TMap * fCacheReadMap
!Pointer to the read cache (if any)
Definition: TFile.h:94
Long64_t fBEGIN
First used byte in file.
Definition: TFile.h:73
Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir)
Create BUILD.sh and SETUP.C under 'proofinf' for PAR package 'pack'.
Definition: TFile.cxx:3327
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:3602
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:2567
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition: TFile.h:96
EOpenTimeOut
Open timeout constants.
Definition: TFile.h:62
@ kInstantTimeout
Definition: TFile.h:62
@ kEternalTimeout
Definition: TFile.h:62
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition: TFile.h:81
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TFile.cxx:1242
Int_t GetFd() const
Definition: TFile.h:221
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
Definition: TFile.cxx:1362
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
Definition: TFile.h:103
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Sets only staged flag.
Definition: TFile.cxx:4560
virtual Int_t GetReadCalls() const
Definition: TFile.h:231
virtual TString GetNewUrl()
Definition: TFile.h:237
virtual Long64_t GetBytesRead() const
Definition: TFile.h:228
virtual Int_t GetErrno() const
Method returning errno.
Definition: TFile.cxx:1143
virtual void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm.
Definition: TFile.cxx:2179
Int_t GetCompressionLevel() const
Definition: TFile.h:388
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
Definition: TFile.h:129
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition: TFile.cxx:534
TFile(const TFile &)=delete
Long64_t GetRelOffset() const
Definition: TFile.h:238
virtual void SetReadCalls(Int_t readcalls=0)
Definition: TFile.h:277
static TFileOpenHandle * AsyncOpen(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Submit an asynchronous open request.
Definition: TFile.cxx:4161
virtual void SetCacheWrite(TFileCacheWrite *cache)
Set a pointer to the write cache.
Definition: TFile.cxx:2229
TString fOption
File options.
Definition: TFile.h:86
virtual Int_t GetNfree() const
Definition: TFile.h:225
virtual Long64_t GetEND() const
Definition: TFile.h:218
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
Definition: TFile.cxx:2317
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
Definition: TFile.cxx:2258
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4470
EAsyncOpenStatus
Asynchronous open request status.
Definition: TFile.h:59
@ kAOSSuccess
Definition: TFile.h:60
@ kAOSNotAsync
Definition: TFile.h:59
@ kAOSInProgress
Definition: TFile.h:60
@ kAOSFailure
Definition: TFile.h:59
virtual void WriteStreamerInfo()
Write the list of TStreamerInfo as a single object in this file The class Streamer description for al...
Definition: TFile.cxx:3631
virtual Long64_t GetBytesWritten() const
Return the total number of bytes written so far to the file.
Definition: TFile.cxx:4382
ERelativeTo
Definition: TFile.h:186
@ kCur
Definition: TFile.h:186
@ kBeg
Definition: TFile.h:186
@ kEnd
Definition: TFile.h:186
virtual Long64_t GetSeekInfo() const
Definition: TFile.h:240
Int_t fCompress
Compression level and algorithm.
Definition: TFile.h:79
virtual Int_t GetNbytesFree() const
Definition: TFile.h:236
virtual Bool_t IsArchive() const
Definition: TFile.h:245
static TFile *& CurrentFile()
Return the current ROOT file if any.
Definition: TFile.cxx:973
virtual void SetEND(Long64_t last)
Definition: TFile.h:274
virtual void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2146
virtual const TUrl * GetEndpointUrl() const
Definition: TFile.h:222
Int_t fNbytesFree
Number of bytes for free segments structure.
Definition: TFile.h:80
Int_t fD
File descriptor.
Definition: TFile.h:77
virtual void ResetErrno() const
Method resetting the errno.
Definition: TFile.cxx:1151
Int_t Sizeof() const override
Return the size in bytes of the file header.
Definition: TFile.cxx:2238
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition: TFile.cxx:1055
virtual void IncrementProcessIDs()
Definition: TFile.h:244
Bool_t fIsPcmFile
!True if the file is a ROOT pcm file.
Definition: TFile.h:102
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:93
virtual Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
Definition: TFile.cxx:4313
TFile()
File default Constructor.
Definition: TFile.cxx:174
Char_t fUnits
Number of bytes for file pointers.
Definition: TFile.h:87
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition: TFile.h:90
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=nullptr)
Resolve the file type as a function of the protocol field in 'name'.
Definition: TFile.cxx:4637
virtual void SetOption(Option_t *option=">")
Definition: TFile.h:276
EFileType
File type.
Definition: TFile.h:189
@ kWeb
Definition: TFile.h:189
@ kDefault
Definition: TFile.h:189
@ kLocal
Definition: TFile.h:189
@ kMerge
Definition: TFile.h:189
@ kNet
Definition: TFile.h:189
@ kFile
Definition: TFile.h:189
virtual void ShowStreamerInfo()
Show the StreamerInfo of all classes written to this file.
Definition: TFile.cxx:3589
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
Definition: TFile.cxx:4341
virtual ~TFile()
File destructor.
Definition: TFile.cxx:484
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:4359
virtual Long64_t GetBytesReadExtra() const
Definition: TFile.h:229
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:4297
ECacheAction
TTreeCache flushing semantics.
Definition: TFile.h:65
@ kDoNotDisconnect
Definition: TFile.h:65
@ kDisconnect
Definition: TFile.h:65
static UInt_t SetOpenTimeout(UInt_t timeout)
Sets open timeout time (in ms). Returns previous timeout value.
Definition: TFile.cxx:4540
virtual void ReadFree()
Read the FREE linked list.
Definition: TFile.cxx:1769
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:4820
static ROOT::Internal::RConcurrentHashColl fgTsSIHashes
!TS Set of hashes built from read streamer infos
Definition: TFile.h:113
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition: TFile.h:72
Long64_t fBytesWrite
Number of bytes written to this file.
Definition: TFile.h:70
TArchiveFile * GetArchive() const
Definition: TFile.h:207
Bool_t fIsRootFile
!True is this is a ROOT file, raw file otherwise
Definition: TFile.h:99
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Definition: TFile.h:319
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
Definition: TFile.cxx:1038
virtual void DirWriteKeys(TDirectory *)
Definition: TFile.h:163
TList * fFree
Free segments linked list table.
Definition: TFile.h:88
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TFile.cxx:5025
std::mutex fWriteMutex
!Lock for writing baskets / keys into the file.
Definition: TFile.h:112
void Delete(const char *namecycle="") override
Delete object namecycle.
Definition: TFile.cxx:1004
Bool_t fInitDone
!True if the file has been initialized
Definition: TFile.h:100
virtual void DrawMap(const char *keys="*", Option_t *option="")
Draw map of objects in this file.
Definition: TFile.cxx:1025
virtual void DirWriteHeader(TDirectory *)
Definition: TFile.h:164
virtual void MakeFree(Long64_t first, Long64_t last)
Mark unused bytes on the file.
Definition: TFile.cxx:1377
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Definition: TFile.h:95
TString fRealName
Effective real file name (not original url)
Definition: TFile.h:85
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TFile.cxx:2094
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:91
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
Definition: TFile.h:124
virtual Int_t GetNbytesInfo() const
Definition: TFile.h:235
TList * fInfoCache
!Cached list of the streamer infos in this file
Definition: TFile.h:107
@ kStartBigFile
Definition: TFile.h:187
virtual Bool_t MustFlush() const
Definition: TFile.h:256
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
Definition: TFile.cxx:5039
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
Definition: TFile.h:121
Int_t MakeProjectParMake(const char *packname, const char *filename)
Create makefile at 'filemake' for PAR package 'pack'.
Definition: TFile.cxx:3205
Long64_t fEND
Last used byte in file.
Definition: TFile.h:74
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3923
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:2277
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
Definition: TFile.h:104
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:68
Bool_t fIsArchive
!True if this is a pure archive file
Definition: TFile.h:97
TObjArray * GetListOfProcessIDs() const
Definition: TFile.h:223
void Draw(Option_t *option="") override
Fill Graphics Structure and Paint.
Definition: TFile.cxx:1017
void Close(Option_t *option="") override
Close a file.
Definition: TFile.cxx:856
Int_t GetCompressionAlgorithm() const
Definition: TFile.h:382
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition: TFile.h:127
virtual Int_t Recover()
Attempt to recover file if not correctly closed.
Definition: TFile.cxx:1889
virtual TList * GetStreamerInfoList() final
Read the list of TStreamerInfo objects written to this file.
Definition: TFile.cxx:1338
virtual void WriteHeader()
Write File Header.
Definition: TFile.cxx:2456
@ kRecovered
Definition: TFile.h:178
@ kReproducible
Definition: TFile.h:184
@ kDevNull
Definition: TFile.h:180
@ kHasReferences
Definition: TFile.h:179
@ kRedirected
Definition: TFile.h:183
@ kWriteError
Definition: TFile.h:181
@ kBinaryFile
Definition: TFile.h:182
static TFile * OpenFromCache(const char *name, Option_t *="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Open a file for reading through the file cache.
Definition: TFile.cxx:3714
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition: TFile.h:83
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
Definition: TFile.cxx:2206
Int_t fWritten
Number of objects written so far.
Definition: TFile.h:82
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:1196
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition: TFile.cxx:1614
Float_t GetCompressionFactor()
Return the file compression factor.
Definition: TFile.cxx:1099
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:4330
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Definition: TFile.cxx:4407
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Definition: TFile.cxx:1159
Option_t * GetOption() const override
Definition: TFile.h:227
static TList * fgAsyncOpenRequests
Definition: TFile.h:116
Service class for TFile.
Definition: TFree.h:27
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
A doubly linked list.
Definition: TList.h:44
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
An array of TObjects.
Definition: TObjArray.h:37
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
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
EStatusBits
Definition: TObject.h:57
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
Stopwatch class.
Definition: TStopwatch.h:28
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
This class represents a WWW compatible URL.
Definition: TUrl.h:35
const Int_t n
Definition: legend1.C:16
basic_string_view< char > string_view
VSD Structures.
Definition: StringConv.hxx:21
Definition: first.py:1
Definition: tree.py:1
@ kUseGlobal
Use the global compression algorithm.
Definition: Compression.h:83
@ kUseCompiledDefault
Use the compile-time default setting.
Definition: Compression.h:50
Simple struct of the return value of GetStreamerInfoListImpl.
Definition: TFile.h:139
Int_t fReturnCode
Definition: TFile.h:141
ROOT::Internal::RConcurrentHashColl::HashValue fHash
Definition: TFile.h:142
TList * fList
Definition: TFile.h:140