24 #if (__GNUC__ >= 3) || defined(__INTEL_COMPILER)
25 #if !defined(R__unlikely)
26 #define R__unlikely(expr) __builtin_expect(!!(expr), 0)
28 #if !defined(R__likely)
29 #define R__likely(expr) __builtin_expect(!!(expr), 1)
32 #define R__unlikely(expr) expr
33 #define R__likely(expr) expr
50 TBasket::
TBasket() : fCompressedBufferRef(0), fOwnsCompressedBuffer(
kFALSE), fLastWriteBufferSize(0)
85 TKey(branch->GetDirectory()),fCompressedBufferRef(0), fOwnsCompressedBuffer(
kFALSE), fLastWriteBufferSize(0)
157 fBufferSize = newsize;
175 return nBytes>0 ? nBytes : -1;
251 }
else if (st == 0) {
294 if (dentries >= fNevBuf)
return;
308 for (i = 0; i<(fNevBufSize-dentries); ++i) {
312 for (i = fNevBufSize-dentries; i<
fNevBufSize; ++i) {
326 char *buffer = buf->
Buffer();
332 #define OLD_CASE_EXPRESSION fObjlen==fNbytes-fKeylen && GetBranch()->GetCompressionLevel()!=0 && file->GetVersion()<=30401
395 if (curBufferSize < len) {
442 char *rawUncompressedBuffer, *rawCompressedBuffer;
443 Int_t uncompressedBufferLen;
456 if (len <= 0)
return -len;
476 if (!readBufferRef) {
477 Error(
"ReadBasketBuffers",
"Unable to allocate buffer.");
487 }
else if (st == 0) {
512 Streamer(*readBufferRef);
517 rawCompressedBuffer = readBufferRef->
Buffer();
530 Error(
"ReadBasketBuffers",
"Unable to allocate buffer.");
546 fBuffer = rawUncompressedBuffer;
561 memcpy(rawUncompressedBuffer, rawCompressedBuffer, fKeylen);
562 char *rawUncompressedObjectBuffer = rawUncompressedBuffer+
fKeylen;
563 UChar_t *rawCompressedObjectBuffer = (
UChar_t*)rawCompressedBuffer+fKeylen;
565 Int_t nout = 0, noutot = 0, nintot = 0;
571 Error(
"ReadBasketBuffers",
"Inconsistency found in header (nin=%d, nbuf=%d)", nin, nbuf);
576 memcpy(rawUncompressedBuffer+fKeylen, rawCompressedObjectBuffer+fKeylen,
fObjlen);
580 R__unzip(&nin, rawCompressedObjectBuffer, &nbuf, (
unsigned char*) rawUncompressedObjectBuffer, &nout);
585 rawCompressedObjectBuffer += nin;
586 rawUncompressedObjectBuffer += nout;
591 Error(
"ReadBasketBuffers",
"fNbytes = %d, fKeylen = %d, fObjlen = %d, noutot = %d, nout=%d, nin=%d, nbuf=%d",
fNbytes,fKeylen,
fObjlen, noutot,nout,nin,nbuf);
604 memcpy(rawUncompressedBuffer, rawCompressedBuffer, len);
622 Warning(
"ReadBasketBuffers",
"basket:%s has fNevBuf=%d but fEntryOffset=0, pos=%lld, len=%d, fNbytes=%d, fObjlen=%d, trying to repair",
GetName(),fNevBuf,pos,len,
fNbytes,
fObjlen);
647 const Int_t len = 128;
670 if (curSize > 2*curLen)
673 if (curSize > 2*curBsize ) {
675 if (curSize > 2*avgSize) {
677 if (curLen > newSize) {
680 if (avgSize > newSize) {
683 newSize = newSize + 512 - newSize%512;
704 if (newNevBufSize==0) {
707 }
else if (newNevBufSize != fNevBufSize) {
713 fNevBufSize = newNevBufSize;
763 void TBasket::Streamer(
TBuffer &b)
771 if (fNevBufSize < 0) {
772 Error(
"Streamer",
"The value of fNevBufSize is incorrect (%d) ; trying to recover by setting it to zero",fNevBufSize);
779 if (fLast > fBufferSize) fBufferSize =
fLast;
787 if (20<flag && flag<40) {
797 if (flag == 1 || flag > 10) {
815 if (fLast > fBufferSize) fBufferSize =
fLast;
880 if (fNevBuf+1 >= fNevBufSize) {
890 fNevBufSize = newsize;
921 const Int_t kWrite = 1;
949 return nBytes>0 ? fKeylen+nout : -1;
969 Int_t lbuf, nout, noutot, bufmax, nzip;
982 Warning(
"WriteBuffer",
"Unable to allocate the compressed buffer");
991 for (
Int_t i = 0; i < nbuffers; ++i) {
992 if (i == nbuffers - 1) bufmax =
fObjlen - nzip;
993 else bufmax = kMAXZIPBUF;
995 R__zipMultipleAlgorithm(cxlevel, &bufmax, objbuf, &bufmax, bufcur, &nout, cxAlgorithm);
1000 if (nout == 0 || nout >=
fObjlen) {
1009 if ((nout+fKeylen)>buflen) {
1010 Warning(
"WriteBuffer",
"Possible memory corruption due to compression algorithm, wrote %d bytes past the end of a block of %d bytes. fNbytes=%d, fObjLen=%d, fKeylen=%d",
1017 objbuf += kMAXZIPBUF;
1038 return nBytes>0 ? fKeylen+nout : -1;
Int_t fVersion
Key version identifier.
TObject * GetParent() const
Return pointer to parent of this buffer.
Int_t ReadBasketBytes(Long64_t pos, TFile *file)
Read basket buffers in memory and cleanup.
void SetBufferOffset(Int_t offset=0)
virtual void SetReadMode()
Set read mode of basket.
void Update(Int_t newlast)
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
virtual TVirtualPerfStats * GetPerfStats() const
Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
Read basket buffers in memory and cleanup.
virtual void IncrementTotalBuffers(Int_t nbytes)
Int_t GetCompressionAlgorithm() const
Provides the interface for the PROOF internal performance measurement and event tracing.
A cache when reading files over the network.
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Int_t * fEntryOffset
[fNevBuf] Displacement of entries in fBuffer(TKey)
virtual void SetName(const char *name)
Change (i.e.
A specialized TFileCacheRead object for a TTree.
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Long64_t GetTotBytes(Option_t *option="") const
Return total number of bytes in the branch (excluding current buffer) if option ="*" includes all sub...
Buffer base class used for serializing objects.
void SetParent(TObject *parent)
Set parent owning this buffer.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
char * fBuffer
Object buffer.
TDirectory * fMotherDir
!pointer to mother directory
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
TFileCacheRead * GetCacheRead(TObject *tree=0) const
Return a pointer to the current read cache.
static struct mg_connection * fc(struct mg_context *ctx)
virtual void WriteArray(const Bool_t *b, Int_t n)=0
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
virtual void Reset()
Reset the basket to the starting state.
virtual Int_t WriteBuffer()
Write buffer of this basket on the current file.
virtual Int_t WriteFile(Int_t cycle=1, TFile *f=0)
Write the encoded object supported by this key.
int R__unzip_header(Int_t *nin, UChar_t *bufin, Int_t *lout)
Short_t fKeylen
Number of bytes for the key itself.
Bool_t IsWritable() const
TString fClassName
Object Class name.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void InitializeCompressedBuffer(Int_t len, TFile *file)
Initialize the compressed buffer; either from the TTree or create a local one.
virtual Int_t WriteFileKeepBuffer(TFile *f=0)
Write the encoded object supported by this key.
void Expand(Int_t newsize, Bool_t copy=kTRUE)
Expand (or shrink) the I/O buffer to newsize bytes.
Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen)
Read the logical record header starting at a certain postion.
TBuffer * GetBufferRef() const
Bool_t fOwnsCompressedBuffer
Compressed buffer.
virtual void AddNoCacheReadCalls(Int_t reads)
virtual void AdjustSize(Int_t newsize)
Increase the size of the current fBuffer up to newsize.
Int_t ReadBasketBuffersUncompressedCase()
By-passing buffer unzipping has been requested and is possible (only 1 entry in this basket)...
Int_t GetEntryPointer(Int_t Entry)
Get pointer to buffer for internal entry.
#define OLD_CASE_EXPRESSION
Bool_t TestBit(UInt_t f) const
Manages buffers for branches of a Tree.
TBuffer * fCompressedBufferRef
void SetReadMode()
Set buffer in read mode.
virtual const char * GetName() const
Returns name of object.
virtual void Reset()
Reset the key as it had not been 'filled' yet.
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
TBuffer * fBufferRef
Pointer to the TBuffer object.
Long64_t fSeekKey
Location of object on file.
virtual Int_t GetBasketSize() const
Short_t fCycle
Cycle number.
Describe directory structure in memory.
The TTimeStamp encapsulates seconds and ns since EPOCH.
static TBuffer * R__InitializeReadBasketBuffer(TBuffer *bufferRef, Int_t len, TFile *file)
Initialize a buffer for reading if it is not already initialized.
virtual ~TBasket()
Basket destructor.
void R__unzip(Int_t *nin, UChar_t *bufin, Int_t *lout, char *bufout, Int_t *nout)
Int_t fObjlen
Length of uncompressed object in bytes.
TDirectory * GetDirectory() const
virtual void Create(Int_t nbytes, TFile *f=0)
Create a TKey object of specified size.
virtual Int_t GetUnzipBuffer(char **, Long64_t, Int_t, Bool_t *)
virtual void SetEntryOffsetLen(Int_t len, Bool_t updateSubBranches=kFALSE)
Update the default value for the branch's fEntryOffsetLen if and only if it was already non zero (and...
virtual void DeleteEntryOffset()
Delete fEntryOffset array.
TBuffer * GetTransientBuffer(Int_t size)
Returns the transient buffer currently used by this TTree for reading/writing baskets.
virtual Int_t DropBuffers()
Drop buffers of this basket if it is not the current basket.
Short_t Max(Short_t a, Short_t b)
Int_t GetEntryOffsetLen() const
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
Int_t fNbytes
Number of bytes for the object on file.
A TTree object has a header with a name and a title.
Long64_t CopyTo(TFile *to)
Copy the basket of this branch onto the file to.
const UInt_t kDisplacementMask
virtual TFile * GetFile(Int_t mode=0)
Return pointer to the file where branch buffers reside, returns 0 in case branch buffers reside in th...
virtual void SetBufferDisplacement()=0
Int_t ReadBasketBuffersUnzip(char *, Int_t, Bool_t, TFile *)
We always create the TBuffer for the basket but it hold the buffer from the cache.
A TTree is a list of TBranches.
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
#define R__unlikely(expr)
Int_t GetCompressionLevel() const
Int_t GetWriteBasket() const
TBasket()
Size of the buffer last time we wrote it to disk.
virtual void SetWriteMode()
Set write mode of basket.
static Int_t * ReAllocInt(Int_t *vp, size_t size, size_t oldsize)
Reallocate (i.e.
void SetWriteMode()
Set buffer in write mode.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
void SetBuffer(void *buf, UInt_t bufsiz=0, Bool_t adopt=kTRUE, ReAllocCharFun_t reallocfunc=0)
Sets a new buffer in an existing TBuffer object.
virtual Int_t ReadArray(Bool_t *&b)=0
virtual void AddNoCacheBytesRead(Long64_t len)
Int_t LoadBasketBuffers(Long64_t pos, Int_t len, TFile *file, TTree *tree=0)
Load basket buffers in memory without unziping.
virtual void MoveEntries(Int_t dentries)
Remove the first dentries of this basket, moving entries at dentries to the start of the buffer...
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.