#ifndef ROOT_TTreeCacheUnzip
#define ROOT_TTreeCacheUnzip
#ifndef ROOT_TTreeCache
#include "TTreeCache.h"
#endif
#include <queue>
class TTree;
class TBranch;
class TThread;
class TCondition;
class TBasket;
class TMutex;
class TTreeCacheUnzip : public TTreeCache {
public:
enum EParUnzipMode { kEnable, kDisable, kForce };
protected:
TThread *fUnzipThread[10];
Bool_t fActiveThread;
TCondition *fUnzipStartCondition;
TCondition *fUnzipDoneCondition;
Bool_t fParallel;
Bool_t fAsyncReading;
TMutex *fMutexList;
TMutex *fIOMutex;
Int_t fCycle;
static TTreeCacheUnzip::EParUnzipMode fgParallel;
Int_t fLastReadPos;
Int_t fBlocksToGo;
Int_t *fUnzipLen;
char **fUnzipChunks;
Byte_t *fUnzipStatus;
Long64_t fTotalUnzipBytes;
Int_t fNseekMax;
Long64_t fUnzipBufferSize;
static Double_t fgRelBuffSize;
Int_t fNUnzip;
Int_t fNFound;
Int_t fNStalls;
Int_t fNMissed;
std::queue<Int_t> fActiveBlks;
private:
TTreeCacheUnzip(const TTreeCacheUnzip &);
TTreeCacheUnzip& operator=(const TTreeCacheUnzip &);
char *fCompBuffer;
Int_t fCompBufferSize;
void Init();
Int_t StartThreadUnzip(Int_t nthreads);
Int_t StopThreadUnzip();
public:
TTreeCacheUnzip();
TTreeCacheUnzip(TTree *tree, Int_t buffersize=0);
virtual ~TTreeCacheUnzip();
virtual void AddBranch(TBranch *b, Bool_t subbranches = kFALSE);
virtual void AddBranch(const char *branch, Bool_t subbranches = kFALSE);
Bool_t FillBuffer();
virtual Int_t ReadBufferExt(char *buf, Long64_t pos, Int_t len, Int_t &loc);
void SetEntryRange(Long64_t emin, Long64_t emax);
virtual void StopLearningPhase();
void UpdateBranches(TTree *tree);
static EParUnzipMode GetParallelUnzip();
static Bool_t IsParallelUnzip();
static Int_t SetParallelUnzip(TTreeCacheUnzip::EParUnzipMode option = TTreeCacheUnzip::kEnable);
Bool_t IsActiveThread();
Bool_t IsQueueEmpty();
void WaitUnzipStartSignal();
void SendUnzipStartSignal(Bool_t broadcast);
Int_t GetRecordHeader(char *buf, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen);
virtual void ResetCache();
virtual Int_t GetUnzipBuffer(char **buf, Long64_t pos, Int_t len, Bool_t *free);
void SetUnzipBufferSize(Long64_t bufferSize);
static void SetUnzipRelBufferSize(Float_t relbufferSize);
Int_t UnzipBuffer(char **dest, char *src);
Int_t UnzipCache(Int_t &startindex, Int_t &locbuffsz, char *&locbuff);
Int_t GetNUnzip() { return fNUnzip; }
Int_t GetNFound() { return fNFound; }
Int_t GetNMissed(){ return fNMissed; }
void Print(Option_t* option = "") const;
static void* UnzipLoop(void *arg);
ClassDef(TTreeCacheUnzip,0)
};
#endif