9 #include "TFileCacheRead.h"
21 #include "TTreeCache.h"
24 class TTreeCacheDebug :
public TTreeCache {
26 void dump(
const char *
label,
const char *trailer)
28 Long64_t entry = fOwner->GetReadEntry();
30 << label <<
": " << entry <<
" "
31 <<
"{ fEntryMin=" << fEntryMin
32 <<
", fEntryMax=" << fEntryMax
33 <<
", fEntryNext=" << fEntryNext
34 <<
", fZipBytes=" << fZipBytes
35 <<
", fNbranches=" << fNbranches
36 <<
", fNReadOk=" << fNReadOk
37 <<
", fNReadMiss=" << fNReadMiss
38 <<
", fNReadPref=" << fNReadPref
39 <<
", fBranches=" << fBranches
40 <<
", fBrNames=" << fBrNames
41 <<
", fOwner=" << fOwner
42 <<
", fTree=" << fTree
43 <<
", fIsLearning=" << fIsLearning
44 <<
", fIsManual=" << fIsManual
45 <<
"; fBufferSizeMin=" << fBufferSizeMin
46 <<
", fBufferSize=" << fBufferSize
47 <<
", fBufferLen=" << fBufferLen
48 <<
", fBytesToPrefetch=" << fBytesToPrefetch
49 <<
", fFirstIndexToPrefetch=" << fFirstIndexToPrefetch
50 <<
", fAsyncReading=" << fAsyncReading
51 <<
", fNseek=" << fNseek
52 <<
", fNtot=" << fNtot
54 <<
", fSeekSize=" << fSeekSize
55 <<
", fSeek=" << fSeek
56 <<
", fSeekIndex=" << fSeekIndex
57 <<
", fSeekSort=" << fSeekSort
59 <<
", fSeekLen=" << fSeekLen
60 <<
", fSeekSortLen=" << fSeekSortLen
61 <<
", fSeekPos=" << fSeekPos
63 <<
", fFile=" << fFile
64 <<
", fBuffer=" << (
void *) fBuffer
65 <<
", fIsSorted=" << fIsSorted
110 Bool_t parallelopen )
111 : TFile(path,
"NET", ftitle, compress),
121 : TFile(path,
"NET", ftitle, compress),
138 gEnv->SetValue(
"TFile.AsyncReading", 1);
144 if (fOption ==
"NEW")
147 Bool_t
create = (fOption ==
"CREATE");
148 Bool_t recreate = (fOption ==
"RECREATE");
149 Bool_t
update = (fOption ==
"UPDATE");
150 Bool_t
read = (fOption ==
"READ") || (fOption ==
"READWRAP");
151 Bool_t readwrap = (fOption ==
"READWRAP");
153 if (!create && !recreate && !update && !read)
161 if (!gSystem->AccessPathName(path, kFileExists))
162 gSystem->Unlink(path);
170 if (update && gSystem->AccessPathName(path, kFileExists))
176 assert(read || update || create);
189 throw cms::Exception(
"TStorageFactoryFile::TStorageFactoryFile()")
190 <<
"Cannot open file '" << path <<
"'";
207 fWritable = read ? kFALSE : kTRUE;
239 Error(
"ReadBuffer",
"Cannot read from a zombie file");
245 Error(
"ReadBuffer",
"Cannot read from a file that is not open");
262 if (TFileCacheRead *
c = GetCacheRead())
264 Long64_t here = GetRelOffset();
265 Bool_t async =
c->IsAsyncReading();
271 Int_t st = ReadBufferViaCache(async ? 0 : buf, len);
297 return n ? kFALSE : kTRUE;
306 Error(
"ReadBufferAsync",
"Cannot read from a zombie file");
312 Error(
"ReadBufferAsync",
"Cannot read from a file that is not open");
377 Int_t remaining = nbuf;
380 IOSize remaining_buffer_size=0;
383 for (Int_t
i=0;
i<nbuf;
i++) remaining_buffer_size+=len[
i];
385 char *current_buffer = buf;
386 Long64_t *current_pos = pos;
387 Int_t *current_len = len;
391 while (remaining > 0) {
393 pack_count = repacker.
pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
400 std::vector<IOPosBuffer> &
iov = repacker.
iov();
402 if (result != io_buffer_used) {
405 xstats.
tick(io_buffer_used);
406 repacker.
unpack(current_buffer);
409 remaining_buffer_size -= real_bytes_processed;
410 current_buffer += real_bytes_processed;
412 current_pos += pack_count;
413 current_len += pack_count;
414 remaining -= pack_count;
417 assert(remaining_buffer_size == 0);
427 Error(
"ReadBuffers",
"Cannot read from a zombie file");
433 Error(
"ReadBuffers",
"Cannot read from a file that is not open");
447 void*
const nobuf = 0;
449 std::vector<IOPosBuffer>
iov;
451 for (Int_t
i = 0;
i < nbuf; ++
i)
466 return success ? kFALSE : TFile::ReadBuffers(buf, pos, len, nbuf);
475 Error(
"WriteBuffer",
"Cannot write to a zombie file");
481 Error(
"WriteBuffer",
"Cannot write to a file that is not open");
487 Error(
"WriteBuffer",
"File is not writable");
496 switch ((st = WriteBufferViaCache(buf, len)))
507 return n > 0 ? kFALSE : kTRUE;
517 Error(
"WriteBuffer",
"Error writing to cache");
558 <<
"Cannot open file '" << pathname <<
"'";
605 Long_t *
flags, Long_t *modtime)
620 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)
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
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
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