7 #include "TFileCacheRead.h"
18 #include "TTreeCache.h"
21 class TTreeCacheDebug :
public TTreeCache {
23 void dump(
const char *
label,
const char *trailer)
25 Long64_t
entry = fOwner->GetReadEntry();
27 << label <<
": " << entry <<
" "
28 <<
"{ fEntryMin=" << fEntryMin
29 <<
", fEntryMax=" << fEntryMax
30 <<
", fEntryNext=" << fEntryNext
31 <<
", fZipBytes=" << fZipBytes
32 <<
", fNbranches=" << fNbranches
33 <<
", fNReadOk=" << fNReadOk
34 <<
", fNReadMiss=" << fNReadMiss
35 <<
", fNReadPref=" << fNReadPref
36 <<
", fBranches=" << fBranches
37 <<
", fBrNames=" << fBrNames
38 <<
", fOwner=" << fOwner
39 <<
", fTree=" << fTree
40 <<
", fIsLearning=" << fIsLearning
41 <<
", fIsManual=" << fIsManual
42 <<
"; fBufferSizeMin=" << fBufferSizeMin
43 <<
", fBufferSize=" << fBufferSize
44 <<
", fBufferLen=" << fBufferLen
45 <<
", fBytesToPrefetch=" << fBytesToPrefetch
46 <<
", fFirstIndexToPrefetch=" << fFirstIndexToPrefetch
47 <<
", fAsyncReading=" << fAsyncReading
48 <<
", fNseek=" << fNseek
49 <<
", fNtot=" << fNtot
51 <<
", fSeekSize=" << fSeekSize
52 <<
", fSeek=" << fSeek
53 <<
", fSeekIndex=" << fSeekIndex
54 <<
", fSeekSort=" << fSeekSort
56 <<
", fSeekLen=" << fSeekLen
57 <<
", fSeekSortLen=" << fSeekSortLen
58 <<
", fSeekPos=" << fSeekPos
60 <<
", fFile=" << fFile
61 <<
", fBuffer=" << (
void *) fBuffer
62 <<
", fIsSorted=" << fIsSorted
107 Bool_t parallelopen )
108 : TFile(path,
"NET", ftitle, compress),
118 : TFile(path,
"NET", ftitle, compress),
135 gEnv->SetValue(
"TFile.AsyncReading", 1);
141 if (fOption ==
"NEW")
144 Bool_t
create = (fOption ==
"CREATE");
145 Bool_t recreate = (fOption ==
"RECREATE");
146 Bool_t
update = (fOption ==
"UPDATE");
147 Bool_t
read = (fOption ==
"READ");
149 if (!create && !recreate && !update && !read)
157 if (!gSystem->AccessPathName(path, kFileExists))
158 gSystem->Unlink(path);
166 if (update && gSystem->AccessPathName(path, kFileExists))
182 throw cms::Exception(
"TStorageFactoryFile::TStorageFactoryFile()")
183 <<
"Cannot open file '" << path <<
"'";
188 fWritable = read ? kFALSE : kTRUE;
220 Error(
"ReadBuffer",
"Cannot read from a zombie file");
226 Error(
"ReadBuffer",
"Cannot read from a file that is not open");
243 if (TFileCacheRead *
c = GetCacheRead())
245 Long64_t here = GetRelOffset();
246 Bool_t async =
c->IsAsyncReading();
252 Int_t st = ReadBufferViaCache(async ? 0 : buf, len);
278 return n ? kFALSE : kTRUE;
287 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
293 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
358 Int_t remaining = nbuf;
361 IOSize remaining_buffer_size=0;
364 for (Int_t
i=0;
i<nbuf;
i++) remaining_buffer_size+=len[
i];
366 char *current_buffer = buf;
367 Long64_t *current_pos =
pos;
368 Int_t *current_len = len;
372 while (remaining > 0) {
374 pack_count = repacker.
pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
381 std::vector<IOPosBuffer> &
iov = repacker.
iov();
383 if (result != io_buffer_used) {
386 xstats.
tick(io_buffer_used);
387 repacker.
unpack(current_buffer);
390 remaining_buffer_size -= real_bytes_processed;
391 current_buffer += real_bytes_processed;
393 current_pos += pack_count;
394 current_len += pack_count;
395 remaining -= pack_count;
398 assert(remaining_buffer_size == 0);
408 Error(
"ReadBuffers",
"Cannot read from a zombie file");
414 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
428 void*
const nobuf = 0;
430 std::vector<IOPosBuffer>
iov;
432 for (Int_t
i = 0;
i < nbuf; ++
i)
447 return success ? kFALSE : TFile::ReadBuffers(buf, pos, len, nbuf);
456 Error(
"WriteBuffer",
"Cannot write to a zombie file");
462 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
468 Error(
"WriteBuffer",
"File is not writable");
477 switch ((st = WriteBufferViaCache(buf, len)))
488 return n > 0 ? kFALSE : kTRUE;
498 Error(
"WriteBuffer",
"Error writing to cache");
539 <<
"Cannot open file '" << pathname <<
"'";
586 Long_t *
flags, Long_t *modtime)
590 *
id = ::Hash(fRealName);
601 TSystem::ResetErrno();
TStorageFactoryFile(void)
IOSize xwrite(const void *from, IOSize n)
CacheHint cacheHint(void) const
static StorageAccount::Counter * s_statsWrite
static StorageAccount::Counter * s_statsStat
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
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
virtual Bool_t ReadBufferAsync(Long64_t off, Int_t len)
unsigned int(* Counter)(align::ID)
std::pair< std::string, MonitorElement * > entry
virtual IOOffset position(void) const
static StorageAccount::Counter * s_statsCtor
virtual Bool_t ReadBuffer(char *buf, Int_t len)
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)
unsigned int offset(bool)
static StorageAccount::Counter * s_statsRead
static StorageAccount::Counter * s_statsXRead
static StorageAccount::Counter * s_statsFlush
void tick(double amount=0.) const
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 ResetErrno(void) const
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