33 #define TMemFile_TRACE
34 #ifndef TMemFile_TRACE
36 Debug("TMemFile", "%s", x);
48 TMemFile::TMemBlock::TMemBlock() : fPrevious(0), fNext(0), fBuffer(0), fSize(0)
56 fPrevious(previous), fNext(0), fBuffer(0), fSize(0)
83 const char *ftitle,
Int_t compress) :
84 TFile(path,
"WEB", ftitle, compress),
94 if (!create && !recreate && !update && !read) {
99 if (!(create || recreate)) {
100 Error(
"TMemFile",
"Reading a TMemFile requires a memory buffer\n");
103 if (create || update || recreate) {
104 Int_t mode = O_RDWR | O_CREAT;
105 if (recreate) mode |= O_TRUNC;
107 fD =
SysOpen(path, O_RDWR | O_CREAT, 0644);
109 SysError(
"TMemFile",
"file %s can not be opened", path);
116 SysError(
"TMemFile",
"file %s can not be opened for reading", path);
122 Init(create || recreate);
136 const char *ftitle,
Int_t compress):
137 TFile(path,
"WEB", ftitle, compress), fBlockList(size),
138 fSize(size), fSysOffset(0), fBlockSeek(&(fBlockList)), fBlockOffset(0)
146 if (!create && !recreate && !update && !read) {
151 if (create || update || recreate) {
152 Int_t mode = O_RDWR | O_CREAT;
153 if (recreate) mode |= O_TRUNC;
155 fD =
SysOpen(path, O_RDWR | O_CREAT, 0644);
157 SysError(
"TMemFile",
"file %s can not be opened", path);
165 SysError(
"TMemFile",
"file %s can not be opened for reading", path);
173 Init(create || recreate);
186 TFile(orig.GetEndpointUrl()->GetUrl(),
"WEB", orig.GetTitle(),
187 orig.GetCompressionSettings() ), fBlockList(orig.GetEND()),
188 fSize(orig.GetEND()), fSysOffset(0), fBlockSeek(&(fBlockList)), fBlockOffset(0)
196 if (!create && !recreate && !update && !read) {
207 Init(create || recreate);
255 current = current->
fNext;
273 if (strcmp(option,
"blocks")==0) {
277 Printf(
"TMemBlock: %d size=%lld addr=%p curr=%p prev=%p next=%p",
280 current = current->
fNext;
335 gROOT->GetListOfFiles()->Remove(
this);
346 while ((idcur =
next())) {
366 Warning(
"ResetObjects",
"Key/Object %s is not attached to the directory %s and can not be ResetAfterMerge correctly",
367 key->GetName(),directory->
GetName());
374 listHargs.
Form(
"(TFileMergeInfo*)0x%lx",(
ULong_t)info);
378 while ((idcur =
next())) {
379 TClass *objcl = idcur->IsA();
384 }
else if (idcur->IsA()->GetMethodWithPrototype(
"ResetAfterMerge",
"TFileMergeInfo*") ) {
386 idcur->Execute(
"ResetAfterMerge", listHargs.
Data(), &error);
388 Error(
"ResetObjects",
"calling ResetAfterMerge() on '%s' failed.",
430 buf = (
char*)buf + sublen;
431 Int_t len_left = len - sublen;
462 if (whence == SEEK_SET) {
472 }
else if (whence == SEEK_CUR) {
476 }
else if (offset > 0) {
496 SysError(
"TMemFile",
"Unable to seek past the beginning of file");
515 }
else if (whence == SEEK_END) {
517 SysError(
"TMemFile",
"Unable to seek past end of file");
521 SysError(
"TMemFile",
"Unable to seek to end of file");
526 SysError(
"TMemFile",
"Unknown whence!");
583 buf = (
char*)buf + sublen;
584 Int_t len_left = len - sublen;
void ResetAfterMerge(TFileMergeInfo *)
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
~TMemBlock()
Usual destructors. Delete the block memory.
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...
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a file in 'MemFile'.
virtual const char * GetTitle() const
Returns title of object.
double read(const std::string &file_name)
reading
Long64_t fSysOffset
Seek offset in file.
Long64_t fSize
Total file size (sum of the size of the chunks)
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Long64_t fBytesWrite
Number of bytes written to this file.
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
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
Int_t SysClose(Int_t fd)
Close the mem file.
Long64_t fBlockOffset
Seek offset within the block.
virtual TList * GetListOfKeys() const
virtual TList * GetList() const
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...
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
void ResetErrno() const
Simply calls TSystem::ResetErrno().
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
virtual Long64_t GetSize() const
Return the current size of the memory file.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Write a buffer into the file.
R__EXTERN TVirtualMutex * gROOTMutex
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
A TMemFile is like a normal TFile except that it reads and writes only from memory.
const char * Data() const
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Option_t * GetOption() const
virtual void Print(Option_t *option="") const
Print all objects in the file.
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
if(pyself &&pyself!=Py_None)
Int_t SysSync(Int_t fd)
Sync remaining data to disk.
void tobuf(char *&buf, Bool_t x)
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Read specified number of bytes from current offset into the buffer.
R__EXTERN TSystem * gSystem
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.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
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().
TMemBlock fBlockList
Colletion of memory blocks of size fBlockSize.
virtual ~TMemFile()
Close and clean-up file.
virtual const char * GetName() const
Returns name of object.
The ROOT global object gROOT contains a list of all defined classes.
virtual void Init(Bool_t create)
Initialize a TFile object.
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
Bool_t fWritable
True if directory is writable.
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Seek to a specified position in the file.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
TList * fFree
Free segments linked list table.
static Long64_t fgDefaultBlockSize
void CreateNext(Long64_t size)
void ResetObjects(TDirectoryFile *, TFileMergeInfo *) const
Wipe all the data from the permanent buffer but keep, the in-memory object alive. ...
TString fOption
File options.
Bool_t fMustFlush
!True if the file buffers must be flushed
Mother of all ROOT objects.
TMemFile(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1)
Usual Constructor. See the TFile constructor for details.
Int_t fNProcessIDs
Number of TProcessID written to this file.
static void ResetErrno()
Static function resetting system error number.
Int_t fWritten
Number of objects written so far.
Long64_t fOffset
!Seek offset cache
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
Return the wrapper around Merge.
void SetErrorStr(const char *errstr)
Set the system error string.
Bool_t fInitDone
!True if the file has been initialized
Long64_t fBytesRead
Number of bytes read from this file.
Int_t fNbytesKeys
Number of bytes for the keys.
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
virtual void Close(Option_t *option="")
Close a file.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.