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(nullptr), fRowPtr(nullptr), fInsertQuery(nullptr)
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 = nullptr; //Must be set to 0 before calling Sizeof
53 fDisplacement= nullptr; //Must be set to 0 before calling Sizeof
54 fBuffer = nullptr; //Must be set to 0 before calling Sizeof
55 fInsertQuery = insert_query;
56
57 if (vc==nullptr) {
58 fBufferRef = nullptr;
59 } else {
61 }
62 fHeaderOnly = true;
63 fLast = 0; // Must initialize before calling Streamer()
64 //Streamer(*fBufferRef);
65 fBuffer = nullptr;
66 fBranch = branch;
67 fHeaderOnly = false;
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 = nullptr; //Must be set to 0 before calling Sizeof
94 fDisplacement= nullptr; //Must be set to 0 before calling Sizeof
95 fBuffer = nullptr; //Must be set to 0 before calling Sizeof
96
97 if(vc==nullptr) {
98 fBufferRef = nullptr;
99 Error("CreateBuffer","Need a vector of columns\n");
100 } else {
102 }
103 fHeaderOnly = true;
104 fLast = 0;
105 //Streamer(*fBufferRef);
106 fBuffer = nullptr;
107 fBranch = branch;
108 fHeaderOnly = false;
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
long long Long64_t
Definition RtypesCore.h:80
#define ClassImp(name)
Definition Rtypes.h:377
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
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.
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
virtual Int_t GetBasketSize() const
Definition TBranch.h:217
Int_t GetEntryOffsetLen() const
Definition TBranch.h:227
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: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:987
Basic string class.
Definition TString.h:139
A TTree object is a list of TBranch.
Definition TTreeSQL.h:42
virtual void IncrementTotalBuffers(Int_t nbytes)
Definition TTree.h:546