53 TTree(table.Data(),
"Database read from table: " + table, 0), fDB(DB),
55 fResult(nullptr), fRow(nullptr),
57 fBranchChecked(false),
65 Error(
"TTreeSQL",
"No TSQLServer specified");
80 Fatal(
"BranchImp",
"Not implemented yet");
90 Fatal(
"BranchImp",
"Not implemented yet");
99 Fatal(
"Branch",
"Not implemented yet");
108 Fatal(
"Branch",
"Not implemented yet");
118 Fatal(
"Branch",
"Not implemented yet");
128 Fatal(
"Bronch",
"Not implemented yet");
138 Fatal(
"BranchOld",
"Not implemented yet");
148 Fatal(
"Branch",
"Not implemented yet");
156 const char *leaflist,
Int_t bufsize)
162 for (
int i=0;i<nb;i++) {
171 Fatal(
"Branch()",
"Duplicate branch!!!");
191 if (basket==
nullptr) {
193 if (basket==
nullptr)
return;
199 if(buffer ==
nullptr){
205 for (
int i=0;i<nb;i++) {
226 if (!tb)
return false;
229 if (!basket)
return false;
233 Error(
"CheckBranch",
"%s has basket but no resultset yet",tb->
GetName());
239 for(
int j=0;j<nl;j++) {
265 if (
fServer==
nullptr)
return false;
267 if (!tables)
return false;
269 while( (row = tables->
Next()) ) {
294 if(typeName ==
"Char_t"){
297 else if(typeName ==
"Int_t") {
300 else if(typeName ==
"Short_t") {
303 else if( typeName ==
"UShort_t") {
304 tn =
"SMALLINT UNSIGNED";
306 else if(typeName ==
"Float_t"){
309 else if(typeName ==
"Float16_t"){
312 else if(typeName ==
"Double_t"){
315 else if(typeName ==
"Double32_t"){
318 else if(typeName ==
"UInt_t") {
321 else if( typeName ==
"Long_t") {
324 else if( typeName ==
"ULong_t") {
325 tn =
"INTEGER UNSIGNED";
327 else if( typeName ==
"Long64_t") {
330 else if( typeName ==
"ULong64_t") {
331 tn =
"BIGINT UNSIGNED";
333 else if( typeName ==
"Bool_t") {
336 else if( typeName ==
"TString") {
341 Error(
"ConvertTypeName",
"TypeName (%s) not found",typeName.
Data());
354 Error(
"CreateBasket",
"No TSQLServer specified");
372 Error(
"CreateBranch",
"No TSQLServer specified");
377 alterSQL =
"ALTER TABLE ";
380 alterSQL += branchName.
Data();
382 alterSQL += typeName;
411 leafName = branchName(pos+2,branchName.
Length());
414 leafName = branchName;
470 Error(
"CreateBranches",
"Skipped %s", branchName.
Data());
491 Error(
"CreateTable",
"No TSQLServer specified");
495 TString branchName, leafName, typeName;
496 TString createSQL, alterSQL, str;
505 branchName = branch->
GetName();
513 if(i == 0 && j == 0) {
515 createSQL +=
"CREATE TABLE ";
518 createSQL += branchName;
520 createSQL += leafName;
522 createSQL += typeName;
528 Error(
"CreateTable",
"May have failed");
576 if (
fServer==
nullptr)
return 0;
586 for (
int i=0;i<nb;i++) {
592 for(
int i=0;i<nb;i++) {
595 Error(
"Fill",
"CheckBranch for %s failed",branch->
GetName());
626 std::vector<Int_t> *columns =
new std::vector<Int_t>;
630 std::vector<TString> names;
633 if (col_list==
nullptr) {
638 std::pair<TString,Int_t>
value;
640 TIter next(col_list);
644 names.push_back( cinfo->
GetName() );
648 for(
int j=0;j<nl;j++) {
659 for (
Int_t i=0;i<rows;++i) {
667 for (
Int_t i=0;i<rows;++i) {
675 columns->push_back(col);
676 }
else Error(
"GetColumnIndice",
"Error finding column %d %s",j,str.
Data());
678 if (columns->empty()) {
701 if (count==
nullptr) {
708 sscanf(val.
Data(),
"%ld",&(ret) );
765 if (
fRow==
nullptr && !reset) {
772 if (
fRow==
nullptr)
return -1;
Int_t gErrorIgnoreLevel
Error handling routines.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Implement TBasket for a SQL backend.
TSQLResult * GetResultSet()
void CreateBuffer(const char *name, TString title, std::vector< Int_t > *vc, TBranch *branch, TSQLResult **rs)
Create a TSQLBuffer for this basket.
Manages buffers for branches of a Tree.
A TTree is a list of TBranches.
virtual void ResetAddress()
Reset the address of the branch.
TObjArray * GetListOfBranches()
TBasket * GetBasket(Int_t basket)
TObjArray * GetListOfBaskets()
TObjArray * GetListOfLeaves()
virtual void SetEntries(Long64_t entries)
Set the number of entries in this branch.
Long64_t * GetBasketEntry() const
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Collection abstract base class.
TBuffer * GetBufferRef() const
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual const char * GetTypeName() const
const char * GetName() const override
Returns name of object.
Int_t GetEntriesFast() const
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
TObject * UncheckedAt(Int_t i) const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
const char * GetTypeName() const
virtual const char * GetFieldName(Int_t field)=0
virtual Int_t GetRowCount() const
virtual TSQLRow * Next()=0
virtual Int_t GetFieldCount()=0
virtual const char * GetField(Int_t field)=0
virtual Int_t SelectDataBase(const char *dbname)=0
virtual TSQLTableInfo * GetTableInfo(const char *tablename)
Produce TSQLTableInfo object, which contain info about table itself and each table column Object must...
virtual TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=nullptr)=0
virtual TSQLResult * Query(const char *sql)=0
virtual TSQLResult * GetTables(const char *dbname, const char *wild=nullptr)=0
TList * GetColumns() const
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & Remove(Ssiz_t pos)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
A TTree object is a list of TBranch.
TBasket * CreateBasket(TBranch *br) override
Create a TBasketSQL.
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
TBranch * BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override
Not implemented yet.
bool CheckTable(const TString &table) const
Check the table exist in the database.
TBranch * BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1) override
Not implemented yet.
void CreateBranches()
determine leaf description string
TSQLTableInfo * fTableInfo
void Init()
Initialization routine.
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
Load the data for the entry from the database.
std::vector< Int_t > * GetColumnIndice(TBranch *branch)
Return a vector of columns index corresponding to the current SQL table and the branch given as argum...
Long64_t LoadTree(Long64_t entry) override
Setup the tree to the load the specified entry.
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
bool CreateTable(const TString &table)
Create the database table corresponding to this TTree.
Int_t Fill() override
Copy the information from the user object to the TTree.
TBranch * Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override
Not implemented yet.
virtual void CreateBranch(const TString &branchName, const TString &typeName)
Create the column(s) in the database that correspond to the branch/.
void ResetQuery()
Reset the internal query.
Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="") override
Not implemented yet.
bool CheckBranch(TBranch *tb)
Check if the table has a column corresponding the branch and that the resultset are properly setup.
Long64_t GetEntries() const override
Get the number of rows in the database.
TTreeSQL(TSQLServer *server, TString DB, const TString &table)
Constructor with an explicit TSQLServer.
Long64_t GetEntriesFast() const override
Return the number of entries as of the last check.
void Refresh() override
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
TObjArray fBranches
List of Branches.
Long64_t fEntries
Number of entries.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
Long64_t fReadEntry
! Number of the entry being processed