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