Logo ROOT   6.10/09
Reference Guide
TBasket.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 19/01/96
3 
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  *************************************************************************/
11 
12 #ifndef ROOT_TBasket
13 #define ROOT_TBasket
14 
15 
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 //////////////////////////////////////////////////////////////////////////
27 
28 
29 #include "TKey.h"
30 
31 
32 class TFile;
33 class TTree;
34 class TBranch;
35 
36 class TBasket : public TKey {
37 
38 private:
39  TBasket(const TBasket&); ///< TBasket objects are not copiable.
40  TBasket& operator=(const TBasket&); ///< TBasket objects are not copiable.
41 
42  // Internal corner cases for ReadBasketBuffers
45 
46  // Helper for managing the compressed buffer.
48 
49 protected:
50  Int_t fBufferSize; ///< fBuffer length in bytes
51  Int_t fNevBufSize; ///< Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null!
52  Int_t fNevBuf; ///< Number of entries in basket
53  Int_t fLast; ///< Pointer to last used byte in basket
54  Bool_t fHeaderOnly; ///< True when only the basket header must be read/written
55  Int_t *fDisplacement; ///<![fNevBuf] Displacement of entries in fBuffer(TKey)
56  Int_t *fEntryOffset; ///<[fNevBuf] Offset of entries in fBuffer(TKey)
57  TBranch *fBranch; ///<Pointer to the basket support branch
58  TBuffer *fCompressedBufferRef; ///<! Compressed buffer.
59  Bool_t fOwnsCompressedBuffer; ///<! Whether or not we own the compressed buffer.
60  Int_t fLastWriteBufferSize; ///<! Size of the buffer last time we wrote it to disk
61 
62 public:
63 
64  TBasket();
65  TBasket(TDirectory *motherDir);
66  TBasket(const char *name, const char *title, TBranch *branch);
67  virtual ~TBasket();
68 
69  virtual void AdjustSize(Int_t newsize);
70  virtual void DeleteEntryOffset();
71  virtual Int_t DropBuffers();
72  TBranch *GetBranch() const {return fBranch;}
73  Int_t GetBufferSize() const {return fBufferSize;}
74  Int_t *GetDisplacement() const {return fDisplacement;}
75  Int_t *GetEntryOffset() const {return fEntryOffset;}
77  Int_t GetNevBuf() const {return fNevBuf;}
78  Int_t GetNevBufSize() const {return fNevBufSize;}
79  Int_t GetLast() const {return fLast;}
80  virtual void MoveEntries(Int_t dentries);
81  virtual void PrepareBasket(Long64_t /* entry */) {};
82  Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file);
83  Int_t ReadBasketBytes(Long64_t pos, TFile *file);
84  virtual void Reset();
85 
86  Int_t LoadBasketBuffers(Long64_t pos, Int_t len, TFile *file, TTree *tree = 0);
87  Long64_t CopyTo(TFile *to);
88 
89  void SetBranch(TBranch *branch) { fBranch = branch; }
90  void SetNevBufSize(Int_t n) { fNevBufSize=n; }
91  virtual void SetReadMode();
92  virtual void SetWriteMode();
93  inline void Update(Int_t newlast) { Update(newlast,newlast); };
94  virtual void Update(Int_t newlast, Int_t skipped);
95  virtual Int_t WriteBuffer();
96 
97  ClassDef(TBasket,2); //the TBranch buffers
98 };
99 
100 #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:54
Int_t fLastWriteBufferSize
! Size of the buffer last time we wrote it to disk
Definition: TBasket.h:60
virtual void SetReadMode()
Set read mode of basket.
Definition: TBasket.cxx:751
void Update(Int_t newlast)
Definition: TBasket.h:93
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:55
Int_t GetNevBufSize() const
Definition: TBasket.h:78
Int_t fBufferSize
fBuffer length in bytes
Definition: TBasket.h:50
Int_t * fEntryOffset
[fNevBuf] Offset of entries in fBuffer(TKey)
Definition: TBasket.h:56
TBranch * fBranch
Pointer to the basket support branch.
Definition: TBasket.h:57
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
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:52
void SetBranch(TBranch *branch)
Definition: TBasket.h:89
#define ClassDef(name, id)
Definition: Rtypes.h:297
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:24
TBranch * GetBranch() const
Definition: TBasket.h:72
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:59
Int_t * GetDisplacement() const
Definition: TBasket.h:74
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:79
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:36
TBuffer * fCompressedBufferRef
! Compressed buffer.
Definition: TBasket.h:58
Int_t * GetEntryOffset() const
Definition: TBasket.h:75
Int_t fNevBufSize
Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null! ...
Definition: TBasket.h:51
Describe directory structure in memory.
Definition: TDirectory.h:34
virtual ~TBasket()
Basket destructor.
Definition: TBasket.cxx:125
TBasket & operator=(const TBasket &)
TBasket objects are not copiable.
Int_t GetNevBuf() const
Definition: TBasket.h:77
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:81
Definition: file.py:1
Int_t fLast
Pointer to last used byte in basket.
Definition: TBasket.h:53
Int_t GetBufferSize() const
Definition: TBasket.h:73
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:78
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:90
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:57
const Int_t n
Definition: legend1.C:16
TBasket()
Default contructor.
Definition: TBasket.cxx:42
virtual void SetWriteMode()
Set write mode of basket.
Definition: TBasket.cxx:760
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