272 fReadDirectionSet(kFALSE),
274 fPrefillType(GetConfiguredPrefillType()),
284 fEntryMax(tree->GetEntriesFast()),
302 fReadDirectionSet(
kFALSE),
304 fPrefillType(GetConfiguredPrefillType()),
365 for (
Int_t j = 0; j < nb; j++) {
367 if (!branch)
continue;
392 TLeaf *leaf, *leafcount;
403 if (!strcmp(bname,
"*")) all =
kTRUE;
404 for (i=0;i<nleaves;i++) {
411 if (strcmp(bname,branch->
GetName())
420 if (leafcount && !all) {
427 if (nb==0 && strchr(bname,
'*')==0) {
448 char *subbranch = (
char*)strstr(bname,fe->GetName());
449 if (subbranch!=bname) subbranch = 0;
451 subbranch += strlen(fe->GetName());
452 if ( *subbranch !=
'.' ) subbranch = 0;
464 if (!nb && !foundInFriend) {
465 if (
gDebug > 0) printf(
"AddBranch: unknown branch -> %s \n", bname);
466 Error(
"AddBranch",
"unknown branch -> %s", bname);
505 for (
Int_t j = 0; j < nb; j++) {
507 if (!branch)
continue;
532 TLeaf *leaf, *leafcount;
543 if (!strcmp(bname,
"*")) all =
kTRUE;
544 for (i=0;i<nleaves;i++) {
551 if (strcmp(bname,branch->
GetName())
560 if (leafcount && !all) {
567 if (nb==0 && strchr(bname,
'*')==0) {
588 char *subbranch = (
char*)strstr(bname,fe->GetName());
589 if (subbranch!=bname) subbranch = 0;
591 subbranch += strlen(fe->GetName());
592 if ( *subbranch !=
'.' ) subbranch = 0;
604 if (!nb && !foundInFriend) {
605 if (
gDebug > 0) printf(
"DropBranch: unknown branch -> %s \n", bname);
606 Error(
"DropBranch",
"unknown branch -> %s", bname);
664 if (entry < 0) entry = 0;
670 if (entry < 0)
return kFALSE;
676 if (entry < 0 && fEntryNext > 0) {
701 if (entry == -1) entry = 0;
734 Int_t fNtotCurrentBuf = 0;
738 fNtotCurrentBuf =
fNtot;
747 fNtotCurrentBuf =
fNtot;
751 Int_t clusterIterations = 0;
757 prevNtot = fNtotCurrentBuf;
758 Int_t nextMinBasket = INT_MAX;
772 if (!lbaskets || !entries)
continue;
780 if (j<blistsize && b->GetListOfBaskets()->UncheckedAt(j))
continue;
783 Int_t len = lbaskets[j];
784 if (pos <= 0 || len <= 0)
continue;
791 if (entries[j] < minEntry && (j<nb-1 && entries[j+1] <= minEntry))
continue;
794 if (j<nb-1) emax = entries[j+1]-1;
795 if (!elist->
ContainsRange(entries[j]+chainOffset,emax+chainOffset))
continue;
797 if (pass==2 && !firstBasketSeen) {
799 firstBasketSeen =
kTRUE;
806 if (clusterIterations > 0) {
811 Info(
"FillBuffer",
"Breaking early because %d is greater than %d at cluster iteration %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,minEntry);
824 Info(
"FillBuffer",
"Breaking early because %d is greater than 2*%d at cluster iteration %d pass %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,pass,
fEntryNext);
835 Info(
"FillBuffer",
"Breaking early because %d is greater than 2*%d at cluster iteration %d pass %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,pass,
fEntryNext);
845 fNtotCurrentBuf =
fNtot;
854 fNtotCurrentBuf =
fNtot;
856 if ( ( j < (nb-1) ) && entries[j+1] > maxReadEntry ) {
857 maxReadEntry = entries[j+1];
861 Warning(
"FillBuffer",
"There is more data in this cluster (starting at entry %lld to %lld, current=%lld) than usual ... with %d %.3f%% of the branches we already have %d bytes (instead of %d)",
871 if (j < nextMinBasket) nextMinBasket = j;
877 minEntry = clusterIter.
Next();
891 if (!((
fBufferSizeMin > ((
Long64_t)fNtotCurrentBuf*(clusterIterations+1))/clusterIterations) && (prevNtot < fNtotCurrentBuf) && (minEntry <
fEntryMax)))
898 if (minEntry >= fEntryCurrentMax && fEntryCurrentMax >0)
901 minBasket = nextMinBasket;
945 if (!(stcp =
gSystem->
Getenv(
"ROOT_TTREECACHE_PREFILL")) || !*stcp) {
1018 printf(
"Number of branches in the cache ...: %d\n",
fNbranches);
1019 printf(
"Cache Efficiency ..................: %f\n",
GetEfficiency());
1022 if ( opt.
Contains(
"cachedbranches") ) {
1024 printf(
"Cached branches....................:\n");
1027 for (
Int_t i = 0; i < nbranches; ++i) {
1029 printf(
"Branch name........................: %s\n",branch->
GetName());
1147 if (res == 0 && buffersize <= prevsize) {
1182 Info(
"SetEntryRange",
"fEntryMin=%lld, fEntryMax=%lld, fEntryNext=%lld",
1185 if (needLearningStart) {
virtual const char * GetName() const
Returns name of object.
Int_t fNtot
Total size of prefetched blocks.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Long64_t fEntryMax
! last entry in the cache
Long64_t * GetBasketEntry() const
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Int_t fNReadOk
Number of blocks read and found in the cache.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
TFile * fFile
Pointer to file.
const TObjArray * GetCachedBranches() const
TObjArray * GetListOfBaskets()
Collectable string class.
TObjArray * fBranches
! List of branches to be stored in the cache
A cache when reading files over the network.
Bool_t fOneTime
! used in the learning phase
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetLearnPrefill(EPrefillType type=kNoPrefill)
Set whether the learning period is started with a prefilling of the cache and which type of prefillin...
A specialized TFileCacheRead object for a TTree.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual Int_t GetEntries() const
virtual TList * GetListOfFriends() const
virtual Long64_t GetAutoFlush() const
Regular expression class.
TDirectory * GetDirectory() const
virtual TObject * Remove(TObject *obj)
Remove object from array.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Long64_t fEntryMin
! first entry in the cache
void ToLower()
Change string to lower-case.
virtual void Prefetch(Long64_t pos, Int_t len)
Add block of length len at position pos in the list of blocks to be prefetched.
virtual void StopLearningPhase()
This is the counterpart of StartLearningPhase() and can be used to stop the learning phase...
virtual void LearnPrefill()
Perform an initial prefetch, attempting to read as much of the learning phase baskets for all branche...
void StartLearningPhase()
The name should be enough to explain the method.
virtual Int_t AddBranch(TBranch *b, Bool_t subgbranches=kFALSE)
Add a branch to the list of branches to be stored in the cache this function is called by TBranch::Ge...
Long64_t * GetTreeOffset() const
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual Int_t ReadBufferNormal(char *buf, Long64_t pos, Int_t len)
Old method ReadBuffer before the addition of the prefetch mechanism.
Helper class to iterate over cluster of baskets.
Int_t * GetBasketBytes() const
virtual void SecondPrefetch(Long64_t, Int_t)
virtual void Print(Option_t *option="") const
Print cache statistics.
virtual Long64_t GetReadEntry() const
Bool_t fIsTransferred
True when fBuffer contains something valid.
virtual Bool_t ContainsRange(Long64_t entrymin, Long64_t entrymax)
Return TRUE if list contains entries from entrymin to entrymax included.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual TClusterIterator GetClusterIterator(Long64_t firstentry)
Return an iterator over the cluster of baskets starting at firstentry.
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos if the request is in the list of prefetched blocks read from fBuffer...
virtual void ResetCache()
This will simply clear the cache.
Bool_t fEnabled
! cache enabled for cached reading
TObjArray * GetListOfBranches()
virtual TFile * GetFile() const
Double_t GetEfficiencyRel() const
This will indicate a sort of relative efficiency...
virtual TTree * GetTree() const
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
TTree * fTree
! pointer to the current Tree
const char * GetName() const
Returns name of object.
EPrefillType GetConfiguredPrefillType() const
Return the desired prefill type from the environment or resource variable.
virtual void SetEntryRange(Long64_t emin, Long64_t emax)
Set the minimum and maximum entry number to be processed this information helps to optimize the numbe...
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
virtual Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE)
Remove a branch to the list of branches to be stored in the cache this function is called by TBranch:...
R__EXTERN TSystem * gSystem
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual Int_t ReadBufferPrefetch(char *buf, Long64_t pos, Int_t len)
Used to read a chunk from a block previously fetched.
virtual ~TTreeCache()
Destructor. (in general called by the TFile destructor)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Int_t GetEntriesFast() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TLeaf * GetLeafCount() const
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
Int_t GetMaxBaskets() const
A TEventList object is a list of selected events (entries) in a TTree.
Bool_t fReadDirectionSet
! read direction established
Int_t fNReadMiss
Number of blocks read and not found in the cache.
static void SetLearnEntries(Int_t n=10)
Static function to set the number of entries to be used in learning mode The default value for n is 1...
virtual Int_t SetBufferSize(Int_t buffersize)
Sets the buffer size.
virtual Bool_t FillBuffer()
Fill the cache buffer with the branches in the cache.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
Int_t fNReadPref
Number of blocks that were prefetched.
virtual Long64_t GetBasketSeek(Int_t basket) const
Return address of basket in the file.
Bool_t fReverseRead
! reading in reverse mode
Bool_t fFirstTime
! save the fact that we processes the first entry
Long64_t fEntryCurrent
! current lowest entry number in the cache
Int_t fBufferSizeMin
Original size of fBuffer.
Long64_t Next()
Move on to the next cluster and return the starting entry of this next cluster.
TObject * UncheckedAt(Int_t i) const
TTreeCache()
Default Constructor.
virtual void Print(Option_t *option="") const
Print cache statistics.
Bool_t fIsLearning
! true if cache is in learning mode
virtual Int_t GetTreeNumber() const
virtual Int_t GetBufferSize() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Overload to make sure that the object specific.
EPrefillType fPrefillType
Whether a pre-filling is enabled (and if applicable which type)
Int_t fFillTimes
! how many times we can fill the current buffer
virtual Int_t SetBufferSize(Int_t buffersize)
Change the underlying buffer size of the cache.
virtual Long64_t GetEntries() const
Int_t fNbranches
! Number of branches in the cache
Bool_t fEnablePrefetching
reading by prefetching asynchronously
virtual void Add(TObject *obj)
Long64_t fFirstEntry
! save the value of the first entry
A TFriendElement TF describes a TTree object TF in a file.
A chain is a collection of files containing TTree objects.
TList * fBrNames
! list of branch names in the cache
Long64_t GetReadEntry() const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Bool_t fFirstBuffer
! true if first buffer is used for prefetching
static Int_t fgLearnEntries
number of entries used for learning mode
Int_t GetEntries() const
Return the number of objects in array (i.e.
Int_t Atoi() const
Return integer value of string.
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
A TTree object has a header with a name and a title.
TEventList * GetEventList() const
TBranch * GetBranch() const
Bool_t fIsManual
! true if cache is StopLearningPhase was used
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetSize() const
A TTree is a list of TBranches.
Long64_t fEntryNext
! next entry number where cache must be filled
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
Double_t GetEfficiency() const
Give the total efficiency of the cache...
static Int_t GetLearnEntries()
Static function returning the number of entries used to train the cache see SetLearnEntries.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Int_t fNseek
Number of blocks to be prefetched.
virtual TObjArray * GetListOfLeaves()
ECacheAction
TTreeCache flushing semantics.