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
23
24/** \class TBasketSQL
25\ingroup tree
26
27Implement TBasket for a SQL backend.
28*/
29
30////////////////////////////////////////////////////////////////////////////////
31/// Default constructor.
32
33TBasketSQL::TBasketSQL() : TBasket(), fResultPtr(nullptr), fRowPtr(nullptr), fInsertQuery(nullptr)
34{
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Regular constructor.
39
40TBasketSQL::TBasketSQL(const char *name, const char *title, TBranch *branch,
42 std::vector<Int_t> *vc, TSQLRow **r) :
43 fResultPtr(rs),fRowPtr(r)
44{
46 SetTitle(title);
47 fClassName = "TBasketSQL";
48 fBufferSize = branch->GetBasketSize();
49 fNevBufSize = branch->GetEntryOffsetLen();
50 fNevBuf = 0;
51 fEntryOffset = nullptr; //Must be set to 0 before calling Sizeof
52 fDisplacement= nullptr; //Must be set to 0 before calling Sizeof
53 fBuffer = nullptr; //Must be set to 0 before calling Sizeof
55
56 if (vc==nullptr) {
57 fBufferRef = nullptr;
58 } else {
60 }
61 fHeaderOnly = true;
62 fLast = 0; // Must initialize before calling Streamer()
63 //Streamer(*fBufferRef);
64 fBuffer = nullptr;
66 fHeaderOnly = false;
67 branch->GetTree()->IncrementTotalBuffers(fBufferSize);
68
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Destructor
73
77
78////////////////////////////////////////////////////////////////////////////////
79/// Create a TSQLBuffer for this basket.
80
81void TBasketSQL::CreateBuffer(const char *name, TString title,
82 std::vector<Int_t> *vc,
84{
85 fResultPtr = rs;
87 SetTitle(title);
88 fClassName = "TBasketSQL";
89 fBufferSize = branch->GetBasketSize();
90 fNevBufSize = branch->GetEntryOffsetLen();
91 fNevBuf = 0;
92 fEntryOffset = nullptr; //Must be set to 0 before calling Sizeof
93 fDisplacement= nullptr; //Must be set to 0 before calling Sizeof
94 fBuffer = nullptr; //Must be set to 0 before calling Sizeof
95
96 if(vc==nullptr) {
97 fBufferRef = nullptr;
98 Error("CreateBuffer","Need a vector of columns\n");
99 } else {
101 }
102 fHeaderOnly = true;
103 fLast = 0;
104 //Streamer(*fBufferRef);
105 fBuffer = nullptr;
106 fBranch = branch;
107 fHeaderOnly = false;
108 branch->GetTree()->IncrementTotalBuffers(fBufferSize);
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Prepare the basket for the next entry.
113
115{
116 ((TBufferSQL*)fBufferRef)->ResetOffset();
117 ((TTreeSQL*)fBranch->GetTree())->PrepEntry(entry);
118 fBufferRef->Reset();
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
123
125{
126 Error("ReadBasketBytes","This member function should not be called!");
127 return 0;
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// See TBasket::ReadBasketBuffers. This is not implemented in TBasketSQL.
132
134{
135 Error("ReadBasketBuffers","This member function should not be called!");
136 return 0;
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// See TBasket::Update.
141
143{
144 ((TBufferSQL*)fBufferRef)->ResetOffset();
145 fNevBuf++;
146}
147
148#endif
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
char name[80]
Definition TGX11.cxx:110
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.
TBasketSQL()
Default constructor.
TSQLRow ** fRowPtr
Definition TBasketSQL.h:39
~TBasketSQL() override
Destructor.
virtual Int_t ReadBasketBytes(Long64_t pos, TFile *file)
See TBasket::ReadBasketBytes. This is not implemented in TBasketSQL.
void PrepareBasket(Long64_t entry) override
Prepare the basket for the next entry.
void Update(Int_t offset, Int_t skipped) override
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
bool fHeaderOnly
True when only the basket header must be read/written.
Definition TBasket.h:66
TBranch * fBranch
Pointer to the basket support branch.
Definition TBasket.h:73
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:93
TTree * GetTree() const
Definition TBranch.h:252
Implement TBuffer for a SQL backend.
Definition TBufferSQL.h:30
virtual void Reset()=0
@ kWrite
Definition TBuffer.h:73
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
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:173
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Basic string class.
Definition TString.h:138
A TTree object is a list of TBranch.
Definition TTreeSQL.h:42