12#ifndef ROOT_TTreeCache
13#define ROOT_TTreeCache
133 Int_t AddBranch(
const char *branch,
bool subbranches =
false)
override;
135 virtual Int_t DropBranch(
const char *branch,
bool subbranches =
false);
unsigned long long ULong64_t
#define ClassDefOverride(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
A TTree is a list of TBranches.
A cache when reading files over the network.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
ECacheAction
TTreeCache flushing semantics.
A cache to speed-up the reading of ROOT datasets.
virtual void SetLearnPrefill(EPrefillType type=kNoPrefill)
Set whether the learning period is started with a prefilling of the cache and which type of prefillin...
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
Double_t GetEfficiencyRel() const
This will indicate a sort of relative efficiency... a ratio of the reads found in the cache to the nu...
bool fEnabled
! cache enabled for cached reading
Long64_t fLastMiss
! set to the event # of the last miss.
Int_t fNMissReadPref
Number of blocks read into the secondary ("miss") cache.
~TTreeCache() override
Destructor. (in general called by the TFile destructor)
bool IsAutoCreated() const
Int_t fNMissReadOk
Number of blocks read, not found in the primary cache, and found in the secondary cache.
bool FillMissCache()
Fill the miss cache from the current set of active branches.
virtual EPrefillType GetLearnPrefill() const
Int_t SetBufferSize(Long64_t buffersize) override
Change the underlying buffer size of the cache.
Long64_t fEntryMin
! first entry in the cache
void SetOptimizeMisses(bool opt)
Start of methods for the miss cache.
Int_t LearnBranch(TBranch *b, bool subgbranches=false) override
Add a branch discovered by actual usage to the list of branches to be stored in the cache this functi...
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...
TTreeCache(const TTreeCache &)=delete
this class cannot be copied
bool CheckMissCache(char *buf, Long64_t pos, int len)
Check the miss cache for a particular buffer, fetching if deemed necessary.
Long64_t fEntryNext
! next entry number where cache must be filled
Int_t fNReadMiss
Number of blocks read and not found in the cache.
bool fReverseRead
! reading in reverse mode
Double_t GetEfficiency() const
Give the total efficiency of the primary cache... defined as the ratio of blocks found in the cache v...
virtual bool FillBuffer()
Fill the cache buffer with the branches in the cache.
Long64_t fNextClusterStart
! End+1 of the cluster(s) where the current content was picked out
bool IsLearning() const override
bool ProcessMiss(Long64_t pos, int len)
! Given a file read not in the miss cache, handle (possibly) loading the data.
const TObjArray * GetCachedBranches() const
bool fIsLearning
! true if cache is in learning mode
Int_t fNMissReadMiss
Number of blocks read and not found in either cache.
IOPos FindBranchBasketPos(TBranch &, Long64_t entry)
Given a branch and an entry, determine the file location (offset / size) of the corresponding basket.
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...
TTreeCache()
Default Constructor.
std::unique_ptr< MissCache > fMissCache
! Cache contents for misses
bool fFirstBuffer
! true if first buffer is used for prefetching
bool fOptimizeMisses
! true if we should optimize cache misses.
void StartLearningPhase()
The name should be enough to explain the method.
TBranch * CalculateMissEntries(Long64_t, int, bool)
Given an file read, try to determine the corresponding branch.
Long64_t fCurrentClusterStart
! Start of the cluster(s) where the current content was picked out
Double_t GetMissEfficiency() const
The total efficiency of the 'miss cache' - defined as the ratio of blocks found in the cache versus t...
virtual Int_t ReadBufferNormal(char *buf, Long64_t pos, Int_t len)
Old method ReadBuffer before the addition of the prefetch mechanism.
virtual void ResetCache()
This will simply clear the cache.
bool fOneTime
! used in the learning phase
EPrefillType fPrefillType
Whether a pre-filling is enabled (and if applicable which type)
bool fLearnPrefilling
! true if we are in the process of executing LearnPrefill
bool fAutoCreated
! true if cache was automatically created
virtual void LearnPrefill()
Perform an initial prefetch, attempting to read as much of the learning phase baskets for all branche...
virtual Int_t DropBranch(TBranch *b, bool subbranches=false)
Remove a branch to the list of branches to be stored in the cache this function is called by TBranch:...
Long64_t fEntryMax
! last entry in the cache
static Int_t fgLearnEntries
number of entries used for learning mode
virtual Int_t GetEntryMax() const
void SetAutoCreated(bool val)
virtual Int_t ReadBufferPrefetch(char *buf, Long64_t pos, Int_t len)
Used to read a chunk from a block previously fetched.
Long64_t fEntryCurrent
! current lowest entry number in the cache
void ResetMissCache()
Reset all the miss cache training.
Long64_t fFirstMiss
! set to the event # of the first miss.
Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override
Read buffer at position pos if the request is in the list of prefetched blocks read from fBuffer.
bool fReadDirectionSet
! read direction established
virtual bool IsEnabled() const
virtual Int_t GetEntryMin() const
bool fIsManual
! true if cache is StopLearningPhase was used
bool GetOptimizeMisses() const
Double_t GetMissEfficiencyRel() const
Relative efficiency of the 'miss cache' - ratio of the reads found in cache to the number of reads so...
Long64_t fFirstEntry
! save the value of the first entry
Int_t fFillTimes
! how many times we can fill the current buffer
Int_t fNReadPref
Number of blocks that were prefetched.
TTree * fTree
! pointer to the current Tree
EPrefillType GetConfiguredPrefillType() const
Return the desired prefill type from the environment or resource variable.
TTreeCache & operator=(const TTreeCache &)=delete
bool CalculateMissCache()
Calculate the appropriate miss cache to fetch; helper function for FillMissCache.
static Int_t GetLearnEntries()
Static function returning the number of entries used to train the cache see SetLearnEntries.
virtual void StopLearningPhase()
This is the counterpart of StartLearningPhase() and can be used to stop the learning phase.
void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect) override
Change the file that is being cached.
Int_t fNbranches
! Number of branches in the cache
Int_t fNReadOk
Number of blocks read and found in the cache.
void Print(Option_t *option="") const override
Print cache statistics.
Int_t AddBranch(TBranch *b, bool subgbranches=false) override
Add a branch to the list of branches to be stored in the cache this function is called by the user vi...
TObjArray * fBranches
! List of branches to be stored in the cache
TList * fBrNames
! list of branch names in the cache
bool fFirstTime
! save the fact that we processes the first entry
A TTree represents a columnar dataset.
Int_t fLen
Position in file of cache entry.
IOPos(Long64_t pos, Int_t len)
ULong64_t fIndex
! Location in fData corresponding to this entry.
friend bool operator<(const Entry &a, const Entry &b)
std::vector< Entry > fEntries
! Description of buffers in the miss cache.
std::vector< char > fData
! Actual data in the cache.
std::vector< TBranch * > fBranches
! list of branches that we read on misses.