Logo ROOT   6.10/09
Reference Guide
TBasketSQL.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Philippe Canal and al. 08/2004
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 TBASKETSQL_CXX
13 #define TBASKETSQL_CXX
14 
15 #include "TBasket.h"
16 #include "TBuffer.h"
17 #include "TTree.h"
18 #include "TBranch.h"
19 #include "TFile.h"
20 #include "TMath.h"
21 #include "TBasketSQL.h"
22 #include <Riostream.h>
23 #include <vector>
24 #include "TTreeSQL.h"
25 #include "TBufferSQL.h"
26 
28 
29 namespace std {} using namespace std;
30 
31 /** \class TBasketSQL
32 \ingroup tree
33 
34 Implement TBasket for a SQL backend.
35 */
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Default constructor.
39 
40 TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(0), fRowPtr(0), fInsertQuery(0)
41 {
42 }
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Regular constructor.
46 
47 TBasketSQL::TBasketSQL(const char *name, const char *title, TBranch *branch,
48  TSQLResult ** rs, TString *insert_query,
49  std::vector<Int_t> *vc, TSQLRow **r) :
50  fResultPtr(rs),fRowPtr(r)
51 {
52  SetName(name);
53  SetTitle(title);
54  fClassName = "TBasketSQL";
55  fBufferSize = branch->GetBasketSize();
56  fNevBufSize = branch->GetEntryOffsetLen();
57  fNevBuf = 0;
58  fEntryOffset = 0; //Must be set to 0 before calling Sizeof
59  fDisplacement= 0; //Must be set to 0 before calling Sizeof
60  fBuffer = 0; //Must be set to 0 before calling Sizeof
61  fInsertQuery = insert_query;
62 
63  if (vc==0) {
64  fBufferRef = 0;
65  } else {
67  }
69  fLast = 0; // Must initialize before calling Streamer()
70  //Streamer(*fBufferRef);
71  fBuffer = 0;
72  fBranch = branch;
74  branch->GetTree()->IncrementTotalBuffers(fBufferSize);
75 
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Destructor
80 
82 {
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 /// Create a TSQLBuffer for this basket.
87 
88 void TBasketSQL::CreateBuffer(const char *name, TString title,
89  std::vector<Int_t> *vc,
90  TBranch *branch, TSQLResult ** rs)
91 {
92  fResultPtr = rs;
93  SetName(name);
94  SetTitle(title);
95  fClassName = "TBasketSQL";
96  fBufferSize = branch->GetBasketSize();
97  fNevBufSize = branch->GetEntryOffsetLen();
98  fNevBuf = 0;
99  fEntryOffset = 0; //Must be set to 0 before calling Sizeof
100  fDisplacement= 0; //Must be set to 0 before calling Sizeof
101  fBuffer = 0; //Must be set to 0 before calling Sizeof
102 
103  if(vc==0) {
104  fBufferRef = 0;
105  Error("CreateBuffer","Need a vector of columns\n");
106  } else {
108  }
109  fHeaderOnly = kTRUE;
110  fLast = 0;
111  //Streamer(*fBufferRef);
112  fBuffer = 0;
113  fBranch = branch;
115  branch->GetTree()->IncrementTotalBuffers(fBufferSize);
116 }
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 /// Prepare the basket for the next entry.
120 
122 {
123  ((TBufferSQL*)fBufferRef)->ResetOffset();
124  ((TTreeSQL*)fBranch->GetTree())->PrepEntry(entry);
125  fBufferRef->Reset();
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
130 
132 {
133  Error("ReadBasketBytes","This member function should not be called!");
134  return 0;
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
139 
141 {
142  Error("ReadBasketBuffers","This member function should not be called!");
143  return 0;
144 }
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 /// See TBasket::Reset
148 
150 {
151  TBasket::Reset();
152 }
153 ////////////////////////////////////////////////////////////////////////////////
154 /// See TBasket::Update.
155 
157 {
158  ((TBufferSQL*)fBufferRef)->ResetOffset();
159  fNevBuf++;
160 }
161 
162 #endif
Bool_t fHeaderOnly
True when only the basket header must be read/written.
Definition: TBasket.h:54
TBasketSQL()
Default constructor.
Definition: TBasketSQL.cxx:40
long long Long64_t
Definition: RtypesCore.h:69
virtual Int_t GetBasketSize() const
Definition: TBranch.h:156
Int_t * fDisplacement
![fNevBuf] Displacement of entries in fBuffer(TKey)
Definition: TBasket.h:55
virtual void Reset()
See TBasket::Reset.
Definition: TBasketSQL.cxx:149
Implement TBuffer for a SQL backend.
Definition: TBufferSQL.h:30
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
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
~TBasketSQL()
Destructor.
Definition: TBasketSQL.cxx:81
TBranch * fBranch
Pointer to the basket support branch.
Definition: TBasket.h:57
int Int_t
Definition: RtypesCore.h:41
STL namespace.
TSQLRow ** fRowPtr
Definition: TBasketSQL.h:39
Implement TTree for a SQL backend.
Definition: TTreeSQL.h:41
Int_t fNevBuf
Number of entries in basket.
Definition: TBasket.h:52
char * fBuffer
Object buffer.
Definition: TKey.h:44
Int_t GetEntryOffsetLen() const
Definition: TBranch.h:165
TSQLResult ** fResultPtr
Definition: TBasketSQL.h:38
void CreateBuffer(const char *name, TString title, std::vector< Int_t > *vc, TBranch *branch, TSQLResult **rs)
Create a TSQLBuffer for this basket.
Definition: TBasketSQL.cxx:88
virtual void Reset()=0
virtual void Reset()
Reset the basket to the starting state.
Definition: TBasket.cxx:666
TString fClassName
Object Class name.
Definition: TKey.h:42
void PrepareBasket(Long64_t entry)
Prepare the basket for the next entry.
Definition: TBasketSQL.cxx:121
TRandom2 r(17)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
Manages buffers for branches of a Tree.
Definition: TBasket.h:36
void Update(Int_t offset, Int_t skipped)
See TBasket::Update.
Definition: TBasketSQL.cxx:156
TBuffer * fBufferRef
Pointer to the TBuffer object.
Definition: TKey.h:45
Int_t fNevBufSize
Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null! ...
Definition: TBasket.h:51
const Bool_t kFALSE
Definition: RtypesCore.h:92
Implement TBasket for a SQL backend.
Definition: TBasketSQL.h:30
#define ClassImp(name)
Definition: Rtypes.h:336
virtual Int_t ReadBasketBytes(Long64_t pos, TFile *file)
See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
Definition: TBasketSQL.cxx:131
Int_t fLast
Pointer to last used byte in basket.
Definition: TBasket.h:53
TTree * GetTree() const
Definition: TBranch.h:188
A TTree is a list of TBranches.
Definition: TBranch.h:57
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
Definition: TBasketSQL.cxx:140
TString * fInsertQuery
Definition: TBasketSQL.h:40