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 "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
29namespace std {} using namespace std;
30
31/** \class TBasketSQL
32\ingroup tree
33
34Implement TBasket for a SQL backend.
35*/
36
37////////////////////////////////////////////////////////////////////////////////
38/// Default constructor.
39
40TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(0), fRowPtr(0), fInsertQuery(0)
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Regular constructor.
46
47TBasketSQL::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{
53 SetTitle(title);
54 fClassName = "TBasketSQL";
55 fBufferSize = branch->GetBasketSize();
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;
75
76}
77
78////////////////////////////////////////////////////////////////////////////////
79/// Destructor
80
82{
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Create a TSQLBuffer for this basket.
87
88void TBasketSQL::CreateBuffer(const char *name, TString title,
89 std::vector<Int_t> *vc,
90 TBranch *branch, TSQLResult ** rs)
91{
92 fResultPtr = rs;
94 SetTitle(title);
95 fClassName = "TBasketSQL";
96 fBufferSize = branch->GetBasketSize();
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 }
110 fLast = 0;
111 //Streamer(*fBufferRef);
112 fBuffer = 0;
113 fBranch = branch;
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::Update.
148
150{
151 ((TBufferSQL*)fBufferRef)->ResetOffset();
152 fNevBuf++;
153}
154
155#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
Implement TBasket for a SQL backend.
Definition: TBasketSQL.h:31
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
TSQLResult ** fResultPtr
Definition: TBasketSQL.h:38
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
void PrepareBasket(Long64_t entry)
Prepare the basket for the next entry.
Definition: TBasketSQL.cxx:121
TBasketSQL()
Default constructor.
Definition: TBasketSQL.cxx:40
TSQLRow ** fRowPtr
Definition: TBasketSQL.h:39
virtual Int_t ReadBasketBytes(Long64_t pos, TFile *file)
See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
Definition: TBasketSQL.cxx:131
~TBasketSQL()
Destructor.
Definition: TBasketSQL.cxx:81
void Update(Int_t offset, Int_t skipped)
See TBasket::Update.
Definition: TBasketSQL.cxx:149
TString * fInsertQuery
Definition: TBasketSQL.h:40
Manages buffers for branches of a Tree.
Definition: TBasket.h:34
Int_t * fEntryOffset
[fNevBuf] Offset of entries in fBuffer(TKey); generated at runtime.
Definition: TBasket.h:71
TBranch * fBranch
Pointer to the basket support branch.
Definition: TBasket.h:73
Bool_t fHeaderOnly
True when only the basket header must be read/written.
Definition: TBasket.h:66
Int_t fBufferSize
fBuffer length in bytes
Definition: TBasket.h:62
Int_t fNevBufSize
Length in Int_t of fEntryOffset OR fixed length of each entry if fEntryOffset is null!
Definition: TBasket.h:63
Int_t fNevBuf
Number of entries in basket.
Definition: TBasket.h:64
Int_t fLast
Pointer to last used byte in basket.
Definition: TBasket.h:65
Int_t * fDisplacement
![fNevBuf] Displacement of entries in fBuffer(TKey)
Definition: TBasket.h:70
A TTree is a list of TBranches.
Definition: TBranch.h:91
TTree * GetTree() const
Definition: TBranch.h:250
virtual Int_t GetBasketSize() const
Definition: TBranch.h:215
Int_t GetEntryOffsetLen() const
Definition: TBranch.h:225
Implement TBuffer for a SQL backend.
Definition: TBufferSQL.h:27
virtual void Reset()=0
@ kWrite
Definition: TBuffer.h:72
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
TBuffer * fBufferRef
Pointer to the TBuffer object.
Definition: TKey.h:46
char * fBuffer
Object buffer.
Definition: TKey.h:45
TString fClassName
Object Class name.
Definition: TKey.h:43
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Basic string class.
Definition: TString.h:131
Implement TTree for a SQL backend.
Definition: TTreeSQL.h:42
virtual void IncrementTotalBuffers(Int_t nbytes)
Definition: TTree.h:533