27inline int xtod(
char c) {
return (
c>=
'0' &&
c<=
'9') ?
c-
'0' : ((
c>=
'A' &&
c<=
'F') ?
c-
'A'+10 : ((
c>=
'a' &&
c<=
'f') ?
c-
'a'+10 : 0)); }
115 for (
Int_t i = 0; i <
block->GetNoElem(); i++)
147 while (
first <= last){
149 if ((offset >= blockObj->
GetPos(mid) && offset <= (blockObj->
GetPos(mid) + blockObj->
GetLen(mid))
150 && ( (offset + len) <= blockObj->
GetPos(mid) + blockObj->
GetLen(mid)))){
155 else if (blockObj->
GetPos(mid) < offset){
203 pBuff += (offset - blockObj->
GetPos(index));
204 memcpy(buf, pBuff, len);
293 blockObj =
new TFPBlock(offset, len, noblock);
339 assert((
fFile ==
file) &&
"kDoNotDisconnect must reattach to the same file");
382 const char* ptr = hex;
385 result +=
xtod(ptr[i]);
411 concatStr.
Form(
"%lld",
block->GetPos(i));
420 dirName.
Form(
"%i", value);
422 fullPath +=
"/" + dirName +
"/" + fileName;
426 path =
new char[fullPath.
Length() + 1];
427 strlcpy(path, fullPath,fullPath.
Length() + 1);
444 strPath +=
"?filetype=raw";
450 buffer = (
char*)
calloc(length,
sizeof(
char));
451 file->ReadBuffer(buffer, 0, length);
482 concatStr.
Form(
"%lld",
block->GetPos(i));
493 dirName.
Form(
"%i", value);
494 fullPath += (
"/" + dirName);
500 fullPath += (
"/" + fileName);
503 fullPath +=
"?filetype=raw";
506 fullPath +=
"?filetype=raw";
static const int kMAX_READ_SIZE
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class represents the encapsulation of a block request.
char * GetPtrToPiece(Int_t index) const
Get block buffer.
void ReallocBlock(Long64_t *, Int_t *, Int_t)
Reallocate the block's buffer based on the length of the elements it will contain.
Int_t GetLen(Int_t) const
Get length of the element at index i.
Int_t GetNoElem() const
Return number of elements in the block.
Long64_t GetPos(Int_t) const
Get position of the element at index i.
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
Bool_t BinarySearchReadList(TFPBlock *, Long64_t, Int_t, Int_t *)
Search for a requested element in a block and return the index.
void ReadBlock(Long64_t *, Int_t *, Int_t)
Create a TFPBlock object or recycle one and add it to the prefetchBlocks list.
static TThread::VoidRtnFunc_t ThreadProc(void *)
Execution loop of the consumer thread.
Int_t SumHex(const char *)
Sum up individual hex values to obtain a decimal value.
TFilePrefetch(TFile *)
Constructor.
TSemaphore * fSemChangeFile
void ReadListOfBlocks()
Get blocks specified in prefetchBlocks.
TFPBlock * CreateBlockObj(Long64_t *, Int_t *, Int_t)
Create a new block or recycle an old one.
std::condition_variable fNewBlockAdded
void AddReadBlock(TFPBlock *)
Safe method to add a block to the readList.
Bool_t CheckBlockInCache(char *&, TFPBlock *)
Test if the block is in cache.
Long64_t GetWaitTime()
Return the time spent wating for buffer to be read in microseconds.
Bool_t SetCache(const char *)
Set the path of the cache directory.
Int_t ThreadStart()
Used to start the consumer thread.
std::atomic< Bool_t > fPrefetchFinished
void ReadAsync(TFPBlock *, Bool_t &)
Read one block and insert it in prefetchBuffers list.
TFPBlock * GetPendingBlock()
Safe method to remove a block from the pendingList.
void AddPendingBlock(TFPBlock *)
Safe method to add a block to the pendingList.
Bool_t ReadBuffer(char *, Long64_t, Int_t)
Return a prefetched element.
virtual ~TFilePrefetch()
Destructor.
std::mutex fMutexReadList
std::mutex fMutexPendingList
std::condition_variable fReadBlockAdded
void WaitFinishPrefetch()
Killing the async prefetching thread.
TThread * GetThread() const
Return reference to the consumer thread.
void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Change the file.
char * GetBlockFromCache(const char *, Int_t)
Return a buffer from cache.
void SaveBlockInCache(TFPBlock *)
Save the block content in cache.
Bool_t IsPrefetchFinished() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Long64_t fBytesRead
Number of bytes read from this file.
Long64_t GetArchiveOffset() const
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
virtual Int_t GetReadCalls() const
virtual void SetReadCalls(Int_t readcalls=0)
ECacheAction
TTreeCache flushing semantics.
TArchiveFile * GetArchive() const
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
This code implements the MD5 message-digest algorithm.
const char * AsString() const
Return message digest as string.
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
Int_t Post()
Increment the value of the semaphore.
Int_t Wait()
If the semaphore value is > 0 then decrement it and carry on, else block, waiting on the condition un...
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Long_t Join(void **ret=0)
Join this thread.
Int_t Run(void *arg=0)
Start the thread.
void *(* VoidRtnFunc_t)(void *)
The TTimeStamp encapsulates seconds and ns since EPOCH.
virtual Bool_t SendFileReadProgress(TFile *)