Logo ROOT   6.08/07
Reference Guide
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 19/01/96
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
12 #ifndef ROOT_TBasket
13 #define ROOT_TBasket
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBasket //
19 // //
20 // The TBasket objects are created at run time to collect TTree entries //
21 // in buffers. When a Basket is full, it is written to the file. //
22 // The Basket is kept in memory if there is enough space. //
23 // (see the fMaxVirtualsize of TTree). //
24 // //
25 // The Basket class derives from TKey. //
26 //////////////////////////////////////////////////////////////////////////
29 #ifndef ROOT_TKey
30 #include "TKey.h"
31 #endif
34 class TFile;
35 class TTree;
36 class TBranch;
38 class TBasket : public TKey {
40 private:
41  TBasket(const TBasket&); ///< TBasket objects are not copiable.
42  TBasket& operator=(const TBasket&); ///< TBasket objects are not copiable.
44  // Internal corner cases for ReadBasketBuffers
48  // Helper for managing the compressed buffer.
51 protected:
52  Int_t fBufferSize; ///< fBuffer length in bytes
53  Int_t fNevBufSize; ///< Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null!
54  Int_t fNevBuf; ///< Number of entries in basket
55  Int_t fLast; ///< Pointer to last used byte in basket
56  Bool_t fHeaderOnly; ///< True when only the basket header must be read/written
57  Int_t *fDisplacement; ///<![fNevBuf] Displacement of entries in fBuffer(TKey)
58  Int_t *fEntryOffset; ///<[fNevBuf] Offset of entries in fBuffer(TKey)
59  TBranch *fBranch; ///<Pointer to the basket support branch
60  TBuffer *fCompressedBufferRef; ///<! Compressed buffer.
61  Bool_t fOwnsCompressedBuffer; ///<! Whether or not we own the compressed buffer.
62  Int_t fLastWriteBufferSize; ///<! Size of the buffer last time we wrote it to disk
64 public:
66  TBasket();
67  TBasket(TDirectory *motherDir);
68  TBasket(const char *name, const char *title, TBranch *branch);
69  virtual ~TBasket();
71  virtual void AdjustSize(Int_t newsize);
72  virtual void DeleteEntryOffset();
73  virtual Int_t DropBuffers();
74  TBranch *GetBranch() const {return fBranch;}
75  Int_t GetBufferSize() const {return fBufferSize;}
76  Int_t *GetDisplacement() const {return fDisplacement;}
77  Int_t *GetEntryOffset() const {return fEntryOffset;}
79  Int_t GetNevBuf() const {return fNevBuf;}
80  Int_t GetNevBufSize() const {return fNevBufSize;}
81  Int_t GetLast() const {return fLast;}
82  virtual void MoveEntries(Int_t dentries);
83  virtual void PrepareBasket(Long64_t /* entry */) {};
84  Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file);
85  Int_t ReadBasketBytes(Long64_t pos, TFile *file);
86  virtual void Reset();
88  Int_t LoadBasketBuffers(Long64_t pos, Int_t len, TFile *file, TTree *tree = 0);
89  Long64_t CopyTo(TFile *to);
91  void SetBranch(TBranch *branch) { fBranch = branch; }
92  void SetNevBufSize(Int_t n) { fNevBufSize=n; }
93  virtual void SetReadMode();
94  virtual void SetWriteMode();
95  inline void Update(Int_t newlast) { Update(newlast,newlast); };
96  virtual void Update(Int_t newlast, Int_t skipped);
97  virtual Int_t WriteBuffer();
99  ClassDef(TBasket,2); //the TBranch buffers
100 };
102 #endif
Int_t ReadBasketBytes(Long64_t pos, TFile *file)
Read basket buffers in memory and cleanup.
Definition: TBasket.cxx:651
Bool_t fHeaderOnly
True when only the basket header must be read/written.
Definition: TBasket.h:56
Int_t fLastWriteBufferSize
! Size of the buffer last time we wrote it to disk
Definition: TBasket.h:62
virtual void SetReadMode()
Set read mode of basket.
Definition: TBasket.cxx:751
void Update(Int_t newlast)
Definition: TBasket.h:95
Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
Read basket buffers in memory and cleanup.
Definition: TBasket.cxx:431
long long Long64_t
Definition: RtypesCore.h:69
Int_t * fDisplacement
![fNevBuf] Displacement of entries in fBuffer(TKey)
Definition: TBasket.h:57
Int_t GetNevBufSize() const
Definition: TBasket.h:80
Int_t fBufferSize
fBuffer length in bytes
Definition: TBasket.h:52
Int_t * fEntryOffset
[fNevBuf] Offset of entries in fBuffer(TKey)
Definition: TBasket.h:58
TBranch * fBranch
Pointer to the basket support branch.
Definition: TBasket.h:59
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t fNevBuf
Number of entries in basket.
Definition: TBasket.h:54
void SetBranch(TBranch *branch)
Definition: TBasket.h:91
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void Reset()
Reset the basket to the starting state.
Definition: TBasket.cxx:666
virtual Int_t WriteBuffer()
Write buffer of this basket on the current file.
Definition: TBasket.cxx:925
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
TBranch * GetBranch() const
Definition: TBasket.h:74
void InitializeCompressedBuffer(Int_t len, TFile *file)
Initialize the compressed buffer; either from the TTree or create a local one.
Definition: TBasket.cxx:407
Bool_t fOwnsCompressedBuffer
! Whether or not we own the compressed buffer.
Definition: TBasket.h:61
Int_t * GetDisplacement() const
Definition: TBasket.h:76
virtual void AdjustSize(Int_t newsize)
Increase the size of the current fBuffer up to newsize.
Definition: TBasket.cxx:144
Int_t GetLast() const
Definition: TBasket.h:81
Int_t ReadBasketBuffersUncompressedCase()
By-passing buffer unzipping has been requested and is possible (only 1 entry in this basket)...
Definition: TBasket.cxx:333
Int_t GetEntryPointer(Int_t Entry)
Get pointer to buffer for internal entry.
Definition: TBasket.cxx:207
Manages buffers for branches of a Tree.
Definition: TBasket.h:38
TBuffer * fCompressedBufferRef
! Compressed buffer.
Definition: TBasket.h:60
Int_t * GetEntryOffset() const
Definition: TBasket.h:77
Int_t fNevBufSize
Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null! ...
Definition: TBasket.h:53
Describe directory structure in memory.
Definition: TDirectory.h:44
virtual ~TBasket()
Basket destructor.
Definition: TBasket.cxx:125
TBasket & operator=(const TBasket &)
TBasket objects are not copiable.
Int_t GetNevBuf() const
Definition: TBasket.h:79
virtual void DeleteEntryOffset()
Delete fEntryOffset array.
Definition: TBasket.cxx:177
virtual Int_t DropBuffers()
Drop buffers of this basket if it is not the current basket.
Definition: TBasket.cxx:187
virtual void PrepareBasket(Long64_t)
Definition: TBasket.h:83
Definition: file.py:1
Int_t fLast
Pointer to last used byte in basket.
Definition: TBasket.h:55
Int_t GetBufferSize() const
Definition: TBasket.h:75
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:98
Long64_t CopyTo(TFile *to)
Copy the basket of this branch onto the file to.
Definition: TBasket.cxx:159
void SetNevBufSize(Int_t n)
Definition: TBasket.h:92
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.
Definition: TBasket.cxx:355
A TTree is a list of TBranches.
Definition: TBranch.h:58
const Int_t n
Definition: legend1.C:16
Default contructor.
Definition: TBasket.cxx:42
virtual void SetWriteMode()
Set write mode of basket.
Definition: TBasket.cxx:760
char name[80]
Definition: TGX11.cxx:109
Int_t LoadBasketBuffers(Long64_t pos, Int_t len, TFile *file, TTree *tree=0)
Load basket buffers in memory without unziping.
Definition: TBasket.cxx:221
virtual void MoveEntries(Int_t dentries)
Remove the first dentries of this basket, moving entries at dentries to the start of the buffer...
Definition: TBasket.cxx:286