52 TTree(table.Data(),
"Database read from table: " + table, 0), fDB(
DB),
54 fResult(nullptr), fRow(nullptr),
56 fBranchChecked(
false),
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");
161 for (
int i=0;i<
nb;i++) {
170 Fatal(
"Branch()",
"Duplicate branch!!!");
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());
236 nl =
tb->GetNleaves();
238 for(
int j=0;
j<
nl;
j++) {
240 typeName =
leaf->GetTypeName();
248 for (
int i=0; i<
rs->GetFieldCount(); ++i) {
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");
475 (
br->GetBasketEntry())[0] = 0;
490 Error(
"CreateTable",
"No TSQLServer specified");
512 if(i == 0 &&
j == 0) {
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;
637 std::pair<TString,Int_t>
value;
643 names.push_back(
cinfo->GetName() );
647 for(
int j=0;
j<
nl;
j++) {
675 }
else Error(
"GetColumnIndice",
"Error finding column %d %s",
j,str.Data());
700 if (count==
nullptr) {
764 if (
fRow==
nullptr && !reset) {
771 if (
fRow==
nullptr)
return -1;
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.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Int_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
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.
Manages buffers for branches of a Tree.
A TTree is a list of TBranches.
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Collection abstract base class.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Int_t GetEntriesFast() const
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.
virtual Int_t GetRowCount() const
virtual TSQLRow * Next()=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)
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