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
29/** \class TBasketSQL
30\ingroup tree
31
32Implement TBasket for a SQL backend.
33*/
34
35////////////////////////////////////////////////////////////////////////////////
36/// Default constructor.
37
38TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(0), fRowPtr(0), fInsertQuery(0)
39{
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Regular constructor.
44
45TBasketSQL::TBasketSQL(const char *name, const char *title, TBranch *branch,
46 TSQLResult ** rs, TString *insert_query,
47 std::vector<Int_t> *vc, TSQLRow **r) :
48 fResultPtr(rs),fRowPtr(r)
49{
51 SetTitle(title);
52 fClassName = "TBasketSQL";
53 fBufferSize = branch->GetBasketSize();
55 fNevBuf = 0;
56 fEntryOffset = 0; //Must be set to 0 before calling Sizeof
57 fDisplacement= 0; //Must be set to 0 before calling Sizeof
58 fBuffer = 0; //Must be set to 0 before calling Sizeof
59 fInsertQuery = insert_query;
60
61 if (vc==0) {
62 fBufferRef = 0;
63 } else {
65 }
67 fLast = 0; // Must initialize before calling Streamer()
68 //Streamer(*fBufferRef);
69 fBuffer = 0;
70 fBranch = branch;
73
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Destructor
78
80{
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Create a TSQLBuffer for this basket.
85
86void TBasketSQL::CreateBuffer(const char *name, TString title,
87 std::vector<Int_t> *vc,
88 TBranch *branch, TSQLResult ** rs)
89{
90 fResultPtr = rs;
92 SetTitle(title);
93 fClassName = "TBasketSQL";
94 fBufferSize = branch->GetBasketSize();
96 fNevBuf = 0;
97 fEntryOffset = 0; //Must be set to 0 before calling Sizeof
98 fDisplacement= 0; //Must be set to 0 before calling Sizeof
99 fBuffer = 0; //Must be set to 0 before calling Sizeof
100
101 if(vc==0) {
102 fBufferRef = 0;
103 Error("CreateBuffer","Need a vector of columns\n");
104 } else {
106 }
108 fLast = 0;
109 //Streamer(*fBufferRef);
110 fBuffer = 0;
111 fBranch = branch;
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Prepare the basket for the next entry.
118
120{
121 ((TBufferSQL*)fBufferRef)->ResetOffset();
122 ((TTreeSQL*)fBranch->GetTree())->PrepEntry(entry);
123 fBufferRef->Reset();
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
128
130{
131 Error("ReadBasketBytes","This member function should not be called!");
132 return 0;
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
137
139{
140 Error("ReadBasketBuffers","This member function should not be called!");
141 return 0;
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// See TBasket::Update.
146
148{
149 ((TBufferSQL*)fBufferRef)->ResetOffset();
150 fNevBuf++;
151}
152
153#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
const Bool_t kFALSE
Definition: RtypesCore.h:90
long long Long64_t
Definition: RtypesCore.h:71
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
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:86
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:138
void PrepareBasket(Long64_t entry)
Prepare the basket for the next entry.
Definition: TBasketSQL.cxx:119
TBasketSQL()
Default constructor.
Definition: TBasketSQL.cxx:38
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:129
~TBasketSQL()
Destructor.
Definition: TBasketSQL.cxx:79
void Update(Int_t offset, Int_t skipped)
See TBasket::Update.
Definition: TBasketSQL.cxx:147
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:53
TBuffer * fBufferRef
Pointer to the TBuffer object.
Definition: TKey.h:50
char * fBuffer
Object buffer.
Definition: TKey.h:49
TString fClassName
Object Class name.
Definition: TKey.h:47
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:891
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:540