Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include <string>
26
27#include "Compression.h"
28#include "TDirectoryFile.h"
29#include "TUrl.h"
31
32// Not a part of TFile interface; provide a forward declaration instead of #include.
33// #ifndef R__LESS_INCLUDES
34// #include "TMap.h"
35// #endif
36
37#ifdef R__USE_IMT
38#include "ROOT/TRWSpinLock.hxx"
39#include <mutex>
40#endif
41
42class TMap;
43class TFree;
44class TArrayC;
45class TArchiveFile;
46class TFileOpenHandle;
47class TFileCacheRead;
48class TFileCacheWrite;
49class TProcessID;
50class TStopwatch;
51class TFilePrefetch;
52
53class TFile : public TDirectoryFile {
54 friend class TDirectoryFile;
55 friend class TFilePrefetch;
56// TODO: We need to make sure only one TBasket is being written at a time
57// if we are writing multiple baskets in parallel.
58#ifdef R__USE_IMT
59 friend class TBasket;
60#endif
61
62public:
63 /// Asynchronous open request status
66 /// Open timeout constants
67 enum EOpenTimeOut { kInstantTimeout = 0, kEternalTimeout = 999999999 };
68
69 /// TTreeCache flushing semantics
71
72protected:
73 Double_t fSumBuffer{0}; ///<Sum of buffer sizes of objects written so far
74 Double_t fSum2Buffer{0}; ///<Sum of squares of buffer sizes of objects written so far
75 Long64_t fBytesWrite{0}; ///<Number of bytes written to this file
76 Long64_t fBytesRead{0}; ///<Number of bytes read from this file
77 Long64_t fBytesReadExtra{0}; ///<Number of extra bytes (overhead) read by the readahead buffer
78 Long64_t fBEGIN{0}; ///<First used byte in file
79 Long64_t fEND{0}; ///<Last used byte in file
80 Long64_t fSeekFree{0}; ///<Location on disk of free segments structure
81 Long64_t fSeekInfo{0}; ///<Location on disk of StreamerInfo record
82 Int_t fD{-1}; ///<File descriptor
83 Int_t fVersion{0}; ///<File format version
84 Int_t fCompress{0}; ///<Compression level and algorithm
85 Int_t fNbytesFree{0}; ///<Number of bytes for free segments structure
86 Int_t fNbytesInfo{0}; ///<Number of bytes for StreamerInfo record
87 Int_t fWritten{0}; ///<Number of objects written so far
88 Int_t fNProcessIDs{0}; ///<Number of TProcessID written to this file
89 Int_t fReadCalls{0}; ///<Number of read calls ( not counting the cache calls )
90 TString fRealName; ///<Effective real file name (not original url)
91 TString fOption; ///<File options
92 Char_t fUnits{0}; ///<Number of bytes for file pointers
93 TList *fFree{nullptr}; ///<Free segments linked list table
94 TArrayC *fClassIndex{nullptr}; ///<!Index of TStreamerInfo classes written to this file
95 TObjArray *fProcessIDs{nullptr}; ///<!Array of pointers to TProcessIDs
96 Long64_t fOffset{0}; ///<!Seek offset cache
97 TArchiveFile *fArchive{nullptr}; ///<!Archive file from which we read this file
98 TFileCacheRead *fCacheRead{nullptr}; ///<!Pointer to the read cache (if any)
99 TMap *fCacheReadMap{nullptr}; ///<!Pointer to the read cache (if any)
100 TFileCacheWrite *fCacheWrite{nullptr}; ///<!Pointer to the write cache (if any)
101 Long64_t fArchiveOffset{0}; ///<!Offset at which file starts in archive
102 Bool_t fIsArchive{kFALSE}; ///<!True if this is a pure archive file
103 Bool_t fNoAnchorInName{kFALSE}; ///<!True if we don't want to force the anchor to be appended to the file name
104 Bool_t fIsRootFile{kTRUE}; ///<!True is this is a ROOT file, raw file otherwise
105 Bool_t fInitDone{kFALSE}; ///<!True if the file has been initialized
106 Bool_t fMustFlush{kTRUE}; ///<!True if the file buffers must be flushed
107 Bool_t fIsPcmFile{kFALSE}; ///<!True if the file is a ROOT pcm file.
108 TFileOpenHandle *fAsyncHandle{nullptr}; ///<!For proper automatic cleanup
109 EAsyncOpenStatus fAsyncOpenStatus{kAOSNotAsync}; ///<!Status of an asynchronous open request
110 TUrl fUrl; ///<!URL of file
111
112 TList *fInfoCache{nullptr}; ///<!Cached list of the streamer infos in this file
113 TList *fOpenPhases{nullptr}; ///<!Time info about open phases
114
115 bool fGlobalRegistration = true; ///<! if true, bypass use of global lists
116
117#ifdef R__USE_IMT
118 std::mutex fWriteMutex; ///<!Lock for writing baskets / keys into the file.
119#endif
120 static ROOT::Internal::RConcurrentHashColl fgTsSIHashes; ///<!TS Set of hashes built from read streamer infos
121
122 static TList *fgAsyncOpenRequests; //List of handles for pending open requests
123
124 static TString fgCacheFileDir; ///<Directory where to locally stage files
125 static Bool_t fgCacheFileDisconnected; ///<Indicates, we trust in the files in the cache dir without stat on the cached file
126 static Bool_t fgCacheFileForce; ///<Indicates, to force all READ to CACHEREAD
127 static UInt_t fgOpenTimeout; ///<Timeout for open operations in ms - 0 corresponds to blocking i/o
128 static Bool_t fgOnlyStaged ; ///<Before the file is opened, it is checked, that the file is staged, if not, the open fails
129
130 static std::atomic<Long64_t> fgBytesWrite; ///<Number of bytes written by all TFile objects
131 static std::atomic<Long64_t> fgBytesRead; ///<Number of bytes read by all TFile objects
132 static std::atomic<Long64_t> fgFileCounter; ///<Counter for all opened files
133 static std::atomic<Int_t> fgReadCalls; ///<Number of bytes read from all TFile objects
134 static Int_t fgReadaheadSize; ///<Readahead buffer size
135 static Bool_t fgReadInfo; ///<if true (default) ReadStreamerInfo is called when opening a file
136
138 virtual void Init(Bool_t create);
140 Int_t ReadBufferViaCache(char *buf, Int_t len);
141 Int_t WriteBufferViaCache(const char *buf, Int_t len);
142
143 ////////////////////////////////////////////////////////////////////////////////
144 /// \brief Simple struct of the return value of GetStreamerInfoListImpl
145 struct InfoListRet {
149 };
150
151 virtual InfoListRet GetStreamerInfoListImpl(bool lookupSICache);
152
153 // Creating projects
154 Int_t MakeProjectParMake(const char *packname, const char *filename);
155 Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir);
156
157 // Interface to basic system I/O routines
158 virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
159 virtual Int_t SysClose(Int_t fd);
160 virtual Int_t SysRead(Int_t fd, void *buf, Int_t len);
161 virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
162 virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
163 virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
164 virtual Int_t SysSync(Int_t fd);
165
166 // Interface for text-based TDirectory I/O
167 virtual Long64_t DirCreateEntry(TDirectory*) { return 0; }
168 virtual Int_t DirReadKeys(TDirectory*) { return 0; }
169 virtual void DirWriteKeys(TDirectory*) {}
170 virtual void DirWriteHeader(TDirectory*) {}
171
172private:
173 TFile(const TFile &) = delete; //Files cannot be copied
174 void operator=(const TFile &) = delete;
175
176 static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch);
177 static TFile *OpenFromCache(const char *name, Option_t * = "",
178 const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
179 Int_t netopt = 0);
180
181public:
182 /// TFile status bits. BIT(13) is taken up by TObject
184 // Produce files forward compatible with (unpatched) version older than
185 // v6.30 by recording the internal bits kIsOnHeap and kNotDeleted; Older
186 // releases were not explicitly setting those bits to the correct value
187 // but instead used verbatim the value stored in the file.
188 // Note that to avoid a circular dependency, this value is used
189 // hard coded in TObject.cxx.
197 kReproducible = BIT(17)
198 };
199 enum ERelativeTo { kBeg = 0, kCur = 1, kEnd = 2 };
200 enum { kStartBigFile = 2000000000 };
201 /// File type
202 enum EFileType { kDefault = 0, kLocal = 1, kNet = 2, kWeb = 3, kFile = 4, kMerge = 5 };
203
204 TFile();
205 TFile(const char *fname, Option_t *option="", const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
206 ~TFile() override;
207
208 void Close(Option_t *option="") override; // *MENU*
209 void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); }
210 virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t buffersize = 1000000);
211 virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize);
212 virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl,
213 const char* name, Int_t bufsize);
214 static TFile *&CurrentFile(); // Return the current file for this thread.
215 void Delete(const char *namecycle="") override;
216 void Draw(Option_t *option="") override;
217 virtual void DrawMap(const char *keys="*",Option_t *option=""); // *MENU*
218 void FillBuffer(char *&buffer) override;
219 virtual void Flush();
220 TArchiveFile *GetArchive() const { return fArchive; }
222 Int_t GetBestBuffer() const;
223 virtual Int_t GetBytesToPrefetch() const;
224 TFileCacheRead *GetCacheRead(const TObject* tree = nullptr) const;
226 TArrayC *GetClassIndex() const { return fClassIndex; }
231 virtual Long64_t GetEND() const { return fEND; }
232 virtual Int_t GetErrno() const;
233 virtual void ResetErrno() const;
234 Int_t GetFd() const { return fD; }
235 virtual const TUrl *GetEndpointUrl() const { return &fUrl; }
237 TList *GetListOfFree() const { return fFree; }
238 virtual Int_t GetNfree() const { return fFree->GetSize(); }
239 virtual Int_t GetNProcessIDs() const { return fNProcessIDs; }
240 Option_t *GetOption() const override { return fOption.Data(); }
241 virtual Long64_t GetBytesRead() const { return fBytesRead; }
242 virtual Long64_t GetBytesReadExtra() const { return fBytesReadExtra; }
243 virtual Long64_t GetBytesWritten() const;
244 virtual Int_t GetReadCalls() const { return fReadCalls; }
245 Int_t GetVersion() const { return fVersion; }
246 Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes,
247 Int_t &nbytes, Int_t &objlen, Int_t &keylen);
248 virtual Int_t GetNbytesInfo() const {return fNbytesInfo;}
249 virtual Int_t GetNbytesFree() const {return fNbytesFree;}
250 virtual TString GetNewUrl() { return ""; }
252 virtual Long64_t GetSeekFree() const {return fSeekFree;}
253 virtual Long64_t GetSeekInfo() const {return fSeekInfo;}
254 virtual Long64_t GetSize() const;
255 virtual TList *GetStreamerInfoList() final; // Note: to override behavior, please override GetStreamerInfoListImpl
257 virtual void IncrementProcessIDs() { fNProcessIDs++; }
258 virtual Bool_t IsArchive() const { return fIsArchive; }
259 Bool_t IsBinary() const { return TestBit(kBinaryFile); }
260 Bool_t IsRaw() const { return !fIsRootFile; }
261 virtual Bool_t IsOpen() const;
262 void ls(Option_t *option="") const override;
263 virtual void MakeFree(Long64_t first, Long64_t last);
264 virtual void MakeProject(const char *dirname, const char *classes="*",
265 Option_t *option="new"); // *MENU*
266 virtual void Map(Option_t *opt); // *MENU*
267 virtual void Map() { Map(""); }; // *MENU*
268 virtual Bool_t Matches(const char *name);
269 virtual Bool_t MustFlush() const {return fMustFlush;}
270 void Paint(Option_t *option="") override;
271 void Print(Option_t *option="") const override;
272 virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
273 virtual Bool_t ReadBuffer(char *buf, Int_t len);
274 virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
275 virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
276 virtual void ReadFree();
277 virtual TProcessID *ReadProcessID(UShort_t pidf);
278 virtual void ReadStreamerInfo();
279 virtual Int_t Recover();
280 virtual Int_t ReOpen(Option_t *mode);
281 virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
282 virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree = nullptr, ECacheAction action = kDisconnect);
283 virtual void SetCacheWrite(TFileCacheWrite *cache);
287 virtual void SetEND(Long64_t last) { fEND = last; }
288 virtual void SetOffset(Long64_t offset, ERelativeTo pos = kBeg);
289 virtual void SetOption(Option_t *option=">") { fOption = option; }
290 virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; }
291 virtual void ShowStreamerInfo();
292 Int_t Sizeof() const override;
293 void SumBuffer(Int_t bufsize);
294 virtual Bool_t WriteBuffer(const char *buf, Int_t len);
295 Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override;
296 Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) const override;
297 virtual void WriteFree();
298 virtual void WriteHeader();
299 virtual UShort_t WriteProcessID(TProcessID *pid);
300 virtual void WriteStreamerInfo();
301
302 static TFileOpenHandle
303 *AsyncOpen(const char *name, Option_t *option = "",
304 const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
305 Int_t netopt = 0);
306 static TFile *Open(const char *name, Option_t *option = "",
307 const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
308 Int_t netopt = 0);
309 static TFile *Open(TFileOpenHandle *handle);
310
311 static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = nullptr);
312
313 static EAsyncOpenStatus GetAsyncOpenStatus(const char *name);
315 static const TUrl *GetEndpointUrl(const char *name);
316
317 static Long64_t GetFileBytesRead();
319 static Int_t GetFileReadCalls();
320 static Int_t GetReadaheadSize();
321
322 static void SetFileBytesRead(Long64_t bytes = 0);
323 static void SetFileBytesWritten(Long64_t bytes = 0);
324 static void SetFileReadCalls(Int_t readcalls = 0);
325 static void SetReadaheadSize(Int_t bufsize = 256000);
326 static void SetReadStreamerInfo(Bool_t readinfo=kTRUE);
328
329 static Long64_t GetFileCounter();
330 static void IncrementFileCounter();
331
332 static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected = kTRUE,
333 Bool_t forceCacheread = kFALSE);
334 static const char *GetCacheFileDir();
335 static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval = 0);
336 static Bool_t Cp(const char *src, const char *dst, Bool_t progressbar = kTRUE,
337 UInt_t buffersize = 1000000);
338
339 static UInt_t SetOpenTimeout(UInt_t timeout); // in ms
340 static UInt_t GetOpenTimeout(); // in ms
341 static Bool_t SetOnlyStaged(Bool_t onlystaged);
342 static Bool_t GetOnlyStaged();
343
344 ClassDefOverride(TFile,8) //ROOT file
345};
346
347#define gFile (TFile::CurrentFile())
348
349/**
350\class TFileOpenHandle
351\ingroup IO
352Class holding info about the file being opened
353*/
354class TFileOpenHandle : public TNamed {
355
356friend class TFile;
357
358private:
359 TString fOpt; ///< Options
360 Int_t fCompress{0}; ///< Compression level and algorithm
361 Int_t fNetOpt{0}; ///< Network options
362 TFile *fFile{nullptr}; ///< TFile instance of the file being opened
363
364 TFileOpenHandle(TFile *f) : TNamed("",""), fOpt(""), fCompress(ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault),
365 fNetOpt(0), fFile(f) { }
366 TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp,
367 Int_t no) : TNamed(n,t), fOpt(o), fCompress(cmp),
368 fNetOpt(no), fFile(nullptr) { }
371
372 TFile *GetFile() const { return fFile; }
373
374public:
375 ~TFileOpenHandle() override { }
376
377 Bool_t Matches(const char *name);
378
379 const char *GetOpt() const { return fOpt; }
380 Int_t GetCompress() const { return fCompress; }
381 Int_t GetNetOpt() const { return fNetOpt; }
382};
383
384//______________________________________________________________________________
386{
387 return (fCompress < 0) ? -1 : fCompress / 100;
388}
389
390//______________________________________________________________________________
392{
393 return (fCompress < 0) ? -1 : fCompress % 100;
394}
395
396//______________________________________________________________________________
398{
399 return (fCompress < 0) ? -1 : fCompress;
400}
401
402#endif
#define f(i)
Definition RSha256.hxx:104
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
char Char_t
Definition RtypesCore.h:37
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
char name[80]
Definition TGX11.cxx:110
This class is a thread-safe associative collection connecting a 256 bits digest/hash to a collection ...
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive.
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:81
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A ROOT file is structured in Directories (like a file system).
Describe directory structure in memory.
Definition TDirectory.h:45
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:354
TFile * fFile
TFile instance of the file being opened.
Definition TFile.h:362
Int_t fNetOpt
Network options.
Definition TFile.h:361
TFileOpenHandle(TFile *f)
Definition TFile.h:364
TString fOpt
Options.
Definition TFile.h:359
TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp, Int_t no)
Definition TFile.h:366
Int_t GetNetOpt() const
Definition TFile.h:381
TFileOpenHandle & operator=(const TFileOpenHandle &)=delete
TFile * GetFile() const
Definition TFile.h:372
Int_t fCompress
Compression level and algorithm.
Definition TFile.h:360
const char * GetOpt() const
Definition TFile.h:379
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:4790
~TFileOpenHandle() override
Definition TFile.h:375
Int_t GetCompress() const
Definition TFile.h:380
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Definition TFile.h:131
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition TFile.h:89
static void SetFileBytesWritten(Long64_t bytes=0)
Definition TFile.cxx:4611
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
Definition TFile.h:126
Long64_t fBytesRead
Number of bytes read from this file.
Definition TFile.h:76
virtual Long64_t GetSeekFree() const
Definition TFile.h:252
virtual TProcessID * ReadProcessID(UShort_t pidf)
The TProcessID with number pidf is read from this file.
Definition TFile.cxx:1951
void ls(Option_t *option="") const override
List file contents.
Definition TFile.cxx:1457
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:2274
static Bool_t GetOnlyStaged()
Returns staged only flag.
Definition TFile.cxx:4754
static void IncrementFileCounter()
Definition TFile.cxx:4620
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Try to shrink the cache to the desired size.
Definition TFile.cxx:4666
Long64_t fSeekFree
Location on disk of free segments structure.
Definition TFile.h:80
static Int_t fgReadaheadSize
Readahead buffer size.
Definition TFile.h:134
void FillBuffer(char *&buffer) override
Encode file output buffer.
Definition TFile.cxx:1170
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition TFile.h:74
static void SetReadaheadSize(Int_t bufsize=256000)
Definition TFile.cxx:4605
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
Definition TFile.h:125
const TList * GetStreamerInfoCache()
Returns the cached list of StreamerInfos used in this file.
Definition TFile.cxx:1366
Int_t GetVersion() const
Definition TFile.h:245
static Bool_t GetReadStreamerInfo()
If the streamerinfos are to be read at file opening.
Definition TFile.cxx:3742
TArchiveFile * fArchive
!Archive file from which we read this file
Definition TFile.h:97
virtual Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
Definition TFile.cxx:4552
virtual Long64_t DirCreateEntry(TDirectory *)
Definition TFile.h:167
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
Definition TFile.cxx:2162
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition TFile.cxx:3605
virtual Bool_t Matches(const char *name)
Return kTRUE if 'url' matches the coordinates of this file.
Definition TFile.cxx:4766
Bool_t IsBinary() const
Definition TFile.h:259
Bool_t IsRaw() const
Definition TFile.h:260
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=nullptr, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
Definition TFile.cxx:2365
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition TFile.h:94
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
Definition TFile.cxx:4583
virtual InfoListRet GetStreamerInfoListImpl(bool lookupSICache)
See documentation of GetStreamerInfoList for more details.
Definition TFile.cxx:1376
@ kStartBigFile
Definition TFile.h:200
Int_t GetCompressionSettings() const
Definition TFile.h:397
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
Specify if the streamerinfos must be read at file opening.
Definition TFile.cxx:3732
Bool_t fNoAnchorInName
!True if we don't want to force the anchor to be appended to the file name
Definition TFile.h:103
virtual Int_t DirReadKeys(TDirectory *)
Definition TFile.h:168
static void SetFileBytesRead(Long64_t bytes=0)
Definition TFile.cxx:4608
TArrayC * GetClassIndex() const
Definition TFile.h:226
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition TFile.h:81
void Paint(Option_t *option="") override
Paint all objects in the file.
Definition TFile.cxx:1698
TList * GetListOfFree() const
Definition TFile.h:237
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
Definition TFile.cxx:1183
TList * fOpenPhases
!Time info about open phases
Definition TFile.h:113
virtual void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
See comments for function SetCompressionSettings.
Definition TFile.cxx:2319
TFileCacheWrite * GetCacheWrite() const
Return a pointer to the current write cache.
Definition TFile.cxx:1279
static void SetFileReadCalls(Int_t readcalls=0)
Definition TFile.cxx:4614
static TString fgCacheFileDir
Directory where to locally stage files.
Definition TFile.h:124
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:4506
Int_t fVersion
File format version.
Definition TFile.h:83
void Print(Option_t *option="") const override
Print all objects in the file.
Definition TFile.cxx:1706
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
Definition TFile.h:132
virtual EAsyncOpenStatus GetAsyncOpenStatus()
Definition TFile.h:137
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
Definition TFile.cxx:4734
void Copy(TObject &) const override
Copy this to obj.
Definition TFile.h:209
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
Print file copy progress.
Definition TFile.cxx:4975
Long64_t GetArchiveOffset() const
Definition TFile.h:221
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:128
virtual Int_t GetNProcessIDs() const
Definition TFile.h:239
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition TFile.h:106
TUrl fUrl
!URL of file
Definition TFile.h:110
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition TFile.cxx:2519
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition TFile.cxx:4574
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition TFile.cxx:1889
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:1047
virtual void Map()
Definition TFile.h:267
virtual void WriteFree()
Write FREE linked list on the file.
Definition TFile.cxx:2543
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Definition TFile.cxx:4599
~TFile() override
File destructor.
Definition TFile.cxx:563
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:1821
static Long64_t GetFileCounter()
Definition TFile.cxx:4617
TMap * fCacheReadMap
!Pointer to the read cache (if any)
Definition TFile.h:99
Long64_t fBEGIN
First used byte in file.
Definition TFile.h:78
Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir)
Create BUILD.sh and SETUP.C under 'proofinf' for PAR package 'pack'.
Definition TFile.cxx:3486
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:3763
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:2726
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition TFile.h:101
EOpenTimeOut
Open timeout constants.
Definition TFile.h:67
@ kInstantTimeout
Definition TFile.h:67
@ kEternalTimeout
Definition TFile.h:67
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition TFile.h:86
virtual Long64_t GetSize() const
Returns the current file size.
Definition TFile.cxx:1347
Int_t GetFd() const
Definition TFile.h:234
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
Definition TFile.cxx:1469
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
Definition TFile.h:108
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Sets only staged flag.
Definition TFile.cxx:4744
virtual Int_t GetReadCalls() const
Definition TFile.h:244
virtual TString GetNewUrl()
Definition TFile.h:250
virtual Long64_t GetBytesRead() const
Definition TFile.h:241
virtual Int_t GetErrno() const
Method returning errno.
Definition TFile.cxx:1246
virtual void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm.
Definition TFile.cxx:2338
Int_t GetCompressionLevel() const
Definition TFile.h:391
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
Definition TFile.h:135
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition TFile.cxx:613
TFile(const TFile &)=delete
Long64_t GetRelOffset() const
Definition TFile.h:251
virtual void SetReadCalls(Int_t readcalls=0)
Definition TFile.h:290
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:4351
virtual void SetCacheWrite(TFileCacheWrite *cache)
Set a pointer to the write cache.
Definition TFile.cxx:2388
TString fOption
File options.
Definition TFile.h:91
virtual Int_t GetNfree() const
Definition TFile.h:238
virtual Long64_t GetEND() const
Definition TFile.h:231
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
Definition TFile.cxx:2476
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
Definition TFile.cxx:2417
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
Definition TFile.cxx:4654
EAsyncOpenStatus
Asynchronous open request status.
Definition TFile.h:64
@ kAOSSuccess
Definition TFile.h:65
@ kAOSNotAsync
Definition TFile.h:64
@ kAOSInProgress
Definition TFile.h:65
@ kAOSFailure
Definition TFile.h:64
virtual void WriteStreamerInfo()
Write the list of TStreamerInfo as a single object in this file The class Streamer description for al...
Definition TFile.cxx:3792
virtual Long64_t GetBytesWritten() const
Return the total number of bytes written so far to the file.
Definition TFile.cxx:4566
ERelativeTo
Definition TFile.h:199
@ kCur
Definition TFile.h:199
@ kBeg
Definition TFile.h:199
@ kEnd
Definition TFile.h:199
virtual Long64_t GetSeekInfo() const
Definition TFile.h:253
Int_t fCompress
Compression level and algorithm.
Definition TFile.h:84
virtual Int_t GetNbytesFree() const
Definition TFile.h:249
virtual Bool_t IsArchive() const
Definition TFile.h:258
static TFile *& CurrentFile()
Return the current ROOT file if any.
Definition TFile.cxx:1067
virtual void SetEND(Long64_t last)
Definition TFile.h:287
virtual void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
See comments for function SetCompressionSettings.
Definition TFile.cxx:2305
virtual const TUrl * GetEndpointUrl() const
Definition TFile.h:235
Int_t fNbytesFree
Number of bytes for free segments structure.
Definition TFile.h:85
Int_t fD
File descriptor.
Definition TFile.h:82
virtual void ResetErrno() const
Method resetting the errno.
Definition TFile.cxx:1254
Int_t Sizeof() const override
Return the size in bytes of the file header.
Definition TFile.cxx:2397
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition TFile.cxx:1158
virtual void IncrementProcessIDs()
Definition TFile.h:257
Bool_t fIsPcmFile
!True if the file is a ROOT pcm file.
Definition TFile.h:107
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition TFile.h:98
virtual Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
Definition TFile.cxx:4497
TFile()
File default Constructor.
Definition TFile.cxx:201
Char_t fUnits
Number of bytes for file pointers.
Definition TFile.h:92
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition TFile.h:95
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:4821
virtual void SetOption(Option_t *option=">")
Definition TFile.h:289
EFileType
File type.
Definition TFile.h:202
@ kWeb
Definition TFile.h:202
@ kDefault
Definition TFile.h:202
@ kLocal
Definition TFile.h:202
@ kMerge
Definition TFile.h:202
@ kNet
Definition TFile.h:202
@ kFile
Definition TFile.h:202
virtual void ShowStreamerInfo()
Show the StreamerInfo of all classes written to this file.
Definition TFile.cxx:3750
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
Definition TFile.cxx:4525
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:4543
virtual Long64_t GetBytesReadExtra() const
Definition TFile.h:242
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:4481
ECacheAction
TTreeCache flushing semantics.
Definition TFile.h:70
@ kDoNotDisconnect
Definition TFile.h:70
@ kDisconnect
Definition TFile.h:70
static UInt_t SetOpenTimeout(UInt_t timeout)
Sets open timeout time (in ms). Returns previous timeout value.
Definition TFile.cxx:4724
virtual void ReadFree()
Read the FREE linked list.
Definition TFile.cxx:1925
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:5003
static ROOT::Internal::RConcurrentHashColl fgTsSIHashes
!TS Set of hashes built from read streamer infos
Definition TFile.h:120
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition TFile.h:77
Long64_t fBytesWrite
Number of bytes written to this file.
Definition TFile.h:75
TArchiveFile * GetArchive() const
Definition TFile.h:220
Bool_t fIsRootFile
!True is this is a ROOT file, raw file otherwise
Definition TFile.h:104
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
Definition TFile.cxx:1141
virtual void DirWriteKeys(TDirectory *)
Definition TFile.h:169
TList * fFree
Free segments linked list table.
Definition TFile.h:93
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition TFile.cxx:5208
std::mutex fWriteMutex
!Lock for writing baskets / keys into the file.
Definition TFile.h:118
void Delete(const char *namecycle="") override
Delete object namecycle.
Definition TFile.cxx:1098
Bool_t fInitDone
!True if the file has been initialized
Definition TFile.h:105
virtual void DrawMap(const char *keys="*", Option_t *option="")
Draw map of objects in this file.
Definition TFile.cxx:1128
virtual void DirWriteHeader(TDirectory *)
Definition TFile.h:170
virtual void MakeFree(Long64_t first, Long64_t last)
Mark unused bytes on the file.
Definition TFile.cxx:1484
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Definition TFile.h:100
TString fRealName
Effective real file name (not original url)
Definition TFile.h:90
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition TFile.cxx:2253
Long64_t fOffset
!Seek offset cache
Definition TFile.h:96
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
Definition TFile.h:130
virtual Int_t GetNbytesInfo() const
Definition TFile.h:248
TList * fInfoCache
!Cached list of the streamer infos in this file
Definition TFile.h:112
virtual Bool_t MustFlush() const
Definition TFile.h:269
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
Definition TFile.cxx:5222
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
Definition TFile.h:127
Int_t MakeProjectParMake(const char *packname, const char *filename)
Create makefile at 'filemake' for PAR package 'pack'.
Definition TFile.cxx:3364
Long64_t fEND
Last used byte in file.
Definition TFile.h:79
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:4089
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4626
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:2436
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
Definition TFile.h:109
bool fGlobalRegistration
! if true, bypass use of global lists
Definition TFile.h:115
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition TFile.h:73
Bool_t fIsArchive
!True if this is a pure archive file
Definition TFile.h:102
TObjArray * GetListOfProcessIDs() const
Definition TFile.h:236
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:950
Int_t GetCompressionAlgorithm() const
Definition TFile.h:385
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition TFile.h:133
virtual Int_t Recover()
Attempt to recover file if not correctly closed.
Definition TFile.cxx:2048
virtual TList * GetStreamerInfoList() final
Read the list of TStreamerInfo objects written to this file.
Definition TFile.cxx:1445
virtual void WriteHeader()
Write File Header.
Definition TFile.cxx:2615
EStatusBits
TFile status bits. BIT(13) is taken up by TObject.
Definition TFile.h:183
@ kRecovered
Definition TFile.h:191
@ kReproducible
Definition TFile.h:197
@ kDevNull
Definition TFile.h:193
@ kHasReferences
Definition TFile.h:192
@ kRedirected
Definition TFile.h:196
@ k630forwardCompatibility
Definition TFile.h:190
@ kWriteError
Definition TFile.h:194
@ kBinaryFile
Definition TFile.h:195
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:3874
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition TFile.h:88
Int_t fWritten
Number of objects written so far.
Definition TFile.h:87
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:1301
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition TFile.cxx:1770
Float_t GetCompressionFactor()
Return the file compression factor.
Definition TFile.cxx:1202
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:4514
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Definition TFile.cxx:4591
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Definition TFile.cxx:1262
Option_t * GetOption() const override
Definition TFile.h:240
static TList * fgAsyncOpenRequests
Definition TFile.h:122
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:28
A doubly linked list.
Definition TList.h:38
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:31
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
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:1046
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition TProcessID.h:74
Stopwatch class.
Definition TStopwatch.h:28
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
This class represents a WWW compatible URL.
Definition TUrl.h:33
const Int_t n
Definition legend1.C:16
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
@ kUseGlobal
Use the global compression algorithm.
Definition Compression.h:93
@ kUseCompiledDefault
Use the compile-time default setting.
Definition Compression.h:53
@ kUseMin
Compression level reserved when we are not sure what to use (1 is for the fastest compression)
Definition Compression.h:72
Simple struct of the return value of GetStreamerInfoListImpl.
Definition TFile.h:145
Int_t fReturnCode
Definition TFile.h:147
ROOT::Internal::RConcurrentHashColl::HashValue fHash
Definition TFile.h:148
TList * fList
Definition TFile.h:146
th1 Draw()