47 TTree(table.Data(),
"Database read from table: " + table, 0), fDB(DB),
59 Error(
"TTreeSQL",
"No TSQLServer specified");
74 Fatal(
"BranchImp",
"Not implemented yet");
84 Fatal(
"BranchImp",
"Not implemented yet");
93 Fatal(
"Branch",
"Not implemented yet");
102 Fatal(
"Branch",
"Not implemented yet");
112 Fatal(
"Branch",
"Not implemented yet");
122 Fatal(
"Bronch",
"Not implemented yet");
132 Fatal(
"BranchOld",
"Not implemented yet");
142 Fatal(
"Branch",
"Not implemented yet");
150 const char *leaflist,
Int_t bufsize)
156 for (
int i=0;i<nb;i++) {
165 Fatal(
"Branch()",
"Duplicate branch!!!");
187 if (basket==0)
return;
199 for (
int i=0;i<nb;i++) {
223 if (!basket)
return kFALSE;
227 Error(
"CheckBranch",
"%s has basket but no resultset yet",tb->
GetName());
233 for(
int j=0;j<nl;j++) {
261 if (!tables)
return kFALSE;
263 while( (row = tables->
Next()) ) {
288 if(typeName ==
"Char_t"){
291 else if(typeName ==
"Int_t") {
294 else if(typeName ==
"Short_t") {
297 else if( typeName ==
"UShort_t") {
298 tn =
"SMALLINT UNSIGNED";
300 else if(typeName ==
"Float_t"){
303 else if(typeName ==
"Float16_t"){
306 else if(typeName ==
"Double_t"){
309 else if(typeName ==
"Double32_t"){
312 else if(typeName ==
"UInt_t") {
315 else if( typeName ==
"Long_t") {
318 else if( typeName ==
"ULong_t") {
319 tn =
"INTEGER UNSIGNED";
321 else if( typeName ==
"Long64_t") {
324 else if( typeName ==
"ULong64_t") {
325 tn =
"BIGINT UNSIGNED";
327 else if( typeName ==
"Bool_t") {
330 else if( typeName ==
"TString") {
335 Error(
"ConvertTypeName",
"TypeName (%s) not found",typeName.
Data());
348 Error(
"CreateBasket",
"No TSQLServer specified");
366 Error(
"CreateBranch",
"No TSQLServer specified");
371 alterSQL =
"ALTER TABLE ";
374 alterSQL += branchName.
Data();;
376 alterSQL += typeName;
405 leafName = branchName(pos+2,branchName.
Length());
408 leafName = branchName;
464 Error(
"CreateBranches",
"Skipped %s", branchName.
Data());
485 Error(
"CreateTable",
"No TSQLServer specified");
489 TString branchName, leafName, typeName;
490 TString createSQL, alterSQL, str;
499 branchName = branch->
GetName();
507 if(i == 0 && j == 0) {
509 createSQL +=
"CREATE TABLE ";
512 createSQL += branchName;
514 createSQL += leafName;
516 createSQL += typeName;
522 Error(
"CreateTable",
"May have failed");
580 for (
int i=0;i<nb;i++) {
586 for(
int i=0;i<nb;i++) {
589 Error(
"Fill",
"CheckBranch for %s failed",branch->
GetName());
620 std::vector<Int_t> *columns =
new std::vector<Int_t>;
624 std::vector<TString> names;
632 std::pair<TString,Int_t> value;
634 TIter next(col_list);
638 names.push_back( cinfo->
GetName() );
642 for(
int j=0;j<nl;j++) {
653 for (
Int_t i=0;i<rows;++i) {
661 for (
Int_t i=0;i<rows;++i) {
669 columns->push_back(col);
670 }
else Error(
"GetColumnIndice",
"Error finding column %d %s",j,str.
Data());
672 if (columns->empty()) {
702 sscanf(val.
Data(),
"%ld",&(ret) );
759 if (
fRow==0 && !reset) {
766 if (
fRow==0)
return -1;
R__EXTERN Int_t gErrorIgnoreLevel
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
virtual const char * GetName() const
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)
Producec TSQLTableInfo object, which contain info about table itself and each table column Object mus...
virtual TSQLResult * Query(const char *sql)=0
virtual TSQLResult * GetTables(const char *dbname, const char *wild=0)=0
virtual TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=0)=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
Implement TTree for a SQL backend.
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
virtual Long64_t GetEntries() const
Get the number of rows in the database.
virtual Long64_t GetEntriesFast() const
Return the number of entries as of the last check.
Bool_t CheckTable(const TString &table) const
Check the table exist in the database.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Load the data for the entry from the database.
void CreateBranches()
determine leaf description string
virtual Int_t Fill()
Copy the information from the user object to the TTree.
TSQLTableInfo * fTableInfo
void Init()
Initializeation routine.
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...
Bool_t CheckBranch(TBranch *tb)
Check if the table has a column corresponding the branch and that the resultset are properly setup.
virtual TBranch * Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
Not implemented yet.
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
virtual Long64_t LoadTree(Long64_t entry)
Setup the tree to the load the specified entry.
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Not implemented yet.
virtual TBranch * BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1)
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 Refresh()
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
void ResetQuery()
Reset the internal query.
TTreeSQL(TSQLServer *server, TString DB, const TString &table)
Constructor with an explicit TSQLServer.
virtual TBasket * CreateBasket(TBranch *br)
Create a TBasketSQL.
Bool_t CreateTable(const TString &table)
Create the database table corresponding to this TTree.
virtual TBranch * BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel)
Not implemented yet.
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
TObjArray fBranches
List of Branches.
Long64_t fEntries
Number of entries.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Long64_t fReadEntry
! Number of the entry being processed
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.