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