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;
733 Int_t fNtotCurrentBuf = 0;
737 fNtotCurrentBuf =
fNtot;
746 fNtotCurrentBuf =
fNtot;
750 Int_t clusterIterations = 0;
756 prevNtot = fNtotCurrentBuf;
757 Int_t nextMinBasket = INT_MAX;
771 if (!lbaskets || !entries)
continue;
779 if (j<blistsize && b->GetListOfBaskets()->UncheckedAt(j))
continue;
782 Int_t len = lbaskets[j];
783 if (pos <= 0 || len <= 0)
continue;
790 if (entries[j] < minEntry && (j<nb-1 && entries[j+1] <= minEntry))
continue;
793 if (j<nb-1) emax = entries[j+1]-1;
794 if (!elist->
ContainsRange(entries[j]+chainOffset,emax+chainOffset))
continue;
796 if (pass==2 && !firstBasketSeen) {
798 firstBasketSeen =
kTRUE;
805 if (clusterIterations > 0) {
810 Info(
"FillBuffer",
"Breaking early because %d is greater than %d at cluster iteration %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,minEntry);
823 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);
834 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);
844 fNtotCurrentBuf =
fNtot;
853 fNtotCurrentBuf =
fNtot;
855 if ( ( j < (nb-1) ) && entries[j+1] > maxReadEntry ) {
856 maxReadEntry = entries[j+1];
860 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)",
870 if (j < nextMinBasket) nextMinBasket = j;
876 minEntry = clusterIter.
Next();
890 if (!((
fBufferSizeMin > ((
Long64_t)fNtotCurrentBuf*(clusterIterations+1))/clusterIterations) && (prevNtot < fNtotCurrentBuf) && (minEntry <
fEntryMax)))
897 if (minEntry >= fEntryCurrentMax && fEntryCurrentMax >0)
900 minBasket = nextMinBasket;
929 if (!(stcp =
gSystem->
Getenv(
"ROOT_TTREECACHE_PREFILL")) || !*stcp) {
1002 printf(
"Number of branches in the cache ...: %d\n",
fNbranches);
1003 printf(
"Cache Efficiency ..................: %f\n",
GetEfficiency());
1006 if ( opt.
Contains(
"cachedbranches") ) {
1008 printf(
"Cached branches....................:\n");
1011 for (
Int_t i = 0; i < nbranches; ++i) {
1013 printf(
"Branch name........................: %s\n",branch->
GetName());
1131 if (res == 0 && buffersize <= prevsize) {
1166 Info(
"SetEntryRange",
"fEntryMin=%lld, fEntryMax=%lld, fEntryNext=%lld",
1169 if (needLearningStart) {
const char * GetName() const
Returns name of object.
Long64_t GetReadEntry() const
virtual Int_t GetEntries() const
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
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.
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.
TEventList * GetEventList() const
Bool_t fOneTime
! used in the learning phase
virtual Long64_t GetReadEntry() const
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.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Regular expression class.
virtual TObject * Remove(TObject *obj)
Remove object from array.
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 TObject * FindObject(const char *name) const
Find an object in this list using its name.
TBranch * GetBranch() const
virtual Long64_t GetBasketSeek(Int_t basket) const
Return address of basket in the file.
virtual void StopLearningPhase()
This is the counterpart of StartLearningPhase() and can be used to stop the learning phase...
Int_t GetEntriesFast() const
virtual void LearnPrefill()
Perform an initial prefetch, attempting to read as much of the learning phase baskets for all branche...
Long64_t * GetBasketEntry() const
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...
virtual void Print(Option_t *option="") const
Print cache statistics.
virtual Int_t ReadBufferNormal(char *buf, Long64_t pos, Int_t len)
Old method ReadBuffer before the addition of the prefetch mechanism.
virtual TList * GetListOfFriends() const
Long64_t * GetTreeOffset() const
Helper class to iterate over cluster of baskets.
virtual void SecondPrefetch(Long64_t, Int_t)
virtual Int_t GetTreeNumber() const
Bool_t fIsTransferred
True when fBuffer contains something valid.
Int_t * GetBasketBytes() const
virtual Bool_t ContainsRange(Long64_t entrymin, Long64_t entrymax)
Return TRUE if list contains entries from entrymin to entrymax included.
EPrefillType GetConfiguredPrefillType() const
Return the desired prefill type from the environment or resource variable.
virtual Int_t GetBufferSize() const
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
Int_t Atoi() const
Return integer value of string.
TObjArray * GetListOfBranches()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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
virtual TFile * GetFile() const
TObject * UncheckedAt(Int_t i) const
Double_t GetEfficiency() const
Give the total efficiency of the cache...
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.
virtual void Print(Option_t *option="") const
Print cache statistics.
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
A TEventList object is a list of selected events (entries) in a TTree.
Bool_t fReadDirectionSet
! read direction established
virtual const char * GetName() const
Returns name of object.
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.
virtual TLeaf * GetLeafCount() const
Int_t fNReadPref
Number of blocks that were prefetched.
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.
virtual Int_t GetSize() const
virtual Long64_t GetAutoFlush() const
TTreeCache()
Default Constructor.
virtual const char * GetName() const
Returns name of object.
Bool_t fIsLearning
! true if cache is in learning mode
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)
virtual TTree * GetTree() const
Int_t fFillTimes
! how many times we can fill the current buffer
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual Int_t SetBufferSize(Int_t buffersize)
Change the underlying buffer size of the cache.
TDirectory * GetDirectory() const
Int_t fNbranches
! Number of branches in the cache
Int_t GetMaxBaskets() const
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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A chain is a collection of files containg TTree objects.
TList * fBrNames
! list of branch names in the cache
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
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
Bool_t fIsManual
! true if cache is StopLearningPhase was used
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
A TTree is a list of TBranches.
Long64_t fEntryNext
! next entry number where cache must be filled
Double_t GetEfficiencyRel() const
This will indicate a sort of relative efficiency...
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
static Int_t GetLearnEntries()
Static function returning the number of entries used to train the cache see SetLearnEntries.
Int_t fNseek
Number of blocks to be prefetched.
virtual TObjArray * GetListOfLeaves()
ECacheAction
TTreeCache flushing semantics.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.