45 TTree(table.
Data(), "Database
read from table: " + table, 0), fDB(DB),
52 fQuery =
TString(
"Select * from " + fTable);
56 Error(
"TTreeSQL",
"No TSQLServer specified");
59 if (CheckTable(fTable.Data())) {
71 Fatal(
"BranchImp",
"Not implemented yet");
81 Fatal(
"BranchImp",
"Not implemented yet");
91 Fatal(
"Branch",
"Not implemented yet");
100 Fatal(
"Branch",
"Not implemented yet");
110 Fatal(
"Branch",
"Not implemented yet");
120 Fatal(
"Bronc",
"Not implemented yet");
130 Fatal(
"BranchOld",
"Not implemented yet");
140 Fatal(
"Branch",
"Not implemented yet");
148 const char *leaflist,
Int_t bufsize)
154 for (
int i=0;i<nb;i++) {
163 Fatal(
"Branch()",
"Duplicate branch!!!");
184 if (basket==0)
return;
196 for (
int i=0;i<nb;i++) {
220 if (!basket)
return kFALSE;
224 Error(
"CheckBranch",
"%s has basket but no resultset yet",tb->
GetName());
230 for(
int j=0;j<nl;j++) {
258 if (!tables)
return kFALSE;
260 while( (row = tables->
Next()) ) {
285 if(typeName ==
"Char_t"){
288 else if(typeName ==
"Int_t") {
291 else if(typeName ==
"Short_t") {
294 else if( typeName ==
"UShort_t") {
295 tn =
"SMALLINT UNSIGNED";
297 else if(typeName ==
"Float_t"){
300 else if(typeName ==
"Float16_t"){
303 else if(typeName ==
"Double_t"){
306 else if(typeName ==
"Double32_t"){
309 else if(typeName ==
"UInt_t") {
312 else if( typeName ==
"Long_t") {
315 else if( typeName ==
"ULong_t") {
316 tn =
"INTEGER UNSIGNED";
318 else if( typeName ==
"Long64_t") {
321 else if( typeName ==
"ULong64_t") {
322 tn =
"BIGINT UNSIGNED";
324 else if( typeName ==
"Bool_t") {
328 Error(
"ConvertTypeName",
"TypeName (%s) not found",typeName.
Data());
341 Error(
"CreateBasket",
"No TSQLServer specified");
359 Error(
"CreateBranch",
"No TSQLServer specified");
364 alterSQL =
"ALTER TABLE ";
367 alterSQL += branchName.
Data();;
369 alterSQL += typeName;
393 for(
int i=0; i < rows; ++i ) {
400 type =
type(0,index);
410 if (prevBranch.
Length()) {
411 if (prevBranch != branchName) {
435 decl.
Append( leafName+siz+
"/C:" );
438 decl.
Append( leafName+
"/I:" );
443 decl.
Append( leafName+
"/I:" );
448 decl.
Append( leafName+
"/i:" );
451 decl.
Append( leafName+
"/S:" );
461 decl.
Append( leafName+
"/F:" );
468 if (prevBranch.
Length()) {
488 Error(
"CreateTable",
"No TSQLServer specified");
493 TString createSQL, alterSQL, str;
502 branchName = branch->
GetName();
510 if(i == 0 && j == 0) {
512 createSQL +=
"CREATE TABLE ";
517 createSQL += leafName;
519 createSQL += typeName;
525 Error(
"CreateTable",
"May have failed");
579 for (
int i=0;i<nb;i++) {
585 for(
int i=0;i<nb;i++) {
588 Error(
"Fill",
"CheckBranch for %s failed",branch->
GetName());
619 std::vector<Int_t> *columns =
new std::vector<Int_t>;
623 std::vector<TString> names;
626 if (rs==0) {
delete columns;
return 0; }
629 std::pair<TString,Int_t> value;
631 for (
Int_t i=0;i<rows;++i) {
633 names.push_back( row->
GetField(0) );
638 for(
int j=0;j<nl;j++) {
649 for (
Int_t i=0;i<rows;++i) {
657 for (
Int_t i=0;i<rows;++i) {
665 columns->push_back(col);
666 }
else Error(
"GetColumnIndice",
"Error finding column %d %s",j,str.
Data());
668 if (columns->empty()) {
669 delete columns;
return 0;
697 sscanf(val.
Data(),
"%ld",&(ret) );
754 if (
fRow==0 && !reset) {
761 if (
fRow==0)
return -1;
virtual const char * GetName() const
Returns name of object.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
double read(const std::string &file_name)
reading
TSQLResult * GetResultSet()
TString CreateBranches(TSQLResult *rs)
determine leaf description string
Long64_t * GetBasketEntry() const
R__EXTERN Int_t gErrorIgnoreLevel
TObjArray * GetListOfBaskets()
virtual TSQLResult * Query(const char *sql)=0
virtual Int_t Fill()
Copy the information from the user object to the TTree.
Bool_t CheckTable(const TString &table) const
Check the table exist in the database.
virtual Int_t Fill()
Fill all branches.
void Init()
Initializeation routine.
virtual const char * GetTypeName() const
Buffer base class used for serializing objects.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Bool_t CheckBranch(TBranch *tb)
Check if the table has a column corresponding the branch and that the resultset are properly setup...
virtual Long64_t GetEntries() const
Get the number of rows in the database.
Implement TTree for a SQL backend.
TBuffer * GetBufferRef() const
virtual TBranch * BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1)
Not implemented yet.
void CreateBuffer(const char *name, TString title, std::vector< Int_t > *vc, TBranch *branch, TSQLResult **rs)
Create a TSQLBuffer for this basket.
virtual TBranch * BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel)
Not implemented yet.
virtual Long64_t LoadTree(Long64_t entry)
Setup the tree to the load the specified entry.
void ResetQuery()
Reset the internal query.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
virtual void CreateBranch(const TString &branchName, const TString &typeName)
Create the column(s) in the database that correspond to the branch/.
TString & Append(const char *cs)
std::vector< std::vector< double > > Data
virtual TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=0)=0
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...
TObjArray * GetListOfBranches()
Ssiz_t First(char c) const
Find first occurrence of a character c.
TBasket * GetBasket(Int_t basket)
Return pointer to basket basketnumber in this Branch.
void Error(const char *location, const char *msgfmt,...)
void Refresh()
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
virtual void SetEntries(Long64_t entries)
Set the number of entries in this branch.
Long64_t fReadEntry
! Number of the entry being processed
Collection abstract base class.
TObjArray fBranches
List of Branches.
Int_t GetEntriesFast() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Manages buffers for branches of a Tree.
virtual const char * GetField(Int_t field)=0
The ROOT global object gROOT contains a list of all defined classes.
virtual Int_t GetFieldCount()=0
TString & Remove(Ssiz_t pos)
virtual Long64_t GetEntriesFast() const
Return the number of entries as of the last check.
Implement TBasket for a SQL backend.
TObject * UncheckedAt(Int_t i) const
virtual void ResetAddress()
Reset the address of the branch.
virtual TSQLResult * GetTables(const char *dbname, const char *wild=0)=0
TObjArray * GetListOfLeaves()
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Load the data for the entry from the database.
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Not implemented yet.
virtual Int_t GetRowCount() const
virtual TBranch * Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
Not implemented yet.
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.
Long64_t fEntries
Number of entries.
Bool_t CreateTable(const TString &table)
Create the database table corresponding to this TTree.
virtual TBasket * CreateBasket(TBranch *br)
Create a TBasketSQL.
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
A TTree object has a header with a name and a title.
virtual const char * GetFieldName(Int_t field)=0
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
A TTree is a list of TBranches.
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
virtual TSQLRow * Next()=0
const char * Data() const