270 fReadDirectionSet(kFALSE),
272 fPrefillType(GetConfiguredPrefillType()),
282 fEntryMax(tree->GetEntriesFast()),
300 fReadDirectionSet(
kFALSE),
302 fPrefillType(GetConfiguredPrefillType()),
363 for (
Int_t j = 0; j < nb; j++) {
365 if (!branch)
continue;
390 TLeaf *leaf, *leafcount;
401 if (!strcmp(bname,
"*")) all =
kTRUE;
402 for (i=0;i<nleaves;i++) {
409 if (strcmp(bname,branch->
GetName())
418 if (leafcount && !all) {
425 if (nb==0 && strchr(bname,
'*')==0) {
446 char *subbranch = (
char*)strstr(bname,fe->GetName());
447 if (subbranch!=bname) subbranch = 0;
449 subbranch += strlen(fe->GetName());
450 if ( *subbranch !=
'.' ) subbranch = 0;
462 if (!nb && !foundInFriend) {
463 if (
gDebug > 0) printf(
"AddBranch: unknown branch -> %s \n", bname);
464 Error(
"AddBranch",
"unknown branch -> %s", bname);
503 for (
Int_t j = 0; j < nb; j++) {
505 if (!branch)
continue;
530 TLeaf *leaf, *leafcount;
541 if (!strcmp(bname,
"*")) all =
kTRUE;
542 for (i=0;i<nleaves;i++) {
549 if (strcmp(bname,branch->
GetName())
558 if (leafcount && !all) {
565 if (nb==0 && strchr(bname,
'*')==0) {
586 char *subbranch = (
char*)strstr(bname,fe->GetName());
587 if (subbranch!=bname) subbranch = 0;
589 subbranch += strlen(fe->GetName());
590 if ( *subbranch !=
'.' ) subbranch = 0;
602 if (!nb && !foundInFriend) {
603 if (
gDebug > 0) printf(
"DropBranch: unknown branch -> %s \n", bname);
604 Error(
"DropBranch",
"unknown branch -> %s", bname);
662 if (entry < 0) entry = 0;
668 if (entry < 0)
return kFALSE;
674 if (entry < 0 && fEntryNext > 0) {
699 if (entry == -1) entry = 0;
731 Int_t fNtotCurrentBuf = 0;
735 fNtotCurrentBuf =
fNtot;
744 fNtotCurrentBuf =
fNtot;
748 Int_t clusterIterations = 0;
754 prevNtot = fNtotCurrentBuf;
755 Int_t nextMinBasket = INT_MAX;
769 if (!lbaskets || !entries)
continue;
777 if (j<blistsize && b->GetListOfBaskets()->UncheckedAt(j))
continue;
780 Int_t len = lbaskets[j];
781 if (pos <= 0 || len <= 0)
continue;
788 if (entries[j] < minEntry && (j<nb-1 && entries[j+1] <= minEntry))
continue;
791 if (j<nb-1) emax = entries[j+1]-1;
792 if (!elist->
ContainsRange(entries[j]+chainOffset,emax+chainOffset))
continue;
794 if (pass==2 && !firstBasketSeen) {
796 firstBasketSeen =
kTRUE;
803 if (clusterIterations > 0) {
808 Info(
"FillBuffer",
"Breaking early because %d is greater than %d at cluster iteration %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,minEntry);
821 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);
832 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);
842 fNtotCurrentBuf =
fNtot;
851 fNtotCurrentBuf =
fNtot;
853 if ( ( j < (nb-1) ) && entries[j+1] > maxReadEntry ) {
854 maxReadEntry = entries[j+1];
858 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)",
868 if (j < nextMinBasket) nextMinBasket = j;
874 minEntry = clusterIter.
Next();
888 if (!((
fBufferSizeMin > ((
Long64_t)fNtotCurrentBuf*(clusterIterations+1))/clusterIterations) && (prevNtot < fNtotCurrentBuf) && (minEntry <
fEntryMax)))
895 if (minEntry >= fEntryCurrentMax && fEntryCurrentMax >0)
898 minBasket = nextMinBasket;
927 if (!(stcp =
gSystem->
Getenv(
"ROOT_TTREECACHE_PREFILL")) || !*stcp) {
1000 printf(
"Number of branches in the cache ...: %d\n",
fNbranches);
1001 printf(
"Cache Efficiency ..................: %f\n",
GetEfficiency());
1004 if ( opt.
Contains(
"cachedbranches") ) {
1006 printf(
"Cached branches....................:\n");
1009 for (
Int_t i = 0; i < nbranches; ++i) {
1011 printf(
"Branch name........................: %s\n",branch->
GetName());
1129 if (res == 0 && buffersize <= prevsize) {
1164 Info(
"SetEntryRange",
"fEntryMin=%lld, fEntryMax=%lld, fEntryNext=%lld",
1167 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
first 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 branches 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.
A cache when reading files over the network.
Bool_t fOneTime
true if first buffer is used for prefetching
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
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
read direction established
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
list of branch names in the cache
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
save the value of the first entry
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 Long64_t GetBasketSeek(Int_t basket) const
Return address of basket in the file.
Bool_t fReverseRead
used in the learning phase
Bool_t fFirstTime
how many times we can fill the current buffer
Long64_t fEntryCurrent
last entry 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
pointer to the current Tree
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
cache enabled for cached reading
Int_t fFillTimes
reading in reverse mode
virtual Int_t SetBufferSize(Int_t buffersize)
Change the underlying buffer size of the cache.
virtual Long64_t GetEntries() const
Int_t fNbranches
next entry number where cache must be filled
Bool_t fEnablePrefetching
reading by prefetching asynchronously
virtual void Add(TObject *obj)
Long64_t fFirstEntry
save the fact that we processes the first entry
A TFriendElement TF describes a TTree object TF in a file.
A chain is a collection of files containg TTree objects.
TList * fBrNames
List of branches to be stored in the cache.
Long64_t GetReadEntry() const
Bool_t fFirstBuffer
true if cache is StopLearningPhase was used
static Int_t fgLearnEntries
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 in learning mode
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetSize() const
A TTree is a list of TBranches.
Long64_t fEntryNext
current lowest entry number in the cache
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.