ROOT  6.06/09
Reference Guide
TMemFile.cxx
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Philippe Canal, May 2011
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, 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 /**
13 \class TMemFile TMemFile.cxx
14 \ingroup IO
15 
16 A TMemFile is like a normal TFile except that it reads and writes
17 only from memory.
18 */
19 
20 #include "TMemFile.h"
21 #include "TError.h"
22 #include "TSystem.h"
23 #include "TROOT.h"
24 #include "TArrayC.h"
25 #include "TKey.h"
26 #include "TClass.h"
27 #include "TVirtualMutex.h"
28 #include <errno.h>
29 #include <stdio.h>
30 #include <sys/stat.h>
31 
32 // The following snippet is used for developer-level debugging
33 #define TMemFile_TRACE
34 #ifndef TMemFile_TRACE
35 #define TRACE(x) \
36  Debug("TMemFile", "%s", x);
37 #else
38 #define TRACE(x);
39 #endif
40 
42 
43 Long64_t TMemFile::fgDefaultBlockSize = 2*1024*1024;
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Default constructor.
47 
48 TMemFile::TMemBlock::TMemBlock() : fPrevious(0), fNext(0), fBuffer(0), fSize(0)
49 {
50 }
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Constructor allocating the memory buffer.
54 
56  fPrevious(previous), fNext(0), fBuffer(0), fSize(0)
57 {
58  fBuffer = new UChar_t[size];
59  fSize = size;
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// Usual destructors. Delete the block memory.
64 
66 {
67  delete fNext;
68  delete [] fBuffer;
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 
74 {
75  R__ASSERT(fNext == 0);
76  fNext = new TMemBlock(size,this);
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Usual Constructor. See the TFile constructor for details.
81 
82 TMemFile::TMemFile(const char *path, Option_t *option,
83  const char *ftitle, Int_t compress) :
84  TFile(path, "WEB", ftitle, compress),
86 {
87  fOption = option;
88  fOption.ToUpper();
89  if (fOption == "NEW") fOption = "CREATE";
90  Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
91  Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
92  Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
93  Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
94  if (!create && !recreate && !update && !read) {
95  read = kTRUE;
96  fOption = "READ";
97  }
98 
99  if (!(create || recreate)) {
100  Error("TMemFile","Reading a TMemFile requires a memory buffer\n");
101  goto zombie;
102  }
103  if (create || update || recreate) {
104  Int_t mode = O_RDWR | O_CREAT;
105  if (recreate) mode |= O_TRUNC;
106 
107  fD = SysOpen(path, O_RDWR | O_CREAT, 0644);
108  if (fD == -1) {
109  SysError("TMemFile", "file %s can not be opened", path);
110  goto zombie;
111  }
112  fWritable = kTRUE;
113  } else {
114  fD = SysOpen(path, O_RDONLY, 0644);
115  if (fD == -1) {
116  SysError("TMemFile", "file %s can not be opened for reading", path);
117  goto zombie;
118  }
119  fWritable = kFALSE;
120  }
121 
122  Init(create || recreate);
123 
124  return;
125 
126 zombie:
127  // Error in opening file; make this a zombie
128  MakeZombie();
129  gDirectory = gROOT;
130 }
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 /// Usual Constructor. See the TFile constructor for details.
134 
135 TMemFile::TMemFile(const char *path, char *buffer, Long64_t size, Option_t *option,
136  const char *ftitle, Int_t compress):
137  TFile(path, "WEB", ftitle, compress), fBlockList(size),
138  fSize(size), fSysOffset(0), fBlockSeek(&(fBlockList)), fBlockOffset(0)
139 {
140  fOption = option;
141  fOption.ToUpper();
142  Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
143  Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
144  Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
145  Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
146  if (!create && !recreate && !update && !read) {
147  read = kTRUE;
148  fOption = "READ";
149  }
150 
151  if (create || update || recreate) {
152  Int_t mode = O_RDWR | O_CREAT;
153  if (recreate) mode |= O_TRUNC;
154 
155  fD = SysOpen(path, O_RDWR | O_CREAT, 0644);
156  if (fD == -1) {
157  SysError("TMemFile", "file %s can not be opened", path);
158  goto zombie;
159  }
160  fWritable = kTRUE;
161 
162  } else {
163  fD = SysOpen(path, O_RDONLY, 0644);
164  if (fD == -1) {
165  SysError("TMemFile", "file %s can not be opened for reading", path);
166  goto zombie;
167  }
168  fWritable = kFALSE;
169  }
170 
171  SysWrite(fD,buffer,size);
172 
173  Init(create || recreate);
174  return;
175 
176 zombie:
177  // Error in opening file; make this a zombie
178  MakeZombie();
179  gDirectory = gROOT;
180 }
181 
182 ////////////////////////////////////////////////////////////////////////////////
183 /// Copying the content of the TMemFile into another TMemFile.
184 
186  TFile(orig.GetEndpointUrl()->GetUrl(), "WEB", orig.GetTitle(),
187  orig.GetCompressionSettings() ), fBlockList(orig.GetEND()),
188  fSize(orig.GetEND()), fSysOffset(0), fBlockSeek(&(fBlockList)), fBlockOffset(0)
189 {
190  fOption = orig.fOption;
191 
192  Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
193  Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
194  Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
195  Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
196  if (!create && !recreate && !update && !read) {
197  read = kTRUE;
198  fOption = "READ";
199  }
200 
201  fD = orig.fD; // not really used, so it is okay to have the same value.
202  fWritable = orig.fWritable;
203 
204  // We intentionally allocated just one big buffer for this object.
206 
207  Init(create || recreate); // A copy is
208 }
209 
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 /// Close and clean-up file.
213 
215 {
216  // Need to call close, now as it will need both our virtual table
217  // and the content of the list of blocks
218  Close();
219  TRACE("destroy")
220 }
221 
222 ////////////////////////////////////////////////////////////////////////////////
223 /// Copy the binary representation of the TMemFile into
224 /// the memory area starting at 'to' and of length at most 'maxsize'
225 /// returns the number of bytes actually copied.
226 
228 {
229  Long64_t len = GetSize();
230  if (len > maxsize) {
231  len = maxsize;
232  }
233  Long64_t storedSysOffset = fSysOffset;
234  Long64_t storedBlockOffset = fBlockOffset;
235  TMemBlock *storedBlockSeek = fBlockSeek;
236 
237  const_cast<TMemFile*>(this)->SysSeek(fD, 0, SEEK_SET);
238  len = const_cast<TMemFile*>(this)->SysRead(fD, to, len);
239 
240  const_cast<TMemFile*>(this)->fBlockSeek = storedBlockSeek;
241  const_cast<TMemFile*>(this)->fBlockOffset = storedBlockOffset;
242  const_cast<TMemFile*>(this)->fSysOffset = storedSysOffset;
243  return len;
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// Copy the binary representation of the TMemFile into
248 /// the TBuffer tobuf
249 
251 {
252  const TMemBlock *current = &fBlockList;
253  while(current) {
254  tobuf.WriteFastArray(current->fBuffer,current->fSize);
255  current = current->fNext;
256  }
257 }
258 
259 ////////////////////////////////////////////////////////////////////////////////
260 /// Return the current size of the memory file
261 
263 {
264  // We could also attempt to read it from the beginning of the buffer
265  return fSize;
266 }
267 
268 ////////////////////////////////////////////////////////////////////////////////
269 
270 void TMemFile::Print(Option_t *option /* = "" */) const
271 {
272  Printf("TMemFile: name=%s, title=%s, option=%s", GetName(), GetTitle(), GetOption());
273  if (strcmp(option,"blocks")==0) {
274  const TMemBlock *current = &fBlockList;
275  Int_t counter = 0;
276  while(current) {
277  Printf("TMemBlock: %d size=%lld addr=%p curr=%p prev=%p next=%p",
278  counter,current->fSize,current->fBuffer,
279  current,current->fPrevious,current->fNext);
280  current = current->fNext;
281  ++counter;
282  }
283  } else {
284  GetList()->R__FOR_EACH(TObject,Print)(option);
285  }
286 }
287 
288 ////////////////////////////////////////////////////////////////////////////////
289 /// Wipe all the data from the permanent buffer but keep, the in-memory object
290 /// alive.
291 
293 {
294  ResetObjects(this,info);
295 
296  fNbytesKeys = 0;
297  fSeekKeys = 0;
298 
299  fMustFlush = kTRUE;
300  fInitDone = kFALSE;
301 
302  if (fFree) {
303  fFree->Delete();
304  delete fFree;
305  fFree = 0;
306  }
307  fWritten = 0;
308  fSumBuffer = 0;
309  fSum2Buffer = 0;
310  fBytesRead = 0;
311  fBytesReadExtra = 0;
312  fBytesWrite = 0;
313  delete fClassIndex;
314  fClassIndex = 0;
315  fSeekInfo = 0;
316  fNbytesInfo = 0;
317  delete fProcessIDs;
318  fProcessIDs = 0;
319  fNProcessIDs = 0;
320  fOffset = 0;
321  fCacheRead = 0;
322  fCacheWrite = 0;
323  fReadCalls = 0;
324  if (fFree) {
325  fFree->Delete();
326  delete fFree;
327  fFree = 0;
328  }
329 
330  fSysOffset = 0;
332  fBlockOffset = 0;
333  {
335  gROOT->GetListOfFiles()->Remove(this);
336  }
337 
338  {
339  TDirectory::TContext ctxt(this);
340  Init(kTRUE);
341 
342  // And now we need re-initilize the directories ...
343 
344  TIter next(this->GetList());
345  TObject *idcur;
346  while ((idcur = next())) {
347  if (idcur->IsA() == TDirectoryFile::Class()) {
348  ((TDirectoryFile*)idcur)->ResetAfterMerge(info);
349  }
350  }
351 
352  }
353 }
354 
355 ////////////////////////////////////////////////////////////////////////////////
356 /// Wipe all the data from the permanent buffer but keep, the in-memory object
357 /// alive.
358 
360 {
361  if (directory->GetListOfKeys()) {
362  TIter next(directory->GetListOfKeys());
363  TKey *key;
364  while( (key = (TKey*)next()) ) {
365  if (0 == directory->GetList()->FindObject(key->GetName())) {
366  Warning("ResetObjects","Key/Object %s is not attached to the directory %s and can not be ResetAfterMerge correctly",
367  key->GetName(),directory->GetName());
368  }
369  }
370  directory->GetListOfKeys()->Delete("slow");
371  }
372 
373  TString listHargs;
374  listHargs.Form("(TFileMergeInfo*)0x%lx",(ULong_t)info);
375 
376  TIter next(directory->GetList());
377  TObject *idcur;
378  while ((idcur = next())) {
379  TClass *objcl = idcur->IsA();
380  if (objcl == TDirectoryFile::Class()) {
381  ResetObjects((TDirectoryFile*)idcur,info);
382  } else if (objcl->GetResetAfterMerge()) {
383  (objcl->GetResetAfterMerge())(idcur,info);
384  } else if (idcur->IsA()->GetMethodWithPrototype("ResetAfterMerge", "TFileMergeInfo*") ) {
385  Int_t error = 0;
386  idcur->Execute("ResetAfterMerge", listHargs.Data(), &error);
387  if (error) {
388  Error("ResetObjects", "calling ResetAfterMerge() on '%s' failed.",
389  idcur->GetName());
390  }
391  } else {
392 // Error("ResetObjects","In %s, we can not reset %s (not ResetAfterMerge function)",
393 // directory->GetName(),idcur->GetName());
394  }
395  }
396 }
397 
398 ////////////////////////////////////////////////////////////////////////////////
399 /// Read specified number of bytes from current offset into the buffer.
400 /// See documentation for TFile::SysRead().
401 
403 {
404  TRACE("READ")
405 
406  if (fBlockList.fBuffer == 0) {
407  errno = EBADF;
408  gSystem->SetErrorStr("The memory file is not open.");
409  return 0;
410  } else {
411  // Don't read past the end.
412  if (fSysOffset + len > fSize) {
413  len = fSize - fSysOffset;
414  }
415 
416  if (fBlockOffset+len <= fBlockSeek->fSize) {
417  // 'len' does not go past the end of the current block,
418  // so let's make a simple copy.
419  memcpy(buf,fBlockSeek->fBuffer+fBlockOffset,len);
420  fBlockOffset += len;
421  } else {
422  // We are going to have to copy data from more than one
423  // block.
424 
425  // First copy the end of the first block.
426  Int_t sublen = fBlockSeek->fSize - fBlockOffset;
427  memcpy(buf,fBlockSeek->fBuffer+fBlockOffset,sublen);
428 
429  // Move to the next.
430  buf = (char*)buf + sublen;
431  Int_t len_left = len - sublen;
433 
434  // Copy all the full blocks that are covered by the request.
435  while (len_left > fBlockSeek->fSize) {
437 
438  memcpy(buf, fBlockSeek->fBuffer, fBlockSeek->fSize);
439  buf = (char*)buf + fBlockSeek->fSize;
440  len_left -= fBlockSeek->fSize;
442  }
443 
444  // Copy the data from the last block.
446  memcpy(buf,fBlockSeek->fBuffer, len_left);
447  fBlockOffset = len_left;
448 
449  }
450  fSysOffset += len;
451  return len;
452  }
453 }
454 
455 ////////////////////////////////////////////////////////////////////////////////
456 /// Seek to a specified position in the file. See TFile::SysSeek().
457 /// Note that TMemFile does not support seeks when the file is open for write.
458 
460 {
461  TRACE("SEEK")
462  if (whence == SEEK_SET) {
463  fSysOffset = offset;
465  Long64_t counter = 0;
466  while(fBlockSeek->fNext && (counter+fBlockSeek->fSize) < fSysOffset)
467  {
468  counter += fBlockSeek->fSize;
470  }
471  fBlockOffset = fSysOffset - counter; // If we seek past the 'end' of the file, we now have fBlockOffset > fBlockSeek->fSize
472  } else if (whence == SEEK_CUR) {
473 
474  if (offset == 0) {
475  // nothing to do, really
476  } else if (offset > 0) {
477  // Move forward.
478  if ( (fBlockOffset+offset) < fBlockSeek->fSize) {
479  fSysOffset += offset;
480  fBlockOffset += offset;
481  } else {
482  Long64_t counter = fSysOffset;
483  fSysOffset += offset;
484  while(fBlockSeek->fNext && counter < fSysOffset)
485  {
486  counter += fBlockSeek->fSize;
488  }
489  fBlockOffset = fSysOffset - counter; // If we seek past the 'end' of the file, we now have fBlockOffset > fBlockSeek->fSize
490  }
491  } else {
492  // Move backward in the file (offset < 0).
493  Long64_t counter = fSysOffset;
494  fSysOffset += offset;
495  if (fSysOffset < 0) {
496  SysError("TMemFile", "Unable to seek past the beginning of file");
497  fSysOffset = 0;
499  fBlockOffset = 0;
500  return -1;
501  } else {
502  if (offset+fBlockOffset >= 0) {
503  // We are just moving in the current block.
504  fBlockOffset += offset;
505  } else {
506  while(fBlockSeek->fPrevious && counter > fSysOffset)
507  {
508  counter -= fBlockSeek->fSize;
510  }
511  fBlockOffset = fSysOffset - counter;
512  }
513  }
514  }
515  } else if (whence == SEEK_END) {
516  if (offset > 0) {
517  SysError("TMemFile", "Unable to seek past end of file");
518  return -1;
519  }
520  if (fSize == -1) {
521  SysError("TMemFile", "Unable to seek to end of file");
522  return -1;
523  }
524  fSysOffset = fSize;
525  } else {
526  SysError("TMemFile", "Unknown whence!");
527  return -1;
528  }
529  return fSysOffset;
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Open a file in 'MemFile'.
534 
535 Int_t TMemFile::SysOpen(const char * /* pathname */, Int_t /* flags */, UInt_t /* mode */)
536 {
537  if (!fBlockList.fBuffer) {
541  }
542  if (fBlockList.fBuffer) {
543  return 0;
544  } else {
545  return -1;
546  }
547 }
548 
549 ////////////////////////////////////////////////////////////////////////////////
550 /// Close the mem file.
551 
553 {
554  return 0;
555 }
556 
557 ////////////////////////////////////////////////////////////////////////////////
558 /// Write a buffer into the file.
559 
560 Int_t TMemFile::SysWrite(Int_t /* fd */, const void *buf, Int_t len)
561 {
562  TRACE("WRITE")
563 
564  if (fBlockList.fBuffer == 0) {
565  errno = EBADF;
566  gSystem->SetErrorStr("The memory file is not open.");
567  return 0;
568  } else {
569  if (fBlockOffset+len <= fBlockSeek->fSize) {
570  // 'len' does not go past the end of the current block,
571  // so let's make a simple copy.
572  memcpy(fBlockSeek->fBuffer+fBlockOffset,buf,len);
573  fBlockOffset += len;
574  } else {
575  // We are going to have to copy data into more than one
576  // block.
577 
578  // First copy to the end of the first block.
579  Int_t sublen = fBlockSeek->fSize - fBlockOffset;
580  memcpy(fBlockSeek->fBuffer+fBlockOffset,buf,sublen);
581 
582  // Move to the next.
583  buf = (char*)buf + sublen;
584  Int_t len_left = len - sublen;
585  if (!fBlockSeek->fNext) {
587  fSize += fgDefaultBlockSize;
588  }
590 
591  // Copy all the full blocks that are covered by the request.
592  while (len_left > fBlockSeek->fSize) {
594 
595  memcpy(fBlockSeek->fBuffer, buf, fBlockSeek->fSize);
596  buf = (char*)buf + fBlockSeek->fSize;
597  len_left -= fBlockSeek->fSize;
598  if (!fBlockSeek->fNext) {
600  fSize += fgDefaultBlockSize;
601  }
603  }
604 
605  // Copy the data from the last block.
607  memcpy(fBlockSeek->fBuffer, buf, len_left);
608  fBlockOffset = len_left;
609 
610  }
611  fSysOffset += len;
612  return len;
613  }
614 }
615 
616 ////////////////////////////////////////////////////////////////////////////////
617 /// Perform a stat on the HDFS file; see TFile::SysStat().
618 
619 Int_t TMemFile::SysStat(Int_t, Long_t* /* id */, Long64_t* /* size */, Long_t* /* flags */, Long_t* /* modtime */)
620 {
621  MayNotUse("SysStat");
622  return 0;
623 }
624 
625 ////////////////////////////////////////////////////////////////////////////////
626 /// Sync remaining data to disk.
627 /// Nothing to do here.
628 
630 {
631  return 0;
632 }
633 
634 ////////////////////////////////////////////////////////////////////////////////
635 /// Simply calls TSystem::ResetErrno().
636 
638 {
640 }
void ResetAfterMerge(TFileMergeInfo *)
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:292
~TMemBlock()
Usual destructors. Delete the block memory.
Definition: TMemFile.cxx:65
virtual Long64_t CopyTo(void *to, Long64_t maxsize) const
Copy the binary representation of the TMemFile into the memory area starting at 'to' and of length at...
Definition: TMemFile.cxx:227
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in 'MemFile'.
Definition: TMemFile.cxx:535
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
double read(const std::string &file_name)
reading
Long64_t fSysOffset
Seek offset in file.
Definition: TMemFile.h:40
Long64_t fSize
Total file size (sum of the size of the chunks)
Definition: TMemFile.h:39
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:85
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:404
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition: TFile.h:82
long long Long64_t
Definition: RtypesCore.h:69
Long64_t fBytesWrite
Number of bytes written to this file.
Definition: TFile.h:62
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:60
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Long64_t fSeekKeys
Location of Keys record on file.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition: TFile.h:81
const char Option_t
Definition: RtypesCore.h:62
Int_t SysClose(Int_t fd)
Close the mem file.
Definition: TMemFile.cxx:552
Long64_t fBlockOffset
Seek offset within the block.
Definition: TMemFile.h:42
#define gDirectory
Definition: TDirectory.h:218
virtual TList * GetListOfKeys() const
virtual TList * GetList() const
Definition: TDirectory.h:154
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:971
UChar_t * fBuffer
Definition: TMemFile.h:35
TMemBlock * fPrevious
Definition: TMemFile.h:33
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
void ResetErrno() const
Simply calls TSystem::ResetErrno().
Definition: TMemFile.cxx:637
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1101
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
#define R__ASSERT(e)
Definition: TError.h:98
#define gROOT
Definition: TROOT.h:340
virtual Long64_t GetSize() const
Return the current size of the memory file.
Definition: TMemFile.cxx:262
Basic string class.
Definition: TString.h:137
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file.
Definition: TMemFile.cxx:560
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:63
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition: TFile.h:64
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:68
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:76
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Definition: TMemFile.h:19
const char * Data() const
Definition: TString.h:349
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition: TFile.h:73
Option_t * GetOption() const
Definition: TFile.h:200
Int_t fD
File descriptor.
Definition: TFile.h:69
void Class()
Definition: Class.C:29
virtual void Print(Option_t *option="") const
Print all objects in the file.
Definition: TMemFile.cxx:270
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
if(pyself &&pyself!=Py_None)
Int_t SysSync(Int_t fd)
Sync remaining data to disk.
Definition: TMemFile.cxx:629
const int maxsize
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:59
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Read specified number of bytes from current offset into the buffer.
Definition: TMemFile.cxx:402
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
#define TRACE(x)
Definition: TMemFile.cxx:38
A ROOT file is structured in Directories (like a file system).
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
TMemBlock * fBlockSeek
Pointer to the block we seeked to.
Definition: TMemFile.h:41
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
TMemBlock * fNext
Definition: TMemFile.h:34
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Perform a stat on the HDFS file; see TFile::SysStat().
Definition: TMemFile.cxx:619
TMemBlock fBlockList
Colletion of memory blocks of size fBlockSize.
Definition: TMemFile.h:38
virtual ~TMemFile()
Close and clean-up file.
Definition: TMemFile.cxx:214
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition: TFile.cxx:581
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
Bool_t fWritable
True if directory is writable.
#define Printf
Definition: TGeoToOCC.h:18
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition: TFile.h:61
long Long_t
Definition: RtypesCore.h:50
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Seek to a specified position in the file.
Definition: TMemFile.cxx:459
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition: TObject.cxx:932
TList * fFree
Free segments linked list table.
Definition: TFile.h:80
static Long64_t fgDefaultBlockSize
Definition: TMemFile.h:44
void CreateNext(Long64_t size)
Definition: TMemFile.cxx:73
#define ClassImp(name)
Definition: Rtypes.h:279
unsigned long ULong_t
Definition: RtypesCore.h:51
void ResetObjects(TDirectoryFile *, TFileMergeInfo *) const
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:359
Long64_t fSize
Definition: TMemFile.h:36
TString fOption
File options.
Definition: TFile.h:78
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition: TFile.h:93
Mother of all ROOT objects.
Definition: TObject.h:58
TMemFile(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1)
Usual Constructor. See the TFile constructor for details.
Definition: TMemFile.cxx:82
void MakeZombie()
Definition: TObject.h:68
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition: TFile.h:75
static void ResetErrno()
Static function resetting system error number.
Definition: TSystem.cxx:280
unsigned char UChar_t
Definition: RtypesCore.h:34
Int_t fWritten
Number of objects written so far.
Definition: TFile.h:74
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:83
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
Return the wrapper around Merge.
Definition: TClass.cxx:6877
void SetErrorStr(const char *errstr)
Set the system error string.
Definition: TSystem.cxx:245
Bool_t fInitDone
!True if the file has been initialized
Definition: TFile.h:92
const Bool_t kTRUE
Definition: Rtypes.h:91
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:63
Int_t fNbytesKeys
Number of bytes for the keys.
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Definition: TFile.h:87
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904