Logo ROOT   6.12/07
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 
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),
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 
172  SysWriteImpl(fD,buffer,size);
173 
174  Init(create || recreate);
175  return;
176 
177 zombie:
178  // Error in opening file; make this a zombie
179  MakeZombie();
180  gDirectory = gROOT;
181 }
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// Copying the content of the TMemFile into another TMemFile.
185 
187  TFile(orig.GetEndpointUrl()->GetUrl(), "WEB", orig.GetTitle(),
188  orig.GetCompressionSettings() ), fBlockList(orig.GetEND()),
190 {
191  fOption = orig.fOption;
192 
193  Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
194  Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
195  Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
196  Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
197  if (!create && !recreate && !update && !read) {
198  read = kTRUE;
199  fOption = "READ";
200  }
201 
202  fD = orig.fD; // not really used, so it is okay to have the same value.
203  fWritable = orig.fWritable;
204 
205  // We intentionally allocated just one big buffer for this object.
207 
208  Init(create || recreate); // A copy is
209 }
210 
211 
212 ////////////////////////////////////////////////////////////////////////////////
213 /// Close and clean-up file.
214 
216 {
217  // Need to call close, now as it will need both our virtual table
218  // and the content of the list of blocks
219  Close();
220  TRACE("destroy")
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// Copy the binary representation of the TMemFile into
225 /// the memory area starting at 'to' and of length at most 'maxsize'
226 /// returns the number of bytes actually copied.
227 
228 Long64_t TMemFile::CopyTo(void *to, Long64_t maxsize) const
229 {
230  Long64_t len = GetSize();
231  if (len > maxsize) {
232  len = maxsize;
233  }
234  Long64_t storedSysOffset = fSysOffset;
235  Long64_t storedBlockOffset = fBlockOffset;
236  TMemBlock *storedBlockSeek = fBlockSeek;
237 
238  const_cast<TMemFile*>(this)->SysSeek(fD, 0, SEEK_SET);
239  len = const_cast<TMemFile*>(this)->SysReadImpl(fD, to, len);
240 
241  const_cast<TMemFile*>(this)->fBlockSeek = storedBlockSeek;
242  const_cast<TMemFile*>(this)->fBlockOffset = storedBlockOffset;
243  const_cast<TMemFile*>(this)->fSysOffset = storedSysOffset;
244  return len;
245 }
246 
247 ////////////////////////////////////////////////////////////////////////////////
248 /// Copy the binary representation of the TMemFile into
249 /// the TBuffer tobuf
250 
252 {
253  const TMemBlock *current = &fBlockList;
254  while(current) {
255  tobuf.WriteFastArray(current->fBuffer,current->fSize);
256  current = current->fNext;
257  }
258 }
259 
260 ////////////////////////////////////////////////////////////////////////////////
261 /// Return the current size of the memory file
262 
264 {
265  // We could also attempt to read it from the beginning of the buffer
266  return fSize;
267 }
268 
269 ////////////////////////////////////////////////////////////////////////////////
270 
271 void TMemFile::Print(Option_t *option /* = "" */) const
272 {
273  Printf("TMemFile: name=%s, title=%s, option=%s", GetName(), GetTitle(), GetOption());
274  if (strcmp(option,"blocks")==0) {
275  const TMemBlock *current = &fBlockList;
276  Int_t counter = 0;
277  while(current) {
278  Printf("TMemBlock: %d size=%lld addr=%p curr=%p prev=%p next=%p",
279  counter,current->fSize,current->fBuffer,
280  current,current->fPrevious,current->fNext);
281  current = current->fNext;
282  ++counter;
283  }
284  } else {
285  GetList()->R__FOR_EACH(TObject,Print)(option);
286  }
287 }
288 
289 ////////////////////////////////////////////////////////////////////////////////
290 /// Wipe all the data from the permanent buffer but keep, the in-memory object
291 /// alive.
292 
294 {
295  ResetObjects(this,info);
296 
297  fNbytesKeys = 0;
298  fSeekKeys = 0;
299 
300  fMustFlush = kTRUE;
301  fInitDone = kFALSE;
302 
303  if (fFree) {
304  fFree->Delete();
305  delete fFree;
306  fFree = 0;
307  }
308  fWritten = 0;
309  fSumBuffer = 0;
310  fSum2Buffer = 0;
311  fBytesRead = 0;
312  fBytesReadExtra = 0;
313  fBytesWrite = 0;
314  delete fClassIndex;
315  fClassIndex = 0;
316  fSeekInfo = 0;
317  fNbytesInfo = 0;
318  delete fProcessIDs;
319  fProcessIDs = 0;
320  fNProcessIDs = 0;
321  fOffset = 0;
322  fCacheRead = 0;
323  fCacheWrite = 0;
324  fReadCalls = 0;
325  if (fFree) {
326  fFree->Delete();
327  delete fFree;
328  fFree = 0;
329  }
330 
331  fSysOffset = 0;
333  fBlockOffset = 0;
334  {
336  gROOT->GetListOfFiles()->Remove(this);
337  }
338 
339  {
340  TDirectory::TContext ctxt(this);
341  Init(kTRUE);
342 
343  // And now we need re-initilize the directories ...
344 
345  TIter next(this->GetList());
346  TObject *idcur;
347  while ((idcur = next())) {
348  if (idcur->IsA() == TDirectoryFile::Class()) {
349  ((TDirectoryFile*)idcur)->ResetAfterMerge(info);
350  }
351  }
352 
353  }
354 }
355 
356 ////////////////////////////////////////////////////////////////////////////////
357 /// Wipe all the data from the permanent buffer but keep, the in-memory object
358 /// alive.
359 
361 {
362  if (directory->GetListOfKeys()) {
363  TIter next(directory->GetListOfKeys());
364  TKey *key;
365  while( (key = (TKey*)next()) ) {
366  if (0 == directory->GetList()->FindObject(key->GetName())) {
367  Warning("ResetObjects","Key/Object %s is not attached to the directory %s and can not be ResetAfterMerge correctly",
368  key->GetName(),directory->GetName());
369  }
370  }
371  directory->GetListOfKeys()->Delete("slow");
372  }
373 
374  TString listHargs;
375  listHargs.Form("(TFileMergeInfo*)0x%lx",(ULong_t)info);
376 
377  TIter next(directory->GetList());
378  TObject *idcur;
379  while ((idcur = next())) {
380  TClass *objcl = idcur->IsA();
381  if (objcl == TDirectoryFile::Class()) {
382  ResetObjects((TDirectoryFile*)idcur,info);
383  } else if (objcl->GetResetAfterMerge()) {
384  (objcl->GetResetAfterMerge())(idcur,info);
385  } else if (idcur->IsA()->GetMethodWithPrototype("ResetAfterMerge", "TFileMergeInfo*") ) {
386  Int_t error = 0;
387  idcur->Execute("ResetAfterMerge", listHargs.Data(), &error);
388  if (error) {
389  Error("ResetObjects", "calling ResetAfterMerge() on '%s' failed.",
390  idcur->GetName());
391  }
392  } else {
393 // Error("ResetObjects","In %s, we can not reset %s (not ResetAfterMerge function)",
394 // directory->GetName(),idcur->GetName());
395  }
396  }
397 }
398 
399 ////////////////////////////////////////////////////////////////////////////////
400 /// Read specified number of bytes from current offset into the buffer.
401 /// See documentation for TFile::SysRead().
402 
404 {
405  TRACE("READ")
406 
407  if (fBlockList.fBuffer == 0) {
408  errno = EBADF;
409  gSystem->SetErrorStr("The memory file is not open.");
410  return 0;
411  } else {
412  // Don't read past the end.
413  if (fSysOffset + len > fSize) {
414  len = fSize - fSysOffset;
415  }
416 
417  if (fBlockOffset+len <= fBlockSeek->fSize) {
418  // 'len' does not go past the end of the current block,
419  // so let's make a simple copy.
420  memcpy(buf,fBlockSeek->fBuffer+fBlockOffset,len);
421  fBlockOffset += len;
422  } else {
423  // We are going to have to copy data from more than one
424  // block.
425 
426  // First copy the end of the first block.
427  Int_t sublen = fBlockSeek->fSize - fBlockOffset;
428  memcpy(buf,fBlockSeek->fBuffer+fBlockOffset,sublen);
429 
430  // Move to the next.
431  buf = (char*)buf + sublen;
432  Int_t len_left = len - sublen;
434 
435  // Copy all the full blocks that are covered by the request.
436  while (len_left > fBlockSeek->fSize) {
438 
439  memcpy(buf, fBlockSeek->fBuffer, fBlockSeek->fSize);
440  buf = (char*)buf + fBlockSeek->fSize;
441  len_left -= fBlockSeek->fSize;
443  }
444 
445  // Copy the data from the last block.
447  memcpy(buf,fBlockSeek->fBuffer, len_left);
448  fBlockOffset = len_left;
449 
450  }
451  fSysOffset += len;
452  return len;
453  }
454 }
455 
456 
457 ////////////////////////////////////////////////////////////////////////////////
458 /// Read specified number of bytes from current offset into the buffer.
459 /// See documentation for TFile::SysRead().
460 
461 Int_t TMemFile::SysRead(Int_t fd, void *buf, Int_t len)
462 {
463  return SysReadImpl(fd, buf, len);
464 }
465 
466 ////////////////////////////////////////////////////////////////////////////////
467 /// Seek to a specified position in the file. See TFile::SysSeek().
468 /// Note that TMemFile does not support seeks when the file is open for write.
469 
471 {
472  TRACE("SEEK")
473  if (whence == SEEK_SET) {
474  fSysOffset = offset;
476  Long64_t counter = 0;
477  while(fBlockSeek->fNext && (counter+fBlockSeek->fSize) < fSysOffset)
478  {
479  counter += fBlockSeek->fSize;
481  }
482  fBlockOffset = fSysOffset - counter; // If we seek past the 'end' of the file, we now have fBlockOffset > fBlockSeek->fSize
483  } else if (whence == SEEK_CUR) {
484 
485  if (offset == 0) {
486  // nothing to do, really
487  } else if (offset > 0) {
488  // Move forward.
489  if ( (fBlockOffset+offset) < fBlockSeek->fSize) {
490  fSysOffset += offset;
491  fBlockOffset += offset;
492  } else {
493  Long64_t counter = fSysOffset;
494  fSysOffset += offset;
495  while(fBlockSeek->fNext && counter < fSysOffset)
496  {
497  counter += fBlockSeek->fSize;
499  }
500  fBlockOffset = fSysOffset - counter; // If we seek past the 'end' of the file, we now have fBlockOffset > fBlockSeek->fSize
501  }
502  } else {
503  // Move backward in the file (offset < 0).
504  Long64_t counter = fSysOffset;
505  fSysOffset += offset;
506  if (fSysOffset < 0) {
507  SysError("TMemFile", "Unable to seek past the beginning of file");
508  fSysOffset = 0;
510  fBlockOffset = 0;
511  return -1;
512  } else {
513  if (offset+fBlockOffset >= 0) {
514  // We are just moving in the current block.
515  fBlockOffset += offset;
516  } else {
517  while(fBlockSeek->fPrevious && counter > fSysOffset)
518  {
519  counter -= fBlockSeek->fSize;
521  }
522  fBlockOffset = fSysOffset - counter;
523  }
524  }
525  }
526  } else if (whence == SEEK_END) {
527  if (offset > 0) {
528  SysError("TMemFile", "Unable to seek past end of file");
529  return -1;
530  }
531  if (fSize == -1) {
532  SysError("TMemFile", "Unable to seek to end of file");
533  return -1;
534  }
535  fSysOffset = fSize;
536  } else {
537  SysError("TMemFile", "Unknown whence!");
538  return -1;
539  }
540  return fSysOffset;
541 }
542 
543 ////////////////////////////////////////////////////////////////////////////////
544 /// Open a file in 'MemFile'.
545 
546 Int_t TMemFile::SysOpen(const char * /* pathname */, Int_t /* flags */, UInt_t /* mode */)
547 {
548  if (!fBlockList.fBuffer) {
552  }
553  if (fBlockList.fBuffer) {
554  return 0;
555  } else {
556  return -1;
557  }
558 }
559 
560 ////////////////////////////////////////////////////////////////////////////////
561 /// Close the mem file.
562 
564 {
565  return 0;
566 }
567 
568 ////////////////////////////////////////////////////////////////////////////////
569 /// Write a buffer into the file.
570 
571 Int_t TMemFile::SysWriteImpl(Int_t /* fd */, const void *buf, Long64_t len)
572 {
573  TRACE("WRITE")
574 
575  if (fBlockList.fBuffer == 0) {
576  errno = EBADF;
577  gSystem->SetErrorStr("The memory file is not open.");
578  return 0;
579  } else {
580  if (fBlockOffset+len <= fBlockSeek->fSize) {
581  // 'len' does not go past the end of the current block,
582  // so let's make a simple copy.
583  memcpy(fBlockSeek->fBuffer+fBlockOffset,buf,len);
584  fBlockOffset += len;
585  } else {
586  // We are going to have to copy data into more than one
587  // block.
588 
589  // First copy to the end of the first block.
590  Int_t sublen = fBlockSeek->fSize - fBlockOffset;
591  memcpy(fBlockSeek->fBuffer+fBlockOffset,buf,sublen);
592 
593  // Move to the next.
594  buf = (char*)buf + sublen;
595  Int_t len_left = len - sublen;
596  if (!fBlockSeek->fNext) {
598  fSize += fgDefaultBlockSize;
599  }
601 
602  // Copy all the full blocks that are covered by the request.
603  while (len_left > fBlockSeek->fSize) {
605 
606  memcpy(fBlockSeek->fBuffer, buf, fBlockSeek->fSize);
607  buf = (char*)buf + fBlockSeek->fSize;
608  len_left -= fBlockSeek->fSize;
609  if (!fBlockSeek->fNext) {
611  fSize += fgDefaultBlockSize;
612  }
614  }
615 
616  // Copy the data from the last block.
618  memcpy(fBlockSeek->fBuffer, buf, len_left);
619  fBlockOffset = len_left;
620 
621  }
622  fSysOffset += len;
623  return len;
624  }
625 }
626 
627 ////////////////////////////////////////////////////////////////////////////////
628 /// Write a buffer into the file.
629 
630 Int_t TMemFile::SysWrite(Int_t fd, const void *buf, Int_t len)
631 {
632  return SysWriteImpl(fd,buf,len);
633 }
634 
635 ////////////////////////////////////////////////////////////////////////////////
636 /// Perform a stat on the HDFS file; see TFile::SysStat().
637 
638 Int_t TMemFile::SysStat(Int_t, Long_t* /* id */, Long64_t* /* size */, Long_t* /* flags */, Long_t* /* modtime */)
639 {
640  MayNotUse("SysStat");
641  return 0;
642 }
643 
644 ////////////////////////////////////////////////////////////////////////////////
645 /// Sync remaining data to disk.
646 /// Nothing to do here.
647 
649 {
650  return 0;
651 }
652 
653 ////////////////////////////////////////////////////////////////////////////////
654 /// Simply calls TSystem::ResetErrno().
655 
657 {
659 }
void ResetAfterMerge(TFileMergeInfo *)
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:293
~TMemBlock()
Usual destructors. Delete the block memory.
Definition: TMemFile.cxx:65
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition: TObject.cxx:894
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in &#39;MemFile&#39;.
Definition: TMemFile.cxx:546
Long64_t fSysOffset
Seek offset in file.
Definition: TMemFile.h:38
Long64_t fSize
Total file size (sum of the size of the chunks)
Definition: TMemFile.h:37
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:91
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition: TFile.h:88
long long Long64_t
Definition: RtypesCore.h:69
Long64_t fBytesWrite
Number of bytes written to this file.
Definition: TFile.h:68
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:66
Long64_t fSeekKeys
Location of Keys record on file.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition: TFile.h:87
const char Option_t
Definition: RtypesCore.h:62
Int_t SysClose(Int_t fd)
Close the mem file.
Definition: TMemFile.cxx:563
Long64_t fBlockOffset
Seek offset within the block.
Definition: TMemFile.h:40
UChar_t * fBuffer
Definition: TMemFile.h:33
TMemBlock * fPrevious
Definition: TMemFile.h:31
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1112
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
#define R__ASSERT(e)
Definition: TError.h:96
#define gROOT
Definition: TROOT.h:402
Basic string class.
Definition: TString.h:125
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file.
Definition: TMemFile.cxx:630
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:57
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition: TFile.h:70
virtual void Print(Option_t *option="") const
Print all objects in the file.
Definition: TMemFile.cxx:271
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:74
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:82
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Definition: TMemFile.h:17
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition: TFile.h:79
Int_t fD
File descriptor.
Definition: TFile.h:75
void Class()
Definition: Class.C:29
void ResetErrno() const
Simply calls TSystem::ResetErrno().
Definition: TMemFile.cxx:656
TMemBlock()
Default constructor.
Definition: TMemFile.cxx:48
Int_t SysSync(Int_t fd)
Sync remaining data to disk.
Definition: TMemFile.cxx:648
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
virtual TList * GetList() const
Definition: TDirectory.h:149
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:57
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual Long64_t GetSize() const
Return the current size of the memory file.
Definition: TMemFile.cxx:263
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:461
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
#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:39
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2343
TMemBlock * fNext
Definition: TMemFile.h:32
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
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:638
TMemBlock fBlockList
Colletion of memory blocks of size fBlockSize.
Definition: TMemFile.h:36
virtual ~TMemFile()
Close and clean-up file.
Definition: TMemFile.cxx:215
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition: TFile.cxx:596
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
void ResetObjects(TDirectoryFile *, TFileMergeInfo *) const
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:360
Bool_t fWritable
True if directory is writable.
Option_t * GetOption() const
Definition: TFile.h:211
#define Printf
Definition: TGeoToOCC.h:18
const Bool_t kFALSE
Definition: RtypesCore.h:88
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition: TFile.h:67
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:470
TList * fFree
Free segments linked list table.
Definition: TFile.h:86
static Long64_t fgDefaultBlockSize
Definition: TMemFile.h:42
void CreateNext(Long64_t size)
Definition: TMemFile.cxx:73
#define ClassImp(name)
Definition: Rtypes.h:359
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
unsigned long ULong_t
Definition: RtypesCore.h:51
Long64_t fSize
Definition: TMemFile.h:34
#define R__LOCKGUARD(mutex)
TString fOption
File options.
Definition: TFile.h:84
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition: TFile.h:99
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Long64_t GetEND() const
Definition: TFile.h:202
virtual const TUrl * GetEndpointUrl() const
Definition: TFile.h:206
Int_t SysReadImpl(Int_t fd, void *buf, Long64_t len)
Read specified number of bytes from current offset into the buffer.
Definition: TMemFile.cxx:403
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
virtual TList * GetListOfKeys() const
void MakeZombie()
Definition: TObject.h:49
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition: TFile.h:81
static void ResetErrno()
Static function resetting system error number.
Definition: TSystem.cxx:284
#define gDirectory
Definition: TDirectory.h:213
unsigned char UChar_t
Definition: RtypesCore.h:34
Int_t fWritten
Number of objects written so far.
Definition: TFile.h:80
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:89
void SetErrorStr(const char *errstr)
Set the system error string.
Definition: TSystem.cxx:249
Bool_t fInitDone
!True if the file has been initialized
Definition: TFile.h:98
virtual Long64_t CopyTo(void *to, Long64_t maxsize) const
Copy the binary representation of the TMemFile into the memory area starting at &#39;to&#39; and of length at...
Definition: TMemFile.cxx:228
const Bool_t kTRUE
Definition: RtypesCore.h:87
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:69
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
Int_t GetCompressionSettings() const
Definition: TFile.h:378
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Int_t fNbytesKeys
Number of bytes for the keys.
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Definition: TFile.h:93
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:916
Int_t SysWriteImpl(Int_t fd, const void *buf, Long64_t len)
Write a buffer into the file.
Definition: TMemFile.cxx:571
const char * Data() const
Definition: TString.h:345