1 #ifndef XRD_READCACHE_H
2 #define XRD_READCACHE_H
36 #include "XrdSys/XrdSysHeaders.hh"
39 #include "XrdClient/XrdClientVector.hh"
40 #include "XrdClient/XrdClientConst.hh"
63 long long end_offs,
long long ticksnow,
64 bool placeholder=
false);
72 return ( (end_offs >= begin_offs) &&
73 (fBeginOffset >= begin_offs) &&
74 (fEndOffset <= end_offs) );
79 return ( (end_offs > begin_offs) &&
80 (fBeginOffset <= begin_offs) && (fEndOffset >= end_offs) );
86 if ( (fBeginOffset >= begin_offs) && (fBeginOffset <= end_offs) )
return true;
92 return (fBeginOffset <= offs) && (fEndOffset >= offs);
98 inline bool GetInterval(
const void *buffer,
long long begin_offs,
102 memcpy((
void *)buffer, ((
char *)fData)+(begin_offs - fBeginOffset),
103 end_offs - begin_offs + 1);
110 long long end_offs) {
112 long long b = -1, e,
l;
114 if (begin_offs > end_offs)
return 0;
117 if ( (begin_offs >= fBeginOffset) &&
118 (begin_offs <= fEndOffset) )
124 e = xrdmin(end_offs, fEndOffset);
129 memcpy((
void *)buffer, ((
char *)fData)+(b - fBeginOffset), l);
138 long Size() {
return (fEndOffset - fBeginOffset + 1); }
140 inline void Touch(
long long ticksnow) { fTimestampTicks = ticksnow; }
151 typedef XrdClientVector<XrdClientReadCacheItem *>
ItemVect;
185 if (fReadsCounter > 0)
186 fMissRate = (float)fMissCount / fReadsCounter;
187 if (fBytesSubmitted > 0)
188 fBytesUsefulness = (float)fBytesHit / fBytesSubmitted;
193 long long begin_offs);
207 long long end_offs,
bool PerfCalc,
215 long long &bytessubmitted,
222 long long &misscount,
228 long long &readreqcnt,
231 float &bytesusefulness
244 cout <<
"Low level caching info:" << endl;
245 cout <<
" StallsRate=" << fMissRate << endl;
246 cout <<
" StallsCount=" << fMissCount << endl;
247 cout <<
" ReadsCounter=" << fReadsCounter << endl;
248 cout <<
" BytesUsefulness=" << fBytesUsefulness << endl;
249 cout <<
" BytesSubmitted=" << fBytesSubmitted <<
" BytesHit=" <<
250 fBytesHit << endl << endl;
260 long long end_offs,
bool pinned=
false);
263 void RemoveItems(
long long begin_offs,
long long end_offs,
bool remove_overlapped =
false);
275 void UnPinCacheBlk(
long long begin_offs,
long long end_offs);
276 void *
FindBlk(
long long begin_offs,
long long end_offs);
281 return (bc < fMaxCacheSize);
void * FindBlk(long long begin_offs, long long end_offs)
XrdClientReadCacheItem(const void *buffer, long long begin_offs, long long end_offs, long long ticksnow, bool placeholder=false)
void PutPlaceholder(long long begin_offs, long long end_offs)
void UnPinCacheBlk(long long begin_offs, long long end_offs)
bool WillFit(long long bc)
bool ContainedInInterval(long long begin_offs, long long end_offs)
bool ContainsOffset(long long offs)
bool IntersectInterval(long long begin_offs, long long end_offs)
void RemoveItems(bool leavepinned=true)
long GetDataIfPresent(const void *buffer, long long begin_offs, long long end_offs, bool PerfCalc, XrdClientIntvList &missingblks, long &outstandingblks)
long GetPartialInterval(const void *buffer, long long begin_offs, long long end_offs)
int FindInsertionApprox(long long begin_offs)
void SetBlkRemovalPolicy(int p)
bool ContainsInterval(long long begin_offs, long long end_offs)
void Touch(long long ticksnow)
bool MakeFreeSpace(long long bytes)
#define XrdSysMutexHelper
XrdClientVector< XrdClientReadCacheItem * > ItemVect
void GetInfo(int &size, long long &bytessubmitted, long long &byteshit, long long &misscount, float &missrate, long long &readreqcnt, float &bytesusefulness)
long long GetTimestampTicks()
long long GetTotalByteCount()
long long fTotalByteCount
void RemovePlaceholders()
long long fBytesSubmitted
XrdClientVector< XrdClientCacheInterval > XrdClientIntvList
long long GetTimestampTick()
void UpdatePerfCounters()
void SubmitXMessage(XrdClientMessage *xmsg, long long begin_offs, long long end_offs)
long long fTimestampTickCounter
bool SubmitRawData(const void *buffer, long long begin_offs, long long end_offs, bool pinned=false)
bool GetInterval(const void *buffer, long long begin_offs, long long end_offs)
~XrdClientReadCacheItem()
int FindInsertionApprox_rec(int startidx, int endidx, long long begin_offs)