ROOT  6.06/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 #ifndef ROOT_TKey
30 #include "TKey.h"
31 #endif
32 
33 
34 class TFile;
35 class TTree;
36 class TBranch;
37 
38 class TBasket : public TKey {
39 
40 private:
41  TBasket(const TBasket&); // TBasket objects are not copiable.
42  TBasket& operator=(const TBasket&); // TBasket objects are not copiable.
43 
44  // Internal corner cases for ReadBasketBuffers
47 
48  // Helper for managing the compressed buffer.
49  void InitializeCompressedBuffer(Int_t len, TFile* file);
50 
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
63 
64 public:
65 
66  TBasket();
67  TBasket(TDirectory *motherDir);
68  TBasket(const char *name, const char *title, TBranch *branch);
69  virtual ~TBasket();
70 
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();
87 
88  Int_t LoadBasketBuffers(Long64_t pos, Int_t len, TFile *file, TTree *tree = 0);
89  Long64_t CopyTo(TFile *to);
90 
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();
98 
99  ClassDef(TBasket,2); //the TBranch buffers
100 };
101 
102 #endif
Int_t ReadBasketBytes(Long64_t pos, TFile *file)
Read basket buffers in memory and cleanup.
Definition: TBasket.cxx:645
Bool_t fHeaderOnly
Definition: TBasket.h:56
Int_t fLastWriteBufferSize
Whether or not we own the compressed buffer.
Definition: TBasket.h:62
virtual void SetReadMode()
Set read mode of basket.
Definition: TBasket.cxx:745
void Update(Int_t newlast)
Definition: TBasket.h:95
Int_t * GetEntryOffset() const
Definition: TBasket.h:77
Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
Read basket buffers in memory and cleanup.
Definition: TBasket.cxx:435
long long Long64_t
Definition: RtypesCore.h:69
Int_t * fDisplacement
Definition: TBasket.h:57
Int_t fBufferSize
Definition: TBasket.h:52
Int_t * fEntryOffset
[fNevBuf] Displacement of entries in fBuffer(TKey)
Definition: TBasket.h:58
TBranch * fBranch
Definition: TBasket.h:59
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
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
Definition: TBasket.h:54
void SetBranch(TBranch *branch)
Definition: TBasket.h:91
ClassDef(TBasket, 2)
virtual void Reset()
Reset the basket to the starting state.
Definition: TBasket.cxx:660
virtual Int_t WriteBuffer()
Write buffer of this basket on the current file.
Definition: TBasket.cxx:919
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
Int_t GetNevBuf() const
Definition: TBasket.h:79
void InitializeCompressedBuffer(Int_t len, TFile *file)
Initialize the compressed buffer; either from the TTree or create a local one.
Definition: TBasket.cxx:411
Bool_t fOwnsCompressedBuffer
Compressed buffer.
Definition: TBasket.h:61
Int_t GetBufferSize() const
Definition: TBasket.h:75
Int_t GetLast() const
Definition: TBasket.h:81
virtual void AdjustSize(Int_t newsize)
Increase the size of the current fBuffer up to newsize.
Definition: TBasket.cxx:148
Int_t ReadBasketBuffersUncompressedCase()
By-passing buffer unzipping has been requested and is possible (only 1 entry in this basket)...
Definition: TBasket.cxx:337
Int_t GetEntryPointer(Int_t Entry)
Get pointer to buffer for internal entry.
Definition: TBasket.cxx:211
Manages buffers for branches of a Tree.
Definition: TBasket.h:38
TBuffer * fCompressedBufferRef
Definition: TBasket.h:60
Int_t * GetDisplacement() const
Definition: TBasket.h:76
Int_t fNevBufSize
Definition: TBasket.h:53
Describe directory structure in memory.
Definition: TDirectory.h:41
virtual ~TBasket()
Basket destructor.
Definition: TBasket.cxx:129
#define name(a, b)
Definition: linkTestLib0.cpp:5
TBasket & operator=(const TBasket &)
virtual void DeleteEntryOffset()
Delete fEntryOffset array.
Definition: TBasket.cxx:181
virtual Int_t DropBuffers()
Drop buffers of this basket if it is not the current basket.
Definition: TBasket.cxx:191
virtual void PrepareBasket(Long64_t)
Definition: TBasket.h:83
Int_t GetNevBufSize() const
Definition: TBasket.h:80
Int_t fLast
Definition: TBasket.h:55
A TTree object has a header with a name and a title.
Definition: TTree.h:94
Long64_t CopyTo(TFile *to)
Copy the basket of this branch onto the file to.
Definition: TBasket.cxx:163
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:359
A TTree is a list of TBranches.
Definition: TBranch.h:58
const Int_t n
Definition: legend1.C:16
TBasket()
Size of the buffer last time we wrote it to disk.
virtual void SetWriteMode()
Set write mode of basket.
Definition: TBasket.cxx:754
TBranch * GetBranch() const
Definition: TBasket.h:74
Int_t LoadBasketBuffers(Long64_t pos, Int_t len, TFile *file, TTree *tree=0)
Load basket buffers in memory without unziping.
Definition: TBasket.cxx:225
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:290