31inline 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 if (
fFile->GetArchive()) {
145 Int_t first = 0, last = -1, mid = -1;
148 while (first <= last){
149 mid = first + (last - first) / 2;
150 if ((offset >= blockObj->
GetPos(mid) && offset <= (blockObj->
GetPos(mid) + blockObj->
GetLen(mid))
151 && ( (offset + len) <= blockObj->
GetPos(mid) + blockObj->
GetLen(mid)))){
156 else if (blockObj->
GetPos(mid) < offset){
204 pBuff += (offset - blockObj->
GetPos(index));
205 memcpy(buf, pBuff, len);
294 blockObj =
new TFPBlock(offset, len, noblock);
340 assert((
fFile == file) &&
"kDoNotDisconnect must reattach to the same file");
383 const char* ptr = hex;
386 result +=
xtod(ptr[i]);
404 void *fdir =
gSystem->OpenDirectory(fullPath);
424 dirName.
Form(
"%i", value);
426 fullPath +=
"/" + dirName +
"/" + fileName;
429 if (
gSystem->GetPathInfo(fullPath, stat) == 0) {
430 path =
new char[fullPath.
Length() + 1];
431 strlcpy(path, fullPath,fullPath.
Length() + 1);
448 strPath +=
"?filetype=raw";
454 buffer = (
char*)
calloc(length,
sizeof(
char));
457 fFile->fBytesRead += length;
458 fFile->fgBytesRead += length;
459 fFile->SetReadCalls(
fFile->GetReadCalls() + 1);
460 fFile->fgReadCalls++;
497 dirName.
Form(
"%i", value);
498 fullPath += (
"/" + dirName);
500 void *fdir =
gSystem->OpenDirectory(fullPath);
508 fullPath += (
"/" + fileName);
510 if (
gSystem->GetPathInfo(fullPath, stat) == 0) {
511 fullPath +=
"?filetype=raw";
514 fullPath +=
"?filetype=raw";
536 void *fdir =
gSystem->OpenDirectory(path);
538 return (!
gSystem->mkdir(path) ?
true :
false);
int Int_t
Signed integer 4 bytes (int).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
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.
static const int kMAX_READ_SIZE
externTVirtualMonitoringWriter * gMonitoringWriter
This class represents the encapsulation of a block request.
char * GetPtrToPiece(Int_t index) const
Get block buffer.
void SetPos(Int_t, Long64_t)
Set pos value for index idx.
void SetBuffer(char *)
Set block buffer.
Long64_t GetDataSize() const
Return size of the data in the block.
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.
char * GetBuffer() const
Get block buffer.
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
semaphore used when changing a file in TChain
void ReadListOfBlocks()
Get blocks specified in prefetchBlocks.
TFPBlock * CreateBlockObj(Long64_t *, Int_t *, Int_t)
Create a new block or recycle an old one.
TThread * fConsumer
consumer thread
std::condition_variable fNewBlockAdded
signal the addition of a new pending block
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 fThreadJoined
mark if async thread was joined
Bool_t SetCache(const char *)
Set the path of the cache directory.
TList * fReadBlocks
list of blocks read
Int_t ThreadStart()
Used to start the consumer thread.
std::atomic< Bool_t > fPrefetchFinished
true if prefetching is over
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.
TString fPathCache
path to the cache directory
std::mutex fMutexReadList
mutex for the list of read blocks
TStopwatch fWaitTime
time waiting to prefetch a buffer (in usec)
std::mutex fMutexPendingList
mutex for the pending list
std::condition_variable fReadBlockAdded
signal the addition of a new red block
void WaitFinishPrefetch()
Killing the async prefetching thread.
TThread * GetThread() const
Return reference to the consumer thread.
TFile * fFile
reference to the file
TList * fPendingBlocks
list of pending blocks to be read
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.
~TFilePrefetch() override
Destructor.
Bool_t IsPrefetchFinished() const
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
ECacheAction
TTreeCache flushing semantics.
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.
void Close(Option_t *option="") override
Close a file.
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
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 ...
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
<div class="legacybox"><h2>Legacy Code</h2> TThread is a legacy interface: there will be no bug fixes...
void *(* VoidRtnFunc_t)(void *)
The TTimeStamp encapsulates seconds and ns since EPOCH.