Status of SQL and XML I/O Sergey Linev, GSI, Darmstadt, Germany.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Standardizing Application.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 1 Introduction to Database Management.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Confidential ODBC May 7, Features What is ODBC? Why Create an ODBC Driver for Rochade? How do we Expose Rochade as Relational Transformation.
Phil Brewster  One of the first steps – identify the proper data types  Decide how data (in columns) should be stored and used.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
Training - Day 3 OJB. What is OR Mapping? OR Mapping is the mapping of relational database tables to objects (Java Objects in our case) Many OR Mapping.
XML I/O in ROOT S. Linev, R. Brun, H.G. Essel CHEP 2004.
Creating Data Marts from COBOL Files (ISAM to RDBMS)
Database Design for DNN Developers Sebastian Leupold.
Introduction to Database Management. 1-2 Outline  Database characteristics  DBMS features  Architectures  Organizational roles.
Irina Sourikova Brookhaven National Laboratory for the PHENIX collaboration Migrating PHENIX databases from object to relational model.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Relational Databases Database Driven Applications Retrieving Data Changing Data Analysing Data What is a DBMS An application that holds the data manages.
5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International
1 Design Issues in XML Databases Ref: Designing XML Databases by Mark Graves.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Workshop on Grid Application Programming 19th-21st July 2004, Edinburgh, 1 Hartmut Kaiser The C Implementation of the GAT OO Specification Hartmut Kaiser.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
Stored Procedures Week 9. Test Details Stored Procedures SQL can call code written in iSeries High Level Languages –Called stored procedures SQL has.
A Brief Documentation.  Provides basic information about connection, server, and client.
Programmatic SQL Shaista Khan CS 157B. Topic Embedded SQL statements in high-level programming languages.
THttpServer for ROOT Bertrand Bellenot, CERN Sergey Linev, GSI Darmstadt
ROOT I/O for SQL databases Sergey Linev, GSI, Germany.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
What’s a database? Data stored in a structured format that lends itself to easy manipulation and recall.
Visual Programing SQL Overview Section 1.
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
Persistent Object References in ROOT1 Persistent Object References in ROOT I/O Status & Proposal CMS-ROOT meeting CERN- November 27 Ren é Brun ftp://root.cern.ch/root/refs.ppt.
Using of XML for object store S. Linev, GSI Using of XML for object store. S.Linev2 Content XML and existing packages XML and existing packages.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
Dr Gordon Russell, Napier University Unit Embedde SQL - V2.0 1 Embedded SQL Unit 5.1.
ROOT Tutorials - Session 51 ROOT Tutorials – Session 5 Dictionary Generation, rootcint, Simple I/O, Hands-on Fons Rademakers.
STAR Schema Evolution Implementation in ROOT I/O V. Perevoztchikov Brookhaven National Laboratory,USA.
ROOT Data bases access1 LCG Data base deployment workshop 11 October Ren é Brun CERN.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
1 CS 430 Database Theory Winter 2005 Lecture 10: Introduction to SQL.
Basics of JDBC Session 14.
9/28/2005Philippe Canal, ROOT Workshop TTree / SQL Philippe Canal (FNAL) 2005 Root Workshop.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Scalable data access with Impala Zbigniew Baranowski Maciej Grzybek Daniel Lanza Garcia Kacper Surdy.
Lu Wei1 Outline Introduction Basic SQL Setting Up and Using PostgreSQL Advanced SQL Embeded SQL.
ROOT-CORE Team 1 Philippe Canal Markus Frank I/O Basic I/O, RDBMS interfaces, Trees.
Confidencial - TRACASA Automatize test [e- Reporting]
Level 1-2 Trigger Data Base development Current status and overview Myron Campbell, Alexei Varganov, Stephen Miller University of Michigan August 17, 2000.
Go4 Workshop J.Adamczewski-Musch, S.Linev Go4 advanced features.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
 CONACT UC:  Magnific training   
 What is DB Testing ?  Testing at the Data Access Layer  Need for Testing DB Objects  Common Problems that affect the Application  Should Testers.
CHAPTER 9 File Storage Shared Preferences SQLite.
Data generators by Jan Kincl. Data Generators - Jan Kincl2 Outline Introduction Introduction Main features Main features MySQL Data Generators MySQL Data.
Evaluation of the C++ binding to the Oracle Database System Dirk Geppert and Krzysztof Nienartowicz, IT/DB CERN IT Fellow Seminar November 20, 2002.
DEPTT. OF COMP. SC & APPLICATIONS
CS320 Web and Internet Programming SQL and MySQL
Possibility of XML I/O support in ROOT
DATABASE MANAGEMENT SYSTEM
SQL Fundamentals in Three Hours
Contents Preface I Introduction Lesson Objectives I-2
CS3220 Web and Internet Programming SQL and MySQL
Data.
CS3220 Web and Internet Programming SQL and MySQL
Database Instructor: Bei Kang.
CS4540 Special Topics in Web Development SQL and MS SQL
Presentation transcript:

Status of SQL and XML I/O Sergey Linev, GSI, Darmstadt, Germany

S.Linev Status of SQL and XML I/O2 Outline  Current development in SQL classes: many improvements new TSQLStatement class new ODBC support  TSQLFile class functionality, table design custom streamers support  Improvements in XML I/O  SQL I/O performance

S.Linev Status of SQL and XML I/O3 SQL support in ROOT  Since 7 years in ROOT there are classes: TSQLServer – interface to SQL server TSQLResult – result of SELECT queries TSQLRow – access to single row in result  Design was driven by text-based MySQL interface, not sufficient for real applications  Implementations for: MySQL, Oracle, PostgreSQL, SapDB

S.Linev Status of SQL and XML I/O4 Improvements in SQL classes  New methods of TSQLServer class: Metainformation in DB-independent format:  GetTablesList() – list of tables  HasTable() – check if table exists  GetTableInfo() – provides information about table in TSQLTableInfo / TSQLColumnInfo objects  GetMaxIdentifierLength() Transaction control:  StartTransaction(), Commit(), Rollback() Error handling:  GetErrorCode(), GetErrorMsg(), EnableErrorOutput() Exec() - for queries without results set  Bug fixes and enhancement in Oracle classes  Better support for different MySQL versions – now from to 5.x

S.Linev Status of SQL and XML I/O5 New TSQLStatement class  Provides functionality to prepared SQL statements, supported by most of modern RDBMS  Works with native data types: integer, double, date/time, string, null  Introduces binary data support (BLOBs)  Useful not only for SELECT, but also for INSERT queries  Implemented for MySQL, Oracle and ODBC plugins  Significant improvement in performance, especially for bulk operations, especially for Oracle (factor of )

S.Linev Status of SQL and XML I/O6 ODBC support in ROOT  ODBC – Open DataBase Connectivity  Supported by most of RDBMS  Implemented as new SQL plugin in ROOT  Provides full functionality of TSQLServer class, including statements support  Tested with MySQL and Oracle on Linux and Windows

S.Linev Status of SQL and XML I/O7 New TSQLFile class  Provides TFile interface to SQL database  Uses only ROOT SQL classes  Produces human-readable tables format  Support most of TFile features: schema evolution subdirectory structure custom streamers the only exception – TTree class  Tested with MySQL, Oracle, MyODBC, can be adjusted for other RDBMS

S.Linev Status of SQL and XML I/O8 Short example with TBox class class TBox: public TObject, public TAttLine, public TAttFill { Double_t fX1; Double_t fY1; Double_t fX2; Double_t fY2; ClassDef(TBox, 2); }; { TSQLFile f(“mysql://host.domain/test”, “create”,”user”,”pass”); for (int n=1;n<=10;n++) { TBox box(n,n*2,n*3,n*4); box.Write(Form(“box%d”,n)); } SELECT * FROM TBox_ver2TObject_ver1 Creates tables: TBox_ver2 TObject_ver1 TAttLine_ver1 TAttFill_ver2 KeysTable ObjectsTable Configurations IdsTable

S.Linev Status of SQL and XML I/O9 More complex example with TGraph { TSQLFile f(“mysql://host.domain/test”, “update”,”user”,”pass”); TGraph gr(10); for (int n=0;n<10;n++) gr.SetPoint(n, n+1, (n+1)*(n+1)); gr.Write(“gr”); } TGraph_ver4 parent classes TGraph_raw4 ObjectsTable TList_raw5 NULL pointer data members

S.Linev Status of SQL and XML I/O10 External access to SQL tables  Easy navigation with simple SELECT queries in any SQL browser  One raw in table corresponds to one object  Each column contains data of single class member  Class name and version for each object can be found in ObjectsTable  TSQLFile::MakeSelectQuery() produce SELECT statement, which aggregates data of object from different tables in one

S.Linev Status of SQL and XML I/O11 Example with TBox class Query, produced by f->MakeSelectQuery(TBox::Class()): SELECT t1.`obj:id`, t2.UniqueId, t2.Bits, t2.ProcessId, t3.fLineColor, t3.fLineStyle, t3.fLineWidth, t4.fFillColor, t4.fFillStyle, t1.fX1, t1.fY1, t1.fX2, t1.fY2 FROM TBox_ver2 AS t1 LEFT JOIN TObject_ver1 AS t2 USING(`obj:id`) LEFT JOIN TAttLine_ver1 AS t3 USING(`obj:id`) LEFT JOIN TAttFill_ver1 AS t4 USING(`obj:id`) TObjectTAttLineTAttFillTBox

S.Linev Status of SQL and XML I/O12 Custom streamer support  Important, while lot of ROOT and some user classes has custom streamers  Two alternatives are possible: produced by custom streamer data will be written without data member info into special tables like TList_raw5 or TGraph_raw4 custom streamer can be instrumented in the way that object data will be stored in normal class table column-wise  Even special case when custom streamer reads data written by standard I/O is supported (for instance, TStreamerElement, TStreamerInfo)

S.Linev Status of SQL and XML I/O13 Example of custom streamer class TTestClass : public TNamed { public: TTestClass(const char* name); virtual ~TTestClass(); Int_t fInt; Double_t fArr[3]; TString fStr; ClassDef(TTestClass, 1); }; void TTestClass::Streamer(TBuffer &b) { UInt_t R__s, R__c; if (b.IsReading()) { Version_t R__v = b.ReadVersion(&R__s, &R__c); TNamed::Streamer(b); b >> fInt; b.ReadFastArray(fArr, 3); fStr.Streamer(b); b.SetBufferOffset(R__s+R__c+sizeof(UInt_t)); } else { UInt_t R__c = b.WriteVersion(TTestClass::Class(), kTRUE); TNamed::Streamer(b); b << fInt; b.WriteFastArray(fArr, 3); fStr.Streamer(b); b.SetByteCount(R__c, kTRUE); } Class definition: Custom streamer implementation:... #pragma link C++ class TTestClass-;... Entry in LinkDef.h:

S.Linev Status of SQL and XML I/O14 XML and SQL representation SELECT * FROM TTestClass_raw1 Part of XML file:

S.Linev Status of SQL and XML I/O15 Instrumented custom streamer void TTestClass::Streamer(TBuffer &b) { UInt_t R__s, R__c; if (b.IsReading()) { Version_t R__v = b.ReadVersion(&R__s, &R__c); b.ClassBegin(TTestClass::Class(), R__v); b.ClassMember("TNamed"); TNamed::Streamer(b); b.ClassMember("fInt","Int_t"); b >> fInt; b.ClassMember("fArr","Double_t", 3); b.ReadFastArray(fArr, 3); b.ClassMember("fStr","TString"); fStr.Streamer(b); b.ClassEnd(TTestClass::Class()); b.SetBufferOffset(R__s+R__c+sizeof(UInt_t)); } else { TTestClass::Class()->WriteBuffer(b,this); } } Instrumented custom streamer implementation: Meta-information about class itself and class members In this case standard store procedure can be used

S.Linev Status of SQL and XML I/O16 XML and SQL representation SELECT * FROM TTestClass_ver1 Part of XML file: SELECT * FROM TTestClass_raw1 Part of XML file:

S.Linev Status of SQL and XML I/O17 Enhancements of XML I/O  TXMLFile class since 2004 in ROOT  Provides possibility to store in XML file arbitrary type of objects (beside TTree)  New functionality of TXMLFile: subdirectories structures instrumented custom streamers better support of TClonesArray xml comments and style sheets

S.Linev Status of SQL and XML I/O18 Converting objects to/from XML  New static methods of TBufferXML class: ConvertToXML() – store object data in from of XML structures ConvertFromXML() – reconstruct object from XML structures  Easy method to convert any single object into / from text representation  Can be use to store any object in form of CINT macro

S.Linev Status of SQL and XML I/O19 Converts any object into macro void make_script(TObject* obj, const char* funcname) { TString xmlbuf = TBufferXML::ConvertToXML(obj); xmlbuf.ReplaceAll("\"","\\\""); xmlbuf.ReplaceAll("\n","\";\n sbuf+=\""); std::ofstream fs(TString(funcname)+".C"); fs ClassName() << "* " << funcname << "()\n" "{\n" " TString sbuf = \"" << xmlbuf << "\";\n" ClassName() << "*)" << "TBufferXML::ConvertFromXML(sbuf);\n}\n"; }

S.Linev Status of SQL and XML I/O20 Convert TBox class into macro... root [0] TBox b(1, 2, 3, 4); root [1] make_script(&b, "make_box"); Generate macro: TBox* make_box() { TString sbuf = " "; sbuf+=" "; return (TBox*) TBufferXML::ConvertFromXML(sbuf); } 2. Produced file make_box.C:... root [0].L make_box.C root [1] b = make_box(); root [2] b->Draw(); Reconstruct object:

S.Linev Status of SQL and XML I/O21 SQL I/O performance  Two aspects: Time and CPU usage on user host Quality and number of SQL statements // TFile f(“test.root”,”recreate”); // TXMLFile f(“test.xml”,”recreate”); TSQLFile f(“mysql://host.domain/test”, “recreate”,”user”,”pass”); TClonesArray clones("TBox", 10000); for(int n=0;n<10000;n++) new (clones[n]) TBox(n+1,n+2,n+3,n+4); clones.Write("clones0", TObject::kSingleKey); gBenchmark->Start(“Write"); clones.Write("clones",TObject::kSingleKey); gBenchmark->Show(“Write"); // TFile f(“test.root”,”read”); // TXMLFile f(“test.xml”,”read”); TSQLFile f(“mysql://host.domain/test”, “read”,”user”,”pass”); TClonesArray* clon = 0, *clon0 = 0; f.GetObject("clones0", clon0); gBenchmark->Start(“Read"); f.GetObject("clones", clon); gBenchmark->Show(“Read");

S.Linev Status of SQL and XML I/O22 Performance measurements * Only text queries are used for MySQL, while SQL statement works slower on MySQL compare to multiple INSERT query ** Same MySQL 5.0 server is used. Can be seen, that using statements while writing significantly increases time WritingReading CPU, sReal, s Queries / statements CPU, sReal, s Queries / statements Binary XML MySQL / 0* / 2 Oracle 10g / / 2 MyODBC 3.51** / / 2

S.Linev Status of SQL and XML I/O23 To do:  SQL performance improvements avoid text conversions where it possible use statements where it make sense use BLOBs for custom data  Adopt TSQLStatement in TTreeSQL class?  Support of large (more 1Gb) XML files?  Any missing features in XML / SQL classes?