27 inline 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)); }
114 if (
fFile->GetArchive()) {
147 while (first <= last){
148 mid = first + (last - first) / 2;
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);
442 TString strPath = path;
444 strPath +=
"?filetype=raw";
445 TFile*
file =
new TFile(strPath);
450 buffer = (
char*)
calloc(length,
sizeof(
char));
451 file->ReadBuffer(buffer, 0, length);
453 fFile->fBytesRead += length;
454 fFile->fgBytesRead += length;
455 fFile->SetReadCalls(
fFile->GetReadCalls() + 1);
456 fFile->fgReadCalls++;
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";
void AddPendingBlock(TFPBlock *)
Safe method to add a block to the pendingList.
std::mutex fMutexReadList
void *(* VoidRtnFunc_t)(void *)
void ReadAsync(TFPBlock *, Bool_t &)
Read one block and insert it in prefetchBuffers list.
Bool_t BinarySearchReadList(TFPBlock *, Long64_t, Int_t, Int_t *)
Search for a requested element in a block and return the index.
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.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t mid
void ReallocBlock(Long64_t *, Int_t *, Int_t)
Reallocate the block's buffer based on the length of the elements it will contain.
Bool_t CheckBlockInCache(char *&, TFPBlock *)
Test if the block is in cache.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
Bool_t IsPrefetchFinished() const
static TThread::VoidRtnFunc_t ThreadProc(void *)
Execution loop of the consumer thread.
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.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
std::condition_variable fNewBlockAdded
static const int kMAX_READ_SIZE
Long64_t GetWaitTime()
Return the time spent wating for buffer to be read in microseconds.
const char * AsString() const
Return message digest as string.
Int_t GetNoElem() const
Return number of elements in the block.
char * GetPtrToPiece(Int_t index) const
Get block buffer.
std::mutex fMutexPendingList
Int_t ThreadStart()
Used to start the consumer thread.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
char * GetBuffer() const
Get block buffer.
void SaveBlockInCache(TFPBlock *)
Save the block content in cache.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
TSemaphore * fSemChangeFile
void SetPos(Int_t, Long64_t)
Set pos value for index idx.
void Stop()
Stop the stopwatch.
This code implements the MD5 message-digest algorithm.
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
void SetBuffer(char *)
Set block buffer.
Int_t Run(void *arg=0)
Start the thread.
This class represents the encapsulation of a block request.
void AddReadBlock(TFPBlock *)
Safe method to add a block to the readList.
Int_t Wait()
If the semaphore value is > 0 then decrement it and carry on, else block, waiting on the condition un...
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
R__EXTERN TSystem * gSystem
void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Change the file.
void WaitFinishPrefetch()
Killing the async prefetching thread.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Bool_t ReadBuffer(char *, Long64_t, Int_t)
Return a prefetched element.
Int_t Post()
Increment the value of the semaphore.
Long_t Join(void **ret=0)
Join this thread.
Long64_t GetPos(Int_t) const
Get position of the element at index i.
Int_t SumHex(const char *)
Sum up individual hex values to obtain a decimal value.
Long64_t GetDataSize() const
Return size of the data in the block.
void ReadListOfBlocks()
Get blocks specified in prefetchBlocks.
virtual ~TFilePrefetch()
Destructor.
TThread * GetThread() const
Return reference to the consumer thread.
The TTimeStamp encapsulates seconds and ns since EPOCH.
std::condition_variable fReadBlockAdded
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Int_t GetLen(Int_t) const
Get length of the element at index i.
virtual Bool_t SendFileReadProgress(TFile *)
char * GetBlockFromCache(const char *, Int_t)
Return a buffer from cache.
std::atomic< Bool_t > fPrefetchFinished
virtual void Add(TObject *obj)
Bool_t SetCache(const char *)
Set the path of the cache directory.
void ReadBlock(Long64_t *, Int_t *, Int_t)
Create a TFPBlock object or recycle one and add it to the prefetchBlocks list.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual Int_t GetSize() const
TFilePrefetch(TFile *)
Constructor.
TFPBlock * GetPendingBlock()
Safe method to remove a block from the pendingList.
TFPBlock * CreateBlockObj(Long64_t *, Int_t *, Int_t)
Create a new block or recycle an old one.
ECacheAction
TTreeCache flushing semantics.