171 return nBytes>0 ? nBytes : -1;
247 }
else if (st == 0) {
290 if (dentries >=
fNevBuf)
return;
322 char *buffer = buf->
Buffer();
328 #define OLD_CASE_EXPRESSION fObjlen==fNbytes-fKeylen && GetBranch()->GetCompressionLevel()!=0 && file->GetVersion()<=30401 391 if (curBufferSize < len) {
438 char *rawUncompressedBuffer, *rawCompressedBuffer;
439 Int_t uncompressedBufferLen;
456 if (len <= 0)
return -len;
476 if (!readBufferRef) {
477 Error(
"ReadBasketBuffers",
"Unable to allocate buffer.");
491 }
else if (st == 0) {
518 Streamer(*readBufferRef);
523 rawCompressedBuffer = readBufferRef->
Buffer();
536 Error(
"ReadBasketBuffers",
"Unable to allocate buffer.");
552 fBuffer = rawUncompressedBuffer;
567 memcpy(rawUncompressedBuffer, rawCompressedBuffer, fKeylen);
568 char *rawUncompressedObjectBuffer = rawUncompressedBuffer+
fKeylen;
569 UChar_t *rawCompressedObjectBuffer = (
UChar_t*)rawCompressedBuffer+fKeylen;
571 Int_t nout = 0, noutot = 0, nintot = 0;
577 Error(
"ReadBasketBuffers",
"Inconsistency found in header (nin=%d, nbuf=%d)", nin, nbuf);
582 memcpy(rawUncompressedBuffer+fKeylen, rawCompressedObjectBuffer+fKeylen,
fObjlen);
586 R__unzip(&nin, rawCompressedObjectBuffer, &nbuf, (
unsigned char*) rawUncompressedObjectBuffer, &nout);
591 rawCompressedObjectBuffer += nin;
592 rawUncompressedObjectBuffer += nout;
597 Error(
"ReadBasketBuffers",
"fNbytes = %d, fKeylen = %d, fObjlen = %d, noutot = %d, nout=%d, nin=%d, nbuf=%d",
fNbytes,fKeylen,
fObjlen, noutot,nout,nin,nbuf);
610 memcpy(rawUncompressedBuffer, rawCompressedBuffer, len);
628 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);
653 const Int_t len = 128;
676 if (curSize > 2*curLen)
679 if (curSize > 2*curBsize ) {
681 if (curSize > 2*avgSize) {
683 if (curLen > newSize) {
686 if (avgSize > newSize) {
689 newSize = newSize + 512 - newSize%512;
710 if (newNevBufSize==0) {
777 if (fNevBufSize < 0) {
778 Error(
"Streamer",
"The value of fNevBufSize is incorrect (%d) ; trying to recover by setting it to zero",fNevBufSize);
785 if (fLast > fBufferSize) fBufferSize =
fLast;
793 if (20<flag && flag<40) {
803 if (flag == 1 || flag > 10) {
927 const Int_t kWrite = 1;
955 return nBytes>0 ? fKeylen+nout : -1;
975 Int_t lbuf, nout, noutot, bufmax, nzip;
988 Warning(
"WriteBuffer",
"Unable to allocate the compressed buffer");
997 for (
Int_t i = 0; i < nbuffers; ++i) {
998 if (i == nbuffers - 1) bufmax =
fObjlen - nzip;
999 else bufmax = kMAXZIPBUF;
1001 R__zipMultipleAlgorithm(cxlevel, &bufmax, objbuf, &bufmax, bufcur, &nout, cxAlgorithm);
1006 if (nout == 0 || nout >=
fObjlen) {
1015 if ((nout+fKeylen)>buflen) {
1016 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",
1023 objbuf += kMAXZIPBUF;
1044 return nBytes>0 ? fKeylen+nout : -1;
Int_t fVersion
Key version identifier.
Int_t ReadBasketBytes(Long64_t pos, TFile *file)
Read basket buffers in memory and cleanup.
virtual const char * GetName() const
Returns name of object.
void SetBufferOffset(Int_t offset=0)
Bool_t fHeaderOnly
True when only the basket header must be read/written.
Int_t fLastWriteBufferSize
! Size of the buffer last time we wrote it to disk
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...
Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
Read basket buffers in memory and cleanup.
virtual Int_t GetBasketSize() const
Int_t * fDisplacement
![fNevBuf] Displacement of entries in fBuffer(TKey)
virtual void IncrementTotalBuffers(Int_t nbytes)
Provides the interface for the PROOF internal performance measurement and event tracing.
Int_t GetCompressionLevel() const
A cache when reading files over the network.
TObject * GetParent() const
Return pointer to parent of this buffer.
Int_t fBufferSize
fBuffer length in bytes
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Int_t * fEntryOffset
[fNevBuf] Offset of entries in fBuffer(TKey)
Bool_t TestBit(UInt_t f) const
virtual void SetName(const char *name)
Set the name of the TNamed.
A specialized TFileCacheRead object for a TTree.
TBranch * fBranch
Pointer to the basket support branch.
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.
Buffer base class used for serializing objects.
TDirectory * GetDirectory() const
R__EXTERN TVirtualMutex * gROOTMutex
void SetParent(TObject *parent)
Set parent owning this buffer.
Int_t GetCompressionAlgorithm() const
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
Int_t fNevBuf
Number of entries in basket.
char * fBuffer
Object buffer.
Int_t GetEntryOffsetLen() const
TDirectory * fMotherDir
!pointer to mother directory
TBuffer * GetBufferRef() const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Long64_t GetTotBytes(Option_t *option="") const
Return total number of bytes in the branch (excluding current buffer) if option ="*" includes all sub...
static struct mg_connection * fc(struct mg_context *ctx)
virtual void WriteArray(const Bool_t *b, Int_t n)=0
virtual TVirtualPerfStats * GetPerfStats() const
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.
TString fClassName
Object Class name.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
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.
Bool_t fOwnsCompressedBuffer
! Whether or not we own the 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 GetWriteBasket() const
Int_t GetEntryPointer(Int_t Entry)
Get pointer to buffer for internal entry.
#define OLD_CASE_EXPRESSION
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Manages buffers for branches of a Tree.
TBuffer * fCompressedBufferRef
! Compressed buffer.
void SetReadMode()
Set buffer in read mode.
virtual void Reset()
Reset the key as it had not been 'filled' yet.
TBuffer * GetTransientBuffer(Int_t size)
Returns the transient buffer currently used by this TBranch for reading/writing baskets.
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.
Int_t fNevBufSize
Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null! ...
Long64_t fSeekKey
Location of object on file.
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.
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.
#define R__unlikely(expr)
Short_t Max(Short_t a, Short_t b)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Int_t fLast
Pointer to last used byte in basket.
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
TFileCacheRead * GetCacheRead(TObject *tree=0) const
Return a pointer to the current read cache.
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.
#define R__LOCKGUARD_IMT2(mutex)
const UInt_t kDisplacementMask
Bool_t IsWritable() const
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="")
Set the title of the TNamed.
TBasket()
Default contructor.
virtual void SetWriteMode()
Set write mode of basket.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
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...