ROOT logo
// @(#)root/io:$Id: TFileCacheRead.h 26028 2008-10-30 20:09:44Z brun $
// Author: Rene Brun   19/05/2006

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TFileCacheRead
#define ROOT_TFileCacheRead


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TFileCacheRead                                                       //
//                                                                      //
// TFile cache when reading                                             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif

class TFile;

class TFileCacheRead : public TObject {

protected:
   Int_t         fBufferSizeMin;  //Original size of fBuffer
   Int_t         fBufferSize;     //Allocated size of fBuffer (at a given time)
   Int_t         fBufferLen;      //Current buffer length (<= fBufferSize)

   Int_t         fBytesToPrefetch;// Helpers to allow the incremental async prefetch
   Int_t         fFirstIndexToPrefetch;
   Bool_t        fAsyncReading;

   Int_t         fNseek;          //Number of blocks to be prefetched
   Int_t         fNtot;           //Total size of prefetched blocks
   Int_t         fNb;             //Number of long buffers
   Int_t         fSeekSize;       //Allocated size of fSeek
   Long64_t     *fSeek;           //[fNseek] Position on file of buffers to be prefetched
   Long64_t     *fSeekSort;       //[fNseek] Position on file of buffers to be prefetched (sorted)
   Int_t        *fSeekIndex;      //[fNseek] sorted index table of fSeek
   Long64_t     *fPos;            //[fNb] start of long buffers
   Int_t        *fSeekLen;        //[fNseek] Length of buffers to be prefetched
   Int_t        *fSeekSortLen;    //[fNseek] Length of buffers to be prefetched (sorted)
   Int_t        *fSeekPos;        //[fNseek] Position of sorted blocks in fBuffer
   Int_t        *fLen;            //[fNb] Length of long buffers
   TFile        *fFile;           //Pointer to file
   char         *fBuffer;         //[fBufferSize] buffer of contiguous prefetched blocks
   Bool_t        fIsSorted;       //True if fSeek array is sorted
   Bool_t        fIsTransferred;   //True when fBuffer contains something valid

private:
   TFileCacheRead(const TFileCacheRead &);            //cannot be copied
   TFileCacheRead& operator=(const TFileCacheRead &);

public:
   TFileCacheRead();
   TFileCacheRead(TFile *file, Int_t buffersize);
   virtual ~TFileCacheRead();
   virtual Int_t       GetBufferSize() const { return fBufferSize; };
   virtual Bool_t      IsAsyncReading() const { return fAsyncReading; };
   virtual void        Prefetch(Long64_t pos, Int_t len);
   virtual void        Print(Option_t *option="") const;
   virtual Int_t       ReadBuffer(char *buf, Long64_t pos, Int_t len);
   virtual void        SetFile(TFile *file);
   virtual void        Sort();

   ClassDef(TFileCacheRead,1)  //TFile cache when reading
};

#endif
 TFileCacheRead.h:1
 TFileCacheRead.h:2
 TFileCacheRead.h:3
 TFileCacheRead.h:4
 TFileCacheRead.h:5
 TFileCacheRead.h:6
 TFileCacheRead.h:7
 TFileCacheRead.h:8
 TFileCacheRead.h:9
 TFileCacheRead.h:10
 TFileCacheRead.h:11
 TFileCacheRead.h:12
 TFileCacheRead.h:13
 TFileCacheRead.h:14
 TFileCacheRead.h:15
 TFileCacheRead.h:16
 TFileCacheRead.h:17
 TFileCacheRead.h:18
 TFileCacheRead.h:19
 TFileCacheRead.h:20
 TFileCacheRead.h:21
 TFileCacheRead.h:22
 TFileCacheRead.h:23
 TFileCacheRead.h:24
 TFileCacheRead.h:25
 TFileCacheRead.h:26
 TFileCacheRead.h:27
 TFileCacheRead.h:28
 TFileCacheRead.h:29
 TFileCacheRead.h:30
 TFileCacheRead.h:31
 TFileCacheRead.h:32
 TFileCacheRead.h:33
 TFileCacheRead.h:34
 TFileCacheRead.h:35
 TFileCacheRead.h:36
 TFileCacheRead.h:37
 TFileCacheRead.h:38
 TFileCacheRead.h:39
 TFileCacheRead.h:40
 TFileCacheRead.h:41
 TFileCacheRead.h:42
 TFileCacheRead.h:43
 TFileCacheRead.h:44
 TFileCacheRead.h:45
 TFileCacheRead.h:46
 TFileCacheRead.h:47
 TFileCacheRead.h:48
 TFileCacheRead.h:49
 TFileCacheRead.h:50
 TFileCacheRead.h:51
 TFileCacheRead.h:52
 TFileCacheRead.h:53
 TFileCacheRead.h:54
 TFileCacheRead.h:55
 TFileCacheRead.h:56
 TFileCacheRead.h:57
 TFileCacheRead.h:58
 TFileCacheRead.h:59
 TFileCacheRead.h:60
 TFileCacheRead.h:61
 TFileCacheRead.h:62
 TFileCacheRead.h:63
 TFileCacheRead.h:64
 TFileCacheRead.h:65
 TFileCacheRead.h:66
 TFileCacheRead.h:67
 TFileCacheRead.h:68
 TFileCacheRead.h:69
 TFileCacheRead.h:70
 TFileCacheRead.h:71
 TFileCacheRead.h:72
 TFileCacheRead.h:73
 TFileCacheRead.h:74
 TFileCacheRead.h:75
 TFileCacheRead.h:76
 TFileCacheRead.h:77