Logo ROOT   6.14/05
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 ///
55 /// \param size: size of the buffer to be allocated. A value of -1 means that
56 /// no allocation should happen, leaving fBuffer and fSize at 0.
57 ///
58 /// \param previous: previous TMemBlock, used to set up the linked list.
59 
61  fPrevious(previous), fNext(0), fBuffer(0), fSize(0)
62 {
63  // size will be -1 when copying an existing buffer into fBuffer.
64  if (size != -1) {
65  fBuffer = new UChar_t[size];
66  fSize = size;
67  }
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Constructor not allocating the memory buffer, for external ownership.
72 
74  fPrevious(nullptr), fNext(nullptr), fBuffer(data), fSize(size)
75 {}
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Usual destructors. Delete the block memory.
79 
81 {
82  delete fNext;
83  delete [] fBuffer;
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 
89 {
90  R__ASSERT(fNext == 0);
91  fNext = new TMemBlock(size,this);
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Parse option strings and set fOption.
97 {
98  fOption = option;
99  fOption.ToUpper();
100  if (fOption == "NEW") fOption = "CREATE";
101 
102  EMode mode = EMode::kRead;
103  if (fOption == "CREATE")
104  mode = EMode::kCreate;
105  else if (fOption == "RECREATE")
106  mode = EMode::kRecreate;
107  else if (fOption == "UPDATE")
108  mode = EMode::kUpdate;
109  else {
110  fOption = "READ";
111  }
112 
113  return mode;
114 }
115 
116 ////////////////////////////////////////////////////////////////////////////////
117 /// Constructor to create a TMemFile re-using external storage.
118 
120  TFile(path, "WEB", "read-only memfile", 0 /*compress*/),
121  fBlockList(reinterpret_cast<UChar_t*>(const_cast<char*>(data->data())), data->size()),
122  fExternalData(std::move(data)), fSize(fExternalData->size()), fSysOffset(0), fBlockSeek(nullptr), fBlockOffset(0)
123 {
124  EMode optmode = ParseOption("READ");
125  if (NeedsToWrite(optmode)) {
126  SysError("TMemFile", "file %s can not be opened", path);
127  // Error in opening file; make this a zombie
128  MakeZombie();
129  gDirectory = gROOT;
130  return;
131  }
132 
133  fD = 0;
134  fWritable = kFALSE;
135 
136  Init(!NeedsExistingFile(optmode));
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 /// Usual Constructor. See the TFile constructor for details.
141 
142 TMemFile::TMemFile(const char *path, Option_t *option,
143  const char *ftitle, Int_t compress) :
144  TMemFile(path, nullptr, -1, option, ftitle, compress) {}
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 /// Usual Constructor. See the TFile constructor for details. Copy data from buffer.
148 
149 TMemFile::TMemFile(const char *path, char *buffer, Long64_t size, Option_t *option,
150  const char *ftitle, Int_t compress):
151  TFile(path, "WEB", ftitle, compress), fBlockList(size),
153 {
154  EMode optmode = ParseOption(option);
155 
156  if (NeedsToWrite(optmode)) {
157  Int_t mode = O_RDWR | O_CREAT;
158  if (optmode == EMode::kRecreate) mode |= O_TRUNC;
159 
160  fD = SysOpen(path, O_RDWR | O_CREAT, 0644);
161  if (fD == -1) {
162  SysError("TMemFile", "file %s can not be opened", path);
163  goto zombie;
164  }
165  fWritable = kTRUE;
166 
167  } else {
168  fD = SysOpen(path, O_RDONLY, 0644);
169  if (fD == -1) {
170  SysError("TMemFile", "file %s can not be opened for reading", path);
171  goto zombie;
172  }
173  fWritable = kFALSE;
174  }
175 
176 
177  if (buffer)
178  SysWriteImpl(fD,buffer,size);
179 
180  Init(!NeedsExistingFile(optmode));
181  return;
182 
183 zombie:
184  // Error in opening file; make this a zombie
185  MakeZombie();
186  gDirectory = gROOT;
187 }
188 
189 ////////////////////////////////////////////////////////////////////////////////
190 /// Copying the content of the TMemFile into another TMemFile.
191 
193  TFile(orig.GetEndpointUrl()->GetUrl(), "WEB", orig.GetTitle(),
196 {
197  EMode optmode = ParseOption(orig.fOption);
198 
199  fD = orig.fD; // not really used, so it is okay to have the same value.
200  fWritable = orig.fWritable;
201 
202  if (!fExternalData) {
203  // We intentionally allocated just one big buffer for this object.
205  }
206 
207  Init(!NeedsExistingFile(optmode)); // 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  if (fExternalData) {
220  // Do not delete external buffer, we don't own it.
221  fBlockList.fBuffer = nullptr;
222  // We must not get extra blocks, as writing is disabled for external data!
223  R__ASSERT(!fBlockList.fNext || "External block is not the only one!");
224  }
225  TRACE("destroy")
226 }
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 /// Copy the binary representation of the TMemFile into
230 /// the memory area starting at 'to' and of length at most 'maxsize'
231 /// returns the number of bytes actually copied.
232 
233 Long64_t TMemFile::CopyTo(void *to, Long64_t maxsize) const
234 {
235  Long64_t len = GetSize();
236  if (len > maxsize) {
237  len = maxsize;
238  }
239  Long64_t storedSysOffset = fSysOffset;
240  Long64_t storedBlockOffset = fBlockOffset;
241  TMemBlock *storedBlockSeek = fBlockSeek;
242 
243  const_cast<TMemFile*>(this)->SysSeek(fD, 0, SEEK_SET);
244  len = const_cast<TMemFile*>(this)->SysReadImpl(fD, to, len);
245 
246  const_cast<TMemFile*>(this)->fBlockSeek = storedBlockSeek;
247  const_cast<TMemFile*>(this)->fBlockOffset = storedBlockOffset;
248  const_cast<TMemFile*>(this)->fSysOffset = storedSysOffset;
249  return len;
250 }
251 
252 ////////////////////////////////////////////////////////////////////////////////
253 /// Copy the binary representation of the TMemFile into
254 /// the TBuffer tobuf
255 
257 {
258  const TMemBlock *current = &fBlockList;
259  while(current) {
260  tobuf.WriteFastArray(current->fBuffer,current->fSize);
261  current = current->fNext;
262  }
263 }
264 
265 ////////////////////////////////////////////////////////////////////////////////
266 /// Return the current size of the memory file
267 
269 {
270  // We could also attempt to read it from the beginning of the buffer
271  return fSize;
272 }
273 
274 ////////////////////////////////////////////////////////////////////////////////
275 
276 void TMemFile::Print(Option_t *option /* = "" */) const
277 {
278  Printf("TMemFile: name=%s, title=%s, option=%s", GetName(), GetTitle(), GetOption());
279  if (strcmp(option,"blocks")==0) {
280  const TMemBlock *current = &fBlockList;
281  Int_t counter = 0;
282  while(current) {
283  Printf("TMemBlock: %d size=%lld addr=%p curr=%p prev=%p next=%p",
284  counter,current->fSize,current->fBuffer,
285  current,current->fPrevious,current->fNext);
286  current = current->fNext;
287  ++counter;
288  }
289  } else {
290  GetList()->R__FOR_EACH(TObject,Print)(option);
291  }
292 }
293 
294 ////////////////////////////////////////////////////////////////////////////////
295 /// Wipe all the data from the permanent buffer but keep, the in-memory object
296 /// alive.
297 
299 {
300  ResetObjects(this,info);
301 
302  fNbytesKeys = 0;
303  fSeekKeys = 0;
304 
305  fMustFlush = kTRUE;
306  fInitDone = kFALSE;
307 
308  if (fFree) {
309  fFree->Delete();
310  delete fFree;
311  fFree = 0;
312  }
313  fWritten = 0;
314  fSumBuffer = 0;
315  fSum2Buffer = 0;
316  fBytesRead = 0;
317  fBytesReadExtra = 0;
318  fBytesWrite = 0;
319  delete fClassIndex;
320  fClassIndex = 0;
321  fSeekInfo = 0;
322  fNbytesInfo = 0;
323  delete fProcessIDs;
324  fProcessIDs = 0;
325  fNProcessIDs = 0;
326  fOffset = 0;
327  fCacheRead = 0;
328  fCacheWrite = 0;
329  fReadCalls = 0;
330  if (fFree) {
331  fFree->Delete();
332  delete fFree;
333  fFree = 0;
334  }
335 
336  fSysOffset = 0;
338  fBlockOffset = 0;
339  {
341  gROOT->GetListOfFiles()->Remove(this);
342  }
343 
344  {
345  TDirectory::TContext ctxt(this);
346  Init(kTRUE);
347 
348  // And now we need re-initilize the directories ...
349 
350  TIter next(this->GetList());
351  TObject *idcur;
352  while ((idcur = next())) {
353  if (idcur->IsA() == TDirectoryFile::Class()) {
354  ((TDirectoryFile*)idcur)->ResetAfterMerge(info);
355  }
356  }
357 
358  }
359 }
360 
361 ////////////////////////////////////////////////////////////////////////////////
362 /// Wipe all the data from the permanent buffer but keep, the in-memory object
363 /// alive.
364 
366 {
367  if (directory->GetListOfKeys()) {
368  TIter next(directory->GetListOfKeys());
369  TKey *key;
370  while( (key = (TKey*)next()) ) {
371  if (0 == directory->GetList()->FindObject(key->GetName())) {
372  Warning("ResetObjects","Key/Object %s is not attached to the directory %s and can not be ResetAfterMerge correctly",
373  key->GetName(),directory->GetName());
374  }
375  }
376  directory->GetListOfKeys()->Delete("slow");
377  }
378 
379  TString listHargs;
380  listHargs.Form("(TFileMergeInfo*)0x%lx",(ULong_t)info);
381 
382  TIter next(directory->GetList());
383  TObject *idcur;
384  while ((idcur = next())) {
385  TClass *objcl = idcur->IsA();
386  if (objcl == TDirectoryFile::Class()) {
387  ResetObjects((TDirectoryFile*)idcur,info);
388  } else if (objcl->GetResetAfterMerge()) {
389  (objcl->GetResetAfterMerge())(idcur,info);
390  } else if (idcur->IsA()->GetMethodWithPrototype("ResetAfterMerge", "TFileMergeInfo*") ) {
391  Int_t error = 0;
392  idcur->Execute("ResetAfterMerge", listHargs.Data(), &error);
393  if (error) {
394  Error("ResetObjects", "calling ResetAfterMerge() on '%s' failed.",
395  idcur->GetName());
396  }
397  } else {
398 // Error("ResetObjects","In %s, we can not reset %s (not ResetAfterMerge function)",
399 // directory->GetName(),idcur->GetName());
400  }
401  }
402 }
403 
404 ////////////////////////////////////////////////////////////////////////////////
405 /// Read specified number of bytes from current offset into the buffer.
406 /// See documentation for TFile::SysRead().
407 
409 {
410  TRACE("READ")
411 
412  if (fBlockSeek == nullptr || fBlockSeek->fBuffer == nullptr) {
413  errno = EBADF;
414  gSystem->SetErrorStr("The memory file is not open.");
415  return 0;
416  } else {
417  // Don't read past the end.
418  if (fSysOffset + len > fSize) {
419  len = fSize - fSysOffset;
420  }
421 
422  if (fBlockOffset+len <= fBlockSeek->fSize) {
423  // 'len' does not go past the end of the current block,
424  // so let's make a simple copy.
425  memcpy(buf,fBlockSeek->fBuffer+fBlockOffset,len);
426  fBlockOffset += len;
427  } else {
428  // We are going to have to copy data from more than one
429  // block.
430 
431  // First copy the end of the first block.
432  Int_t sublen = fBlockSeek->fSize - fBlockOffset;
433  memcpy(buf,fBlockSeek->fBuffer+fBlockOffset,sublen);
434 
435  // Move to the next.
436  buf = (char*)buf + sublen;
437  Int_t len_left = len - sublen;
439 
440  // Copy all the full blocks that are covered by the request.
441  while (len_left > fBlockSeek->fSize) {
443 
444  memcpy(buf, fBlockSeek->fBuffer, fBlockSeek->fSize);
445  buf = (char*)buf + fBlockSeek->fSize;
446  len_left -= fBlockSeek->fSize;
448  }
449 
450  // Copy the data from the last block.
452  memcpy(buf,fBlockSeek->fBuffer, len_left);
453  fBlockOffset = len_left;
454 
455  }
456  fSysOffset += len;
457  return len;
458  }
459 }
460 
461 
462 ////////////////////////////////////////////////////////////////////////////////
463 /// Read specified number of bytes from current offset into the buffer.
464 /// See documentation for TFile::SysRead().
465 
466 Int_t TMemFile::SysRead(Int_t fd, void *buf, Int_t len)
467 {
468  return SysReadImpl(fd, buf, len);
469 }
470 
471 ////////////////////////////////////////////////////////////////////////////////
472 /// Seek to a specified position in the file. See TFile::SysSeek().
473 /// Note that TMemFile does not support seeks when the file is open for write.
474 
476 {
477  TRACE("SEEK")
478  if (whence == SEEK_SET) {
479  fSysOffset = offset;
481  Long64_t counter = 0;
482  while(fBlockSeek->fNext && (counter+fBlockSeek->fSize) < fSysOffset)
483  {
484  counter += fBlockSeek->fSize;
486  }
487  fBlockOffset = fSysOffset - counter; // If we seek past the 'end' of the file, we now have fBlockOffset > fBlockSeek->fSize
488  } else if (whence == SEEK_CUR) {
489 
490  if (offset == 0) {
491  // nothing to do, really
492  } else if (offset > 0) {
493  // Move forward.
494  if ( (fBlockOffset+offset) < fBlockSeek->fSize) {
495  fSysOffset += offset;
496  fBlockOffset += offset;
497  } else {
498  Long64_t counter = fSysOffset;
499  fSysOffset += offset;
500  while(fBlockSeek->fNext && counter < fSysOffset)
501  {
502  counter += fBlockSeek->fSize;
504  }
505  fBlockOffset = fSysOffset - counter; // If we seek past the 'end' of the file, we now have fBlockOffset > fBlockSeek->fSize
506  }
507  } else {
508  // Move backward in the file (offset < 0).
509  Long64_t counter = fSysOffset;
510  fSysOffset += offset;
511  if (fSysOffset < 0) {
512  SysError("TMemFile", "Unable to seek past the beginning of file");
513  fSysOffset = 0;
515  fBlockOffset = 0;
516  return -1;
517  } else {
518  if (offset+fBlockOffset >= 0) {
519  // We are just moving in the current block.
520  fBlockOffset += offset;
521  } else {
522  while(fBlockSeek->fPrevious && counter > fSysOffset)
523  {
524  counter -= fBlockSeek->fSize;
526  }
527  fBlockOffset = fSysOffset - counter;
528  }
529  }
530  }
531  } else if (whence == SEEK_END) {
532  if (offset > 0) {
533  SysError("TMemFile", "Unable to seek past end of file");
534  return -1;
535  }
536  if (fSize == -1) {
537  SysError("TMemFile", "Unable to seek to end of file");
538  return -1;
539  }
540  fSysOffset = fSize;
541  } else {
542  SysError("TMemFile", "Unknown whence!");
543  return -1;
544  }
545  return fSysOffset;
546 }
547 
548 ////////////////////////////////////////////////////////////////////////////////
549 /// Open a file in 'MemFile'.
550 
551 Int_t TMemFile::SysOpen(const char * /* pathname */, Int_t /* flags */, UInt_t /* mode */)
552 {
553  if (!fBlockList.fBuffer) {
557  }
558  if (fBlockList.fBuffer) {
559  return 0;
560  } else {
561  return -1;
562  }
563 }
564 
565 ////////////////////////////////////////////////////////////////////////////////
566 /// Close the mem file.
567 
569 {
570  return 0;
571 }
572 
573 ////////////////////////////////////////////////////////////////////////////////
574 /// Write a buffer into the file.
575 
576 Int_t TMemFile::SysWriteImpl(Int_t /* fd */, const void *buf, Long64_t len)
577 {
578  TRACE("WRITE")
579 
580  if (fExternalData) {
581  gSystem->SetErrorStr("A memory file with shared data is read-only.");
582  return 0;
583  }
584 
585  if (fBlockList.fBuffer == 0) {
586  errno = EBADF;
587  gSystem->SetErrorStr("The memory file is not open.");
588  return 0;
589  } else {
590  if (fBlockOffset+len <= fBlockSeek->fSize) {
591  // 'len' does not go past the end of the current block,
592  // so let's make a simple copy.
593  memcpy(fBlockSeek->fBuffer+fBlockOffset,buf,len);
594  fBlockOffset += len;
595  } else {
596  // We are going to have to copy data into more than one
597  // block.
598 
599  // First copy to the end of the first block.
600  Int_t sublen = fBlockSeek->fSize - fBlockOffset;
601  memcpy(fBlockSeek->fBuffer+fBlockOffset,buf,sublen);
602 
603  // Move to the next.
604  buf = (char*)buf + sublen;
605  Int_t len_left = len - sublen;
606  if (!fBlockSeek->fNext) {
608  fSize += fgDefaultBlockSize;
609  }
611 
612  // Copy all the full blocks that are covered by the request.
613  while (len_left > fBlockSeek->fSize) {
615 
616  memcpy(fBlockSeek->fBuffer, buf, fBlockSeek->fSize);
617  buf = (char*)buf + fBlockSeek->fSize;
618  len_left -= fBlockSeek->fSize;
619  if (!fBlockSeek->fNext) {
621  fSize += fgDefaultBlockSize;
622  }
624  }
625 
626  // Copy the data from the last block.
628  memcpy(fBlockSeek->fBuffer, buf, len_left);
629  fBlockOffset = len_left;
630 
631  }
632  fSysOffset += len;
633  return len;
634  }
635 }
636 
637 ////////////////////////////////////////////////////////////////////////////////
638 /// Write a buffer into the file.
639 
640 Int_t TMemFile::SysWrite(Int_t fd, const void *buf, Int_t len)
641 {
642  return SysWriteImpl(fd,buf,len);
643 }
644 
645 ////////////////////////////////////////////////////////////////////////////////
646 /// Perform a stat on the HDFS file; see TFile::SysStat().
647 
648 Int_t TMemFile::SysStat(Int_t, Long_t* /* id */, Long64_t* /* size */, Long_t* /* flags */, Long_t* /* modtime */)
649 {
650  MayNotUse("SysStat");
651  return 0;
652 }
653 
654 ////////////////////////////////////////////////////////////////////////////////
655 /// Sync remaining data to disk.
656 /// Nothing to do here.
657 
659 {
660  return 0;
661 }
662 
663 ////////////////////////////////////////////////////////////////////////////////
664 /// Simply calls TSystem::ResetErrno().
665 
667 {
669 }
void ResetAfterMerge(TFileMergeInfo *)
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:298
~TMemBlock()
Usual destructors. Delete the block memory.
Definition: TMemFile.cxx:80
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:551
Long64_t fSysOffset
Seek offset in file.
Definition: TMemFile.h:44
Long64_t fSize
Total file size (sum of the size of the chunks)
Definition: TMemFile.h:43
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:92
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:89
long long Long64_t
Definition: RtypesCore.h:69
Long64_t fBytesWrite
Number of bytes written to this file.
Definition: TFile.h:69
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:67
Long64_t fSeekKeys
Location of Keys record on file.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition: TFile.h:88
const char Option_t
Definition: RtypesCore.h:62
Int_t SysClose(Int_t fd)
Close the mem file.
Definition: TMemFile.cxx:568
Long64_t fBlockOffset
Seek offset within the block.
Definition: TMemFile.h:46
UChar_t * fBuffer
Definition: TMemFile.h:38
TMemBlock * fPrevious
Definition: TMemFile.h:36
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:47
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1113
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
#define R__ASSERT(e)
Definition: TError.h:96
#define gROOT
Definition: TROOT.h:410
Basic string class.
Definition: TString.h:131
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file.
Definition: TMemFile.cxx:640
int Int_t
Definition: RtypesCore.h:41
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:57
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition: TFile.h:71
virtual void Print(Option_t *option="") const
Print all objects in the file.
Definition: TMemFile.cxx:276
STL namespace.
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:75
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:83
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:19
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition: TFile.h:80
Int_t fD
File descriptor.
Definition: TFile.h:76
void Class()
Definition: Class.C:29
void ResetErrno() const
Simply calls TSystem::ResetErrno().
Definition: TMemFile.cxx:666
TMemBlock()
Default constructor.
Definition: TMemFile.cxx:48
Int_t SysSync(Int_t fd)
Sync remaining data to disk.
Definition: TMemFile.cxx:658
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
const ExternalDataPtr_t fExternalData
shared file data / content
Definition: TMemFile.h:42
bool NeedsToWrite(EMode mode) const
Definition: TMemFile.h:72
virtual Long64_t GetSize() const
Return the current size of the memory file.
Definition: TMemFile.cxx:268
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:466
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).
std::shared_ptr< const std::vector< char > > ExternalDataPtr_t
Definition: TMemFile.h:21
TMemBlock * fBlockSeek
Pointer to the block we seeked to.
Definition: TMemFile.h:45
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2264
TMemBlock * fNext
Definition: TMemFile.h:37
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:648
TMemBlock fBlockList
Collection of memory blocks of size fgDefaultBlockSize.
Definition: TMemFile.h:41
virtual ~TMemFile()
Close and clean-up file.
Definition: TMemFile.cxx:214
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:597
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:365
Bool_t fWritable
True if directory is writable.
Option_t * GetOption() const
Definition: TFile.h:223
#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:68
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:475
TList * fFree
Free segments linked list table.
Definition: TFile.h:87
static Long64_t fgDefaultBlockSize
Definition: TMemFile.h:48
void CreateNext(Long64_t size)
Definition: TMemFile.cxx:88
#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:39
#define R__LOCKGUARD(mutex)
TString fOption
File options.
Definition: TFile.h:85
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition: TFile.h:100
EMode ParseOption(Option_t *option)
Parse option strings and set fOption.
Definition: TMemFile.cxx:96
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Long64_t GetEND() const
Definition: TFile.h:214
virtual const TUrl * GetEndpointUrl() const
Definition: TFile.h:218
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:408
bool NeedsExistingFile(EMode mode) const
Definition: TMemFile.h:73
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:142
virtual TList * GetListOfKeys() const
void MakeZombie()
Definition: TObject.h:49
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition: TFile.h:82
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:81
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:90
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:99
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:233
const Bool_t kTRUE
Definition: RtypesCore.h:87
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:70
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
Int_t GetCompressionSettings() const
Definition: TFile.h:390
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:94
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:917
Int_t SysWriteImpl(Int_t fd, const void *buf, Long64_t len)
Write a buffer into the file.
Definition: TMemFile.cxx:576
const char * Data() const
Definition: TString.h:364