52 TTree(table.Data(),
"Database read from table: " + table, 0),
fDB(DB),
64 Error(
"TTreeSQL",
"No TSQLServer specified");
79 Fatal(
"BranchImp",
"Not implemented yet");
89 Fatal(
"BranchImp",
"Not implemented yet");
98 Fatal(
"Branch",
"Not implemented yet");
107 Fatal(
"Branch",
"Not implemented yet");
117 Fatal(
"Branch",
"Not implemented yet");
127 Fatal(
"Bronch",
"Not implemented yet");
137 Fatal(
"BranchOld",
"Not implemented yet");
147 Fatal(
"Branch",
"Not implemented yet");
155 const char *leaflist,
Int_t bufsize)
161 for (
int i=0;i<nb;i++) {
170 Fatal(
"Branch()",
"Duplicate branch!!!");
190 if (basket==
nullptr) {
192 if (basket==
nullptr)
return;
198 if(buffer ==
nullptr){
204 for (
int i=0;i<nb;i++) {
225 if (!tb)
return false;
228 if (!basket)
return false;
232 Error(
"CheckBranch",
"%s has basket but no resultset yet",tb->
GetName());
238 for(
int j=0;j<nl;j++) {
264 if (
fServer==
nullptr)
return false;
266 if (!tables)
return false;
268 while( (row = tables->
Next()) ) {
293 if(typeName ==
"Char_t"){
296 else if(typeName ==
"Int_t") {
299 else if(typeName ==
"Short_t") {
302 else if( typeName ==
"UShort_t") {
303 tn =
"SMALLINT UNSIGNED";
305 else if(typeName ==
"Float_t"){
308 else if(typeName ==
"Float16_t"){
311 else if(typeName ==
"Double_t"){
314 else if(typeName ==
"Double32_t"){
317 else if(typeName ==
"UInt_t") {
320 else if( typeName ==
"Long_t") {
323 else if( typeName ==
"ULong_t") {
324 tn =
"INTEGER UNSIGNED";
326 else if( typeName ==
"Long64_t") {
329 else if( typeName ==
"ULong64_t") {
330 tn =
"BIGINT UNSIGNED";
332 else if( typeName ==
"Bool_t") {
335 else if( typeName ==
"TString") {
340 Error(
"ConvertTypeName",
"TypeName (%s) not found",typeName.
Data());
353 Error(
"CreateBasket",
"No TSQLServer specified");
371 Error(
"CreateBranch",
"No TSQLServer specified");
376 alterSQL =
"ALTER TABLE ";
377 alterSQL +=
fTable.Data();
379 alterSQL += branchName.
Data();
381 alterSQL += typeName;
410 leafName = branchName(pos+2,branchName.
Length());
413 leafName = branchName;
469 Error(
"CreateBranches",
"Skipped %s", branchName.
Data());
490 Error(
"CreateTable",
"No TSQLServer specified");
494 TString branchName, leafName, typeName;
495 TString createSQL, alterSQL, str;
504 branchName = branch->
GetName();
512 if(i == 0 && j == 0) {
514 createSQL +=
"CREATE TABLE ";
517 createSQL += branchName;
519 createSQL += leafName;
521 createSQL += typeName;
527 Error(
"CreateTable",
"May have failed");
575 if (
fServer==
nullptr)
return 0;
585 for (
int i=0;i<nb;i++) {
591 for(
int i=0;i<nb;i++) {
594 Error(
"Fill",
"CheckBranch for %s failed",branch->
GetName());
625 std::vector<Int_t> *columns =
new std::vector<Int_t>;
629 std::vector<TString> names;
632 if (col_list==
nullptr) {
637 std::pair<TString,Int_t> value;
639 TIter next(col_list);
643 names.push_back( cinfo->
GetName() );
647 for(
int j=0;j<nl;j++) {
658 for (
Int_t i=0;i<rows;++i) {
666 for (
Int_t i=0;i<rows;++i) {
674 columns->push_back(col);
675 }
else Error(
"GetColumnIndice",
"Error finding column %d %s",j,str.Data());
677 if (columns->empty()) {
700 if (count==
nullptr) {
705 TString val = row->GetField(0);
707 sscanf(val.
Data(),
"%ld",&(
ret) );
764 if (
fRow==
nullptr && !reset) {
771 if (
fRow==
nullptr)
return -1;
int Int_t
Signed integer 4 bytes (int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
externInt_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
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
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
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.
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.
TTree()
Default constructor and I/O constructor.
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