Logo ROOT   6.08/07
Reference Guide
TMemFile.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Philippe Canal, May 2011
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TMemFile
13 #define ROOT_TMemFile
14 
15 #ifndef ROOT_TFile
16 #include "TFile.h"
17 #endif
18 
19 class TMemFile : public TFile {
20 
21 private:
22  struct TMemBlock {
23  private:
24  TMemBlock(const TMemBlock&); // Not implemented
25  TMemBlock &operator=(const TMemBlock&); // Not implemented.
26  public:
27  TMemBlock();
28  TMemBlock(Long64_t size, TMemBlock *previous = 0);
29  ~TMemBlock();
30 
31  void CreateNext(Long64_t size);
32 
37  };
38  TMemBlock fBlockList; ///< Colletion of memory blocks of size fBlockSize
39  Long64_t fSize; ///< Total file size (sum of the size of the chunks)
40  Long64_t fSysOffset; ///< Seek offset in file
41  TMemBlock *fBlockSeek; ///< Pointer to the block we seeked to.
42  Long64_t fBlockOffset; ///< Seek offset within the block
43 
45 
46  Long64_t MemRead(Int_t fd, void *buf, Long64_t len) const;
47 
48  // Overload TFile interfaces.
49  Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
50  Int_t SysClose(Int_t fd);
51  Int_t SysReadImpl(Int_t fd, void *buf, Long64_t len);
52  Int_t SysWriteImpl(Int_t fd, const void *buf, Long64_t len);
53  Int_t SysRead(Int_t fd, void *buf, Int_t len);
54  Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
55  Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
56  Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
57  Int_t SysSync(Int_t fd);
58 
60 
61  TMemFile &operator=(const TMemFile&); // Not implemented.
62 
63 public:
64  TMemFile(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1);
65  TMemFile(const char *name, char *buffer, Long64_t size, Option_t *option="", const char *ftitle="", Int_t compress=1);
66  TMemFile(const TMemFile &orig);
67  virtual ~TMemFile();
68 
69  virtual Long64_t CopyTo(void *to, Long64_t maxsize) const;
70  virtual void CopyTo(TBuffer &tobuf) const;
71  virtual Long64_t GetSize() const;
72 
74  void ResetErrno() const;
75 
76  virtual void Print(Option_t *option="") const;
77 
78  ClassDef(TMemFile, 0) // A ROOT file that reads/writes via HDFS
79 };
80 
81 #endif
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
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:40
Long64_t fSize
Total file size (sum of the size of the chunks)
Definition: TMemFile.h:39
long long Long64_t
Definition: RtypesCore.h:69
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:42
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:50
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
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
virtual void Print(Option_t *option="") const
Print all objects in the file.
Definition: TMemFile.cxx:271
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Definition: TMemFile.h:19
#define ClassDef(name, id)
Definition: Rtypes.h:254
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
Long64_t MemRead(Int_t fd, void *buf, Long64_t len) const
const int maxsize
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:59
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
A ROOT file is structured in Directories (like a file system).
TMemBlock * fBlockSeek
Pointer to the block we seeked to.
Definition: TMemFile.h:41
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:638
TMemBlock fBlockList
Colletion of memory blocks of size fBlockSize.
Definition: TMemFile.h:38
virtual ~TMemFile()
Close and clean-up file.
Definition: TMemFile.cxx:215
void ResetObjects(TDirectoryFile *, TFileMergeInfo *) const
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
Definition: TMemFile.cxx:360
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
static Long64_t fgDefaultBlockSize
Definition: TMemFile.h:44
void CreateNext(Long64_t size)
Definition: TMemFile.cxx:73
Long64_t fSize
Definition: TMemFile.h:36
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
unsigned char UChar_t
Definition: RtypesCore.h:34
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
char name[80]
Definition: TGX11.cxx:109
TMemBlock & operator=(const TMemBlock &)
Int_t SysWriteImpl(Int_t fd, const void *buf, Long64_t len)
Write a buffer into the file.
Definition: TMemFile.cxx:571