Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
28Implement TBasket for a SQL backend.
29*/
30
31////////////////////////////////////////////////////////////////////////////////
32/// Default constructor.
33
34TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(0), fRowPtr(0), fInsertQuery(0)
35{
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Regular constructor.
40
41TBasketSQL::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{
47 SetTitle(title);
48 fClassName = "TBasketSQL";
49 fBufferSize = branch->GetBasketSize();
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
82void TBasketSQL::CreateBuffer(const char *name, TString title,
83 std::vector<Int_t> *vc,
84 TBranch *branch, TSQLResult ** rs)
85{
86 fResultPtr = rs;
88 SetTitle(title);
89 fClassName = "TBasketSQL";
90 fBufferSize = branch->GetBasketSize();
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 }
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::Update.
142
144{
145 ((TBufferSQL*)fBufferRef)->ResetOffset();
146 fNevBuf++;
147}
148
149#endif
ROOT::R::TRInterface & r
Definition Object.C:4
const Bool_t kFALSE
Definition RtypesCore.h:92
long long Long64_t
Definition RtypesCore.h:73
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
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.
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.
void PrepareBasket(Long64_t entry)
Prepare the basket for the next entry.
TBasketSQL()
Default constructor.
TSQLRow ** fRowPtr
Definition TBasketSQL.h:39
virtual Int_t ReadBasketBytes(Long64_t pos, TFile *file)
See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
~TBasketSQL()
Destructor.
void Update(Int_t offset, Int_t skipped)
See TBasket::Update.
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:89
TTree * GetTree() const
Definition TBranch.h:248
virtual Int_t GetBasketSize() const
Definition TBranch.h:213
Int_t GetEntryOffsetLen() const
Definition TBranch.h:223
Implement TBuffer for a SQL backend.
Definition TBufferSQL.h:30
virtual void Reset()=0
@ kWrite
Definition TBuffer.h:73
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
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:893
Basic string class.
Definition TString.h:136
A TTree object is a list of TBranch.
Definition TTreeSQL.h:42
virtual void IncrementTotalBuffers(Int_t nbytes)
Definition TTree.h:543