10 #include "TFileCacheRead.h"
22 #include "TTreeCache.h"
25 class TTreeCacheDebug :
public TTreeCache {
27 void dump(
const char *
label,
const char *trailer)
29 Long64_t entry = fOwner->GetReadEntry();
31 << label <<
": " << entry <<
" "
32 <<
"{ fEntryMin=" << fEntryMin
33 <<
", fEntryMax=" << fEntryMax
34 <<
", fEntryNext=" << fEntryNext
35 <<
", fZipBytes=" << fZipBytes
36 <<
", fNbranches=" << fNbranches
37 <<
", fNReadOk=" << fNReadOk
38 <<
", fNReadMiss=" << fNReadMiss
39 <<
", fNReadPref=" << fNReadPref
40 <<
", fBranches=" << fBranches
41 <<
", fBrNames=" << fBrNames
42 <<
", fOwner=" << fOwner
43 <<
", fTree=" << fTree
44 <<
", fIsLearning=" << fIsLearning
45 <<
", fIsManual=" << fIsManual
46 <<
"; fBufferSizeMin=" << fBufferSizeMin
47 <<
", fBufferSize=" << fBufferSize
48 <<
", fBufferLen=" << fBufferLen
49 <<
", fBytesToPrefetch=" << fBytesToPrefetch
50 <<
", fFirstIndexToPrefetch=" << fFirstIndexToPrefetch
51 <<
", fAsyncReading=" << fAsyncReading
52 <<
", fNseek=" << fNseek
53 <<
", fNtot=" << fNtot
55 <<
", fSeekSize=" << fSeekSize
56 <<
", fSeek=" << fSeek
57 <<
", fSeekIndex=" << fSeekIndex
58 <<
", fSeekSort=" << fSeekSort
60 <<
", fSeekLen=" << fSeekLen
61 <<
", fSeekSortLen=" << fSeekSortLen
62 <<
", fSeekPos=" << fSeekPos
64 <<
", fFile=" << fFile
65 <<
", fBuffer=" << (
void *) fBuffer
66 <<
", fIsSorted=" << fIsSorted
112 Bool_t parallelopen )
113 : TFile(path,
"NET", ftitle, compress),
127 : TFile(path,
"NET", ftitle, compress),
148 gEnv->SetValue(
"TFile.AsyncReading", 1);
154 if (fOption ==
"NEW")
157 Bool_t
create = (fOption ==
"CREATE");
158 Bool_t recreate = (fOption ==
"RECREATE");
159 Bool_t
update = (fOption ==
"UPDATE");
160 Bool_t
read = (fOption ==
"READ") || (fOption ==
"READWRAP");
161 Bool_t readwrap = (fOption ==
"READWRAP");
163 if (!create && !recreate && !update && !read)
171 if (!gSystem->AccessPathName(path, kFileExists))
172 gSystem->Unlink(path);
180 if (update && gSystem->AccessPathName(path, kFileExists))
186 assert(read || update || create);
199 throw cms::Exception(
"TStorageFactoryFile::TStorageFactoryFile()")
200 <<
"Cannot open file '" << path <<
"'";
217 fWritable = read ? kFALSE : kTRUE;
249 Error(
"ReadBuffer",
"Cannot read from a zombie file");
255 Error(
"ReadBuffer",
"Cannot read from a file that is not open");
272 if (TFileCacheRead *
c = GetCacheRead())
274 Long64_t here = GetRelOffset();
275 Bool_t async =
c->IsAsyncReading();
281 Int_t st = ReadBufferViaCache(async ? 0 : buf, len);
307 return n ? kFALSE : kTRUE;
316 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
322 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
387 Int_t remaining = nbuf;
390 IOSize remaining_buffer_size=0;
393 for (Int_t
i=0;
i<nbuf;
i++) remaining_buffer_size+=len[
i];
395 char *current_buffer = buf;
396 Long64_t *current_pos = pos;
397 Int_t *current_len = len;
401 while (remaining > 0) {
403 pack_count = repacker.
pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
410 std::vector<IOPosBuffer> &
iov = repacker.
iov();
412 if (result != io_buffer_used) {
415 xstats.
tick(io_buffer_used);
416 repacker.
unpack(current_buffer);
419 remaining_buffer_size -= real_bytes_processed;
420 current_buffer += real_bytes_processed;
422 current_pos += pack_count;
423 current_len += pack_count;
424 remaining -= pack_count;
427 assert(remaining_buffer_size == 0);
437 Error(
"ReadBuffers",
"Cannot read from a zombie file");
443 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
457 void*
const nobuf = 0;
459 std::vector<IOPosBuffer>
iov;
461 for (Int_t
i = 0;
i < nbuf; ++
i)
476 return success ? kFALSE : TFile::ReadBuffers(buf, pos, len, nbuf);
485 Error(
"WriteBuffer",
"Cannot write to a zombie file");
491 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
497 Error(
"WriteBuffer",
"File is not writable");
506 switch ((st = WriteBufferViaCache(buf, len)))
517 return n > 0 ? kFALSE : kTRUE;
527 Error(
"WriteBuffer",
"Error writing to cache");
568 <<
"Cannot open file '" << pathname <<
"'";
615 Long_t *
flags, Long_t *modtime)
630 TSystem::ResetErrno();
Code categoryCode() const
TStorageFactoryFile(void)
IOSize xwrite(const void *from, IOSize n)
CacheHint cacheHint(void) const
static StorageAccount::Counter * s_statsWrite
static StorageAccount::Counter * s_statsStat
#define PREFETCH_PROBE_LENGTH
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
void tick(double amount=0., int64_t tick=0) const
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
static StorageAccount::Counter * s_statsXWrite
static StorageAccount::Counter * s_statsClose
std::vector< Variable::Flags > flags
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
static StorageFactory * get(void)
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, const char *label)
IOSize realBytesProcessed() const
static StorageAccount::Counter * s_statsARead
tuple path
else: Piece not in the list, fine.
virtual Bool_t ReadBufferAsync(Long64_t off, Int_t len)
unsigned int(* Counter)(align::ID, const TrackerTopology *)
virtual IOOffset position(void) const
static StorageAccount::Counter * s_statsCtor
virtual Bool_t ReadBuffer(char *buf, Int_t len)
XrdSiteStatisticsInformation * statsService
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
static StorageAccount::Counter * s_statsRead
static StorageAccount::Counter * s_statsXRead
static StorageAccount::Counter * s_statsFlush
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
static StorageAccount::Counter * s_statsCWrite
static Counter & counter(const std::string &storageClass, const std::string &operation)
IOSize bufferUsed() const
virtual IOOffset size(void) const
~TStorageFactoryFile(void)
std::vector< IOPosBuffer > & iov()
void setException(std::exception_ptr e)
void ResetErrno(void) const
void setSize(size_t size)
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
virtual Int_t SysClose(Int_t fd)
static StorageAccount::Counter * s_statsSeek
static StorageAccount::Counter * s_statsOpen
virtual Int_t SysSync(Int_t fd)
Bool_t ReadBuffersSync(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
void Initialize(const char *name, Option_t *option="")
tuple size
Write out results.
static StorageAccount::Counter * s_statsCPrefetch
static StorageAccount::Counter * s_statsCRead