ROOT  6.06/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 "TTree.h"
17 #include "TBranch.h"
18 #include "TFile.h"
19 #include "TMath.h"
20 #include "TBasketSQL.h"
21 #include <Riostream.h>
22 #include <vector>
23 #include "TTreeSQL.h"
24 #include "TBufferSQL.h"
25 
27 
28 namespace std {} using namespace std;
29 
30 /** \class TBasketSQL
31 Implement TBasket for a SQL backend.
32 */
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Default constructor.
36 
37 TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(0), fRowPtr(0), fInsertQuery(0)
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Regular constructor.
43 
44 TBasketSQL::TBasketSQL(const char *name, const char *title, TBranch *branch,
45  TSQLResult ** rs, TString *insert_query,
46  std::vector<Int_t> *vc, TSQLRow **r) :
47  fResultPtr(rs),fRowPtr(r)
48 {
49  SetName(name);
50  SetTitle(title);
51  fClassName = "TBasketSQL";
52  fBufferSize = branch->GetBasketSize();
53  fNevBufSize = branch->GetEntryOffsetLen();
54  fNevBuf = 0;
55  fEntryOffset = 0; //Must be set to 0 before calling Sizeof
56  fDisplacement= 0; //Must be set to 0 before calling Sizeof
57  fBuffer = 0; //Must be set to 0 before calling Sizeof
58  fInsertQuery = insert_query;
59 
60  if (vc==0) {
61  fBufferRef = 0;
62  } else {
64  }
66  fLast = 0; // Must initialize before calling Streamer()
67  //Streamer(*fBufferRef);
68  fBuffer = 0;
69  fBranch = branch;
72 
73 }
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Destructor
77 
79 {
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Create a TSQLBuffer for this basket.
84 
85 void TBasketSQL::CreateBuffer(const char *name, TString title,
86  std::vector<Int_t> *vc,
87  TBranch *branch, TSQLResult ** rs)
88 {
89  fResultPtr = rs;
90  SetName(name);
91  SetTitle(title);
92  fClassName = "TBasketSQL";
93  fBufferSize = branch->GetBasketSize();
94  fNevBufSize = branch->GetEntryOffsetLen();
95  fNevBuf = 0;
96  fEntryOffset = 0; //Must be set to 0 before calling Sizeof
97  fDisplacement= 0; //Must be set to 0 before calling Sizeof
98  fBuffer = 0; //Must be set to 0 before calling Sizeof
99 
100  if(vc==0) {
101  fBufferRef = 0;
102  Error("CreateBuffer","Need a vector of columns\n");
103  } else {
105  }
106  fHeaderOnly = kTRUE;
107  fLast = 0;
108  //Streamer(*fBufferRef);
109  fBuffer = 0;
110  fBranch = branch;
113 }
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Prepare the basket for the next entry.
117 
119 {
120  ((TBufferSQL*)fBufferRef)->ResetOffset();
121  ((TTreeSQL*)fBranch->GetTree())->PrepEntry(entry);
122  fBufferRef->Reset();
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
127 
129 {
130  Error("ReadBasketBytes","This member function should not be called!");
131  return 0;
132 }
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 /// See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
136 
138 {
139  Error("ReadBasketBuffers","This member function should not be called!");
140  return 0;
141 }
142 
143 ////////////////////////////////////////////////////////////////////////////////
144 /// See TBasket::Reset
145 
147 {
148  TBasket::Reset();
149 }
150 ////////////////////////////////////////////////////////////////////////////////
151 /// See TBasket::Update.
152 
154 {
155  ((TBufferSQL*)fBufferRef)->ResetOffset();
156  fNevBuf++;
157 }
158 
159 #endif
Bool_t fHeaderOnly
Definition: TBasket.h:56
TBasketSQL()
Default constructor.
Definition: TBasketSQL.cxx:37
long long Long64_t
Definition: RtypesCore.h:69
Int_t * fDisplacement
Definition: TBasket.h:57
virtual void Reset()
See TBasket::Reset.
Definition: TBasketSQL.cxx:146
virtual void IncrementTotalBuffers(Int_t nbytes)
Definition: TTree.h:460
Implement TBuffer for a SQL backend.
Definition: TBufferSQL.h:34
Int_t fBufferSize
Definition: TBasket.h:52
Int_t * fEntryOffset
[fNevBuf] Displacement of entries in fBuffer(TKey)
Definition: TBasket.h:58
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
~TBasketSQL()
Destructor.
Definition: TBasketSQL.cxx:78
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
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
STL namespace.
TSQLRow ** fRowPtr
Definition: TBasketSQL.h:39
Implement TTree for a SQL backend.
Definition: TTreeSQL.h:43
Int_t fNevBuf
Definition: TBasket.h:54
char * fBuffer
Object buffer.
Definition: TKey.h:50
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:85
virtual void Reset()=0
virtual void Reset()
Reset the basket to the starting state.
Definition: TBasket.cxx:660
TString fClassName
Object Class name.
Definition: TKey.h:48
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
void PrepareBasket(Long64_t entry)
Prepare the basket for the next entry.
Definition: TBasketSQL.cxx:118
ROOT::R::TRInterface & r
Definition: Object.C:4
Manages buffers for branches of a Tree.
Definition: TBasket.h:38
void Update(Int_t offset, Int_t skipped)
See TBasket::Update.
Definition: TBasketSQL.cxx:153
Long64_t entry
TTree * GetTree() const
Definition: TBranch.h:183
TBuffer * fBufferRef
Pointer to the TBuffer object.
Definition: TKey.h:51
Int_t fNevBufSize
Definition: TBasket.h:53
virtual Int_t GetBasketSize() const
Definition: TBranch.h:151
Implement TBasket for a SQL backend.
Definition: TBasketSQL.h:30
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual Int_t ReadBasketBytes(Long64_t pos, TFile *file)
See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
Definition: TBasketSQL.cxx:128
ClassImp(TBasketSQL) namespace std
Definition: TBasketSQL.cxx:26
Int_t fLast
Definition: TBasket.h:55
Int_t GetEntryOffsetLen() const
Definition: TBranch.h:160
A TTree is a list of TBranches.
Definition: TBranch.h:58
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
virtual Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file)
See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
Definition: TBasketSQL.cxx:137
TString * fInsertQuery
Definition: TBasketSQL.h:40