142 SetEnablePrefetchingImpl(true);
145 SetEnablePrefetchingImpl(false);
329 printf(
"Cached Reading.....................: %lld bytes in %d transactions\n",this->
GetBytesRead(), this->
GetReadCalls());
335 printf(
"Average transaction................: No read calls yet\n");
336 printf(
"Number of blocks in current cache..: %d, total size: %d\n",
fNseek,
fNtot);
339 printf(
"Prefetching Wait Time..............: %f seconds\n",
fPrefetch->GetWaitTime() / 1
e+6);
350 printf (
"Number of long buffers = %d\n",
fNb);
352 printf(
"fPos[%d] = %lld, fLen = %d\n",j,
fPos[j],
fLen[j]);
414 if (cachew->ReadBuffer(buf,pos,len) == 0) {
415 fFile->SetOffset(pos+len);
437 if (
fPrefetch->ReadBuffer(buf, pos, len)) {
472 fFile->ReadBuffers(0, 0, 0, 0);
483 if (cachew->ReadBuffer(buf,pos,len) == 0) {
484 fFile->SetOffset(pos+len);
506 if (
fFile->ReadBuffer(buf, pos, len)) {
509 fFile->SetOffset(pos+len);
519 Info(
"ReadBuffer",
"pos=%lld, len=%d, retval=%d, loc=%d, "
520 "fseekSort[loc]=%lld, fSeekLen[loc]=%d",
532 fFile->SetOffset(pos+len);
577 Int_t effectiveNseek = 0;
611 (
fLen[nb] > 16000000)) {
635 Int_t effectiveNseek = 0;
669 (
fBLen[nb] > 16000000)) {
712 if (bufsize <= 0)
return -1;
713 if (bufsize <=10000) bufsize = 100000;
714 if (bufsize > std::numeric_limits<Int_t>::max()) bufsize = std::numeric_limits<Int_t>::max();
724 if (
fNtot > bufsize) {
743 np =
new char[bufsize];
745 memcpy(np, pres,
fNtot);
789 const char* cacheDir =
gEnv->GetValue(
"Cache.Directory",
"");
790 if (strcmp(cacheDir,
""))
791 if (!
fPrefetch->SetCache((
char*) cacheDir))
792 fprintf(stderr,
"Error while trying to set the cache directory: %s.\n", cacheDir);
794 fprintf(stderr,
"Error stating prefetching thread. Disabling prefetching.\n");
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
virtual Long64_t GetBytesRead() const
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
virtual Long64_t GetBytesReadExtra() const
virtual Long64_t GetNoCacheBytesRead() const
Int_t fBufferSize
Allocated size of fBuffer (at a given time).
char * fBuffer
[fBufferSize] buffer of contiguous prefetched blocks
Long64_t * fBSeekSort
[fBNseek]
Long64_t * fPos
[fNb] start of long buffers
Bool_t fIsSorted
True if fSeek array is sorted.
virtual Int_t GetReadCalls() const
Int_t * fSeekIndex
[fNseek] sorted index table of fSeek
virtual Int_t ReadBufferExt(char *buf, Long64_t pos, Int_t len, Int_t &loc)
~TFileCacheRead() override
Destructor.
Long64_t * fSeekSort
[fNseek] Position on file of buffers to be prefetched (sorted)
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
TFilePrefetch * fPrefetch
! Object that does the asynchronous reading in another thread
Int_t * fBSeekPos
[fBNseek]
virtual void SecondPrefetch(Long64_t, Int_t)
Long64_t fBytesRead
Number of bytes read for this cache.
virtual void SecondSort()
Sort buffers to be prefetched in increasing order of positions.
virtual TFilePrefetch * GetPrefetchObj()
virtual Int_t ReadBufferExtPrefetch(char *buf, Long64_t pos, Int_t len, Int_t &loc)
prefetch the first block
virtual void Sort()
Sort buffers to be prefetched in increasing order of positions.
virtual Int_t ReadBufferExtNormal(char *buf, Long64_t pos, Int_t len, Int_t &loc)
Base function for ReadBuffer.
TFileCacheRead()
Default Constructor.
void SetEnablePrefetchingImpl(Bool_t setPrefetching=kFALSE)
TFileCacheRead implementation of SetEnablePrefetching.
Bool_t fEnablePrefetching
reading by prefetching asynchronously
Int_t * fSeekLen
[fNseek] Length of buffers to be prefetched
Int_t fNtot
Total size of prefetched blocks.
virtual Int_t SetBufferSize(Long64_t buffersize)
Sets the buffer size.
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.
Int_t * fSeekSortLen
[fNseek] Length of buffers to be prefetched (sorted)
virtual void SetEnablePrefetching(Bool_t setPrefetching=kFALSE)
Set the prefetching mode of this file.
Int_t fBufferSizeMin
Original size of fBuffer.
Int_t * fBSeekIndex
[fBNseek]
virtual void Close(Option_t *option="")
Close out any threads or asynchronous fetches used by the underlying implementation.
Int_t fNb
Number of long buffers.
Int_t fReadCalls
Number of read calls for this cache.
Int_t fBufferLen
Current buffer length (<= fBufferSize).
Long64_t fPrefetchedBlocks
Number of blocks prefetched.
Long64_t fNoCacheBytesRead
Number of bytes read by basket to fill cached tree.
Long64_t * fSeek
[fNseek] Position on file of buffers to be prefetched
virtual Int_t GetNoCacheReadCalls() const
Bool_t fIsTransferred
True when fBuffer contains something valid.
TFile * fFile
Pointer to file.
virtual void WaitFinishPrefetch()
Int_t * fBSeekLen
[fBNseek]
Int_t fNseek
Number of blocks to be prefetched.
Int_t * fLen
[fNb] Length of long buffers
Int_t * fBSeekSortLen
[fBNseek]
void Print(Option_t *option="") const override
Print cache statistics.
Int_t fNoCacheReadCalls
Number of read calls by basket to fill cached tree.
Int_t * fSeekPos
[fNseek] Position of sorted blocks in fBuffer
Int_t fSeekSize
Allocated size of fSeek.
Long64_t * fBSeek
[fBNseek]
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
A cache when writing files over the network.
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=nullptr, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
virtual const TUrl * GetEndpointUrl() const
ECacheAction
TTreeCache flushing semantics.
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
TObject()
TObject constructor.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void ToLower()
Change string to lower-case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
const char * GetProtocol() const
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.