forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTBasketSQL.cxx
More file actions
162 lines (134 loc) · 4.77 KB
/
TBasketSQL.cxx
File metadata and controls
162 lines (134 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// @(#)root/tree:$Id$
// Author: Philippe Canal and al. 08/2004
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef TBASKETSQL_CXX
#define TBASKETSQL_CXX
#include "TBasket.h"
#include "TBuffer.h"
#include "TTree.h"
#include "TBranch.h"
#include "TFile.h"
#include "TMath.h"
#include "TBasketSQL.h"
#include <Riostream.h>
#include <vector>
#include "TTreeSQL.h"
#include "TBufferSQL.h"
ClassImp(TBasketSQL);
namespace std {} using namespace std;
/** \class TBasketSQL
\ingroup tree
Implement TBasket for a SQL backend.
*/
////////////////////////////////////////////////////////////////////////////////
/// Default constructor.
TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(0), fRowPtr(0), fInsertQuery(0)
{
}
////////////////////////////////////////////////////////////////////////////////
/// Regular constructor.
TBasketSQL::TBasketSQL(const char *name, const char *title, TBranch *branch,
TSQLResult ** rs, TString *insert_query,
std::vector<Int_t> *vc, TSQLRow **r) :
fResultPtr(rs),fRowPtr(r)
{
SetName(name);
SetTitle(title);
fClassName = "TBasketSQL";
fBufferSize = branch->GetBasketSize();
fNevBufSize = branch->GetEntryOffsetLen();
fNevBuf = 0;
fEntryOffset = 0; //Must be set to 0 before calling Sizeof
fDisplacement= 0; //Must be set to 0 before calling Sizeof
fBuffer = 0; //Must be set to 0 before calling Sizeof
fInsertQuery = insert_query;
if (vc==0) {
fBufferRef = 0;
} else {
fBufferRef = new TBufferSQL(TBuffer::kWrite, fBufferSize, vc, fInsertQuery, fRowPtr);
}
fHeaderOnly = kTRUE;
fLast = 0; // Must initialize before calling Streamer()
//Streamer(*fBufferRef);
fBuffer = 0;
fBranch = branch;
fHeaderOnly = kFALSE;
branch->GetTree()->IncrementTotalBuffers(fBufferSize);
}
////////////////////////////////////////////////////////////////////////////////
/// Destructor
TBasketSQL::~TBasketSQL()
{
}
////////////////////////////////////////////////////////////////////////////////
/// Create a TSQLBuffer for this basket.
void TBasketSQL::CreateBuffer(const char *name, TString title,
std::vector<Int_t> *vc,
TBranch *branch, TSQLResult ** rs)
{
fResultPtr = rs;
SetName(name);
SetTitle(title);
fClassName = "TBasketSQL";
fBufferSize = branch->GetBasketSize();
fNevBufSize = branch->GetEntryOffsetLen();
fNevBuf = 0;
fEntryOffset = 0; //Must be set to 0 before calling Sizeof
fDisplacement= 0; //Must be set to 0 before calling Sizeof
fBuffer = 0; //Must be set to 0 before calling Sizeof
if(vc==0) {
fBufferRef = 0;
Error("CreateBuffer","Need a vector of columns\n");
} else {
fBufferRef = new TBufferSQL(TBuffer::kWrite, fBufferSize, vc, fInsertQuery, fRowPtr);
}
fHeaderOnly = kTRUE;
fLast = 0;
//Streamer(*fBufferRef);
fBuffer = 0;
fBranch = branch;
fHeaderOnly = kFALSE;
branch->GetTree()->IncrementTotalBuffers(fBufferSize);
}
////////////////////////////////////////////////////////////////////////////////
/// Prepare the basket for the next entry.
void TBasketSQL::PrepareBasket(Long64_t entry)
{
((TBufferSQL*)fBufferRef)->ResetOffset();
((TTreeSQL*)fBranch->GetTree())->PrepEntry(entry);
fBufferRef->Reset();
}
////////////////////////////////////////////////////////////////////////////////
/// See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
Int_t TBasketSQL::ReadBasketBytes(Long64_t , TFile *)
{
Error("ReadBasketBytes","This member function should not be called!");
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
Int_t TBasketSQL::ReadBasketBuffers(Long64_t , Int_t, TFile *)
{
Error("ReadBasketBuffers","This member function should not be called!");
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// See TBasket::Reset
void TBasketSQL::Reset()
{
TBasket::Reset();
}
////////////////////////////////////////////////////////////////////////////////
/// See TBasket::Update.
void TBasketSQL::Update(Int_t, Int_t)
{
((TBufferSQL*)fBufferRef)->ResetOffset();
fNevBuf++;
}
#endif