[root] / trunk / io / sql / src / TBufferSQL2.cxx Repository:
ViewVC logotype

Log of /trunk/io/sql/src/TBufferSQL2.cxx

Parent Directory Parent Directory


Links to HEAD: (view) (download) (as text) (annotate)
Sticky Revision:

Revision 49019 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Mar 31 17:18:33 2013 UTC (21 months, 3 weeks ago) by pcanal
File length: 91737 byte(s)
Diff to previous 44507
Import revision 48931 from the v5-34-00 patch branch:
Add the concept of implicit rules to (centrally) support automatic translation of
STL collection from numeric type to other numeric type or for when the contained
class has some rules.  Currently enabled only when the target is an std::vector.

Implement the transformation from STL container of numeric to any other numeric
type (both in TGenCollectionStreamer and TStreamerInfo[Actions]).

Migrate more of the conversions to TStreamerInfoActions.

Fix the Conversion of a Double32 or Float16 inside a collection of object to another
type (the previous implemetation was not supporting the customization of the factor
nor the number of bits).

Add TBuffer::ReadFastArrayWithNbits and WithFactor for use in the StreamerInfo Actions.

TStreamerInfoActions:

Introduce WithFactorMarker and NoFactorMarker to allow for less code duplicaton when
supporting Float16_t and Double32_t.
Replace the collection-memberwise action from loop over simple operation to using
ReadFastArray (to be compatible with TBufferXML).

Revision 44507 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jun 4 12:30:41 2012 UTC (2 years, 7 months ago) by axel
File length: 90702 byte(s)
Diff to previous 43518
Remove
  using namespace std;
from Riostream.h, which has huge consequences for all of ROOT.
Riostream.h is now a simple wrapper for fstream, iostream, iomanip for backward compatibility; Riosfwd.h simply wraps iosfwd.

Because of templates and their inline functions, Riostream.h needed to be included in headers, too (e.g. TParameter.h), which violated the assumption that Riostream.h is not exposing its using namespace std to headers.
ROOT now requires R__ANSISTREAM, R__SSTREAM, which does not change the set of supported compilers.

Without "using namespace std", several identifiers are now prefixed by std::; e.g. roofit/* source files now have a using namespace std to keep their coding style.
TFile::MakeProject() now generates "using namespace std" to convert the CINT-style class names into C++ ones.

Revision 43518 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Mar 28 01:04:07 2012 UTC (2 years, 9 months ago) by pcanal
File length: 90487 byte(s)
Diff to previous 43303
Fix for coding convention RS1 and RS2

Revision 43303 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Mar 8 16:18:34 2012 UTC (2 years, 10 months ago) by pcanal
File length: 90544 byte(s)
Diff to previous 41696
Avoid null pointer use (coverity #33546)

Revision 41696 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Nov 1 19:52:12 2011 UTC (3 years, 2 months ago) by pcanal
File length: 90535 byte(s)
Diff to previous 40872
Fix high impact coverity reports

Revision 40872 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Sep 13 21:33:33 2011 UTC (3 years, 4 months ago) by pcanal
File length: 90475 byte(s)
Diff to previous 36061
From Chris Jones:

Put in place the infrastructure to optimize the I/O writes in the same way we optimized the I/O reads.

Rename TBuffer::ReadSequence to TBuffer::ApplySequence as they can be used both for reading and writing.  The 3 new signatures:

1. virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object);      
2. virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);      
3. virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);

The 1st version is optimized to read a single object. The 2nd version is optimized to read the content of TClonesArrays and vectors of pointers to objects.
The 3rd version is used to streamed any collections.

In TBranchElement, introduce a set FillLeaves member functions to precalculate many of the (existing) conditional.  Introduction support for the StreamerInfo write actions and sequences.

Revision 36061 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Oct 4 16:05:51 2010 UTC (4 years, 3 months ago) by pcanal
File length: 90472 byte(s)
Diff to previous 35970
Introduce an optimized infrastructure for reading objects using a StreamerInfo.

Rather than driving the streaming using a switch statement inside TStreamerInfo::ReadBuffer,
the streaming is now driven using a simple loop over a sequence of configured StreamerInfo actions.

This improves run-time performance by allowing a dramatic reduction in function calls and code
branches at the expense of some code duplication.


There are 3 versions of this loop implemented in TBufferFile and overloaded in TBufferXML and TBufferSQL:

1. virtual Int_t ReadSequence(const TStreamerInfoActions::TActionSequence &sequence, void *object);      
2. virtual Int_t ReadSequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);      
3. virtual Int_t ReadSequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);

The 1st version is optimized to read a single object. The 2nd version is optimized to read the content of TClonesArrays and vectors of pointers to objects.
The 3rd version is used to streamed any collections.

TBufferXML and TBufferSQL overload the loops to introduce extra code to help the buffer keep track of which streamer
element is being streamed (this functionality is not used by TBufferFile.)

A TStreamerInfoActions::TActionSequence is an ordered sequence of configured actions.   

A configured action has both an action which is a free standing function and a configuration object deriving 
from TStreamerInfoActions::TConfiguration. The configuration contains information that is specific to the action
but varies from use to use, including the offset from the beginning of the object that needs to be updated.   
Other examples of configuration include the number of bits requested for storing a Double32_t or its factor and minimum.   


When the sequence is intended for a collection, the sequence also has a configuration object deriving
from TStreamerInfoActions::TLoopConfiguration which contains for example the size of the element of
a vector or the pointers to the iterators functions (see below).


Each TStreamerInfo has 2 reading sequences, one for object-wise reading (GetReadObjectWiseActions)
and one for member-wise reading (GetReadMemberWiseActions) which is used when streaming a TClonesArray
of a vector of pointer to the type of objects described by the TClass.


Each collection proxy has at least one reading sequences, one for the reading each version of the
contained class layout.


Each case of the TStreamerInfo::ReadBuffer switch statement is replaced by 4 new action functions,
one for the object wise reading, one for the member wise reading for TClonesArray and vector of pointers,
one for the member wise reading for a vector of object and one for all other collections.


Each collection (proxy) needs to provide 5 new free standing functions:

   // Set of functions to iterate easily throught the collection
   static const Int_t fgIteratorArenaSize = 16; // greater than sizeof(void*) + sizeof(UInt_t)

   typedef void (*CreateIterators_t)(void *collection, void **begin_arena, void **end_arena);
   virtual CreateIterators_t GetFunctionCreateIterators(Bool_t read = kTRUE) = 0; 
   // begin_arena and end_arena should contain the location of a memory arena of size fgIteratorSize. 
   // If the collection iterator are of that size or less, the iterators will be constructed in place in those location (new with placement)
   // Otherwise the iterators will be allocated via a regular new and their address returned by modifying the value of begin_arena and end_arena.
   
   typedef void* (*CopyIterator_t)(void *dest, const void *source);
   virtual CopyIterator_t GetFunctionCopyIterator(Bool_t read = kTRUE) = 0;
   // Copy the iterator source, into dest.   dest should contain the location of a memory arena of size fgIteratorSize.
   // If the collection iterator is of that size or less, the iterator will be constructed in place in this location (new with placement)
   // Otherwise the iterator will be allocated via a regular new and its address returned by modifying the value of dest.
   
   typedef void* (*Next_t)(void *iter, const void *end);
   virtual Next_t GetFunctionNext(Bool_t read = kTRUE) = 0;
   // iter and end should be pointers to respectively an iterator to be incremented and the result of collection.end()
   // If the iterator has not reached the end of the collection, 'Next' increment the iterator 'iter' and return 0 if 
   // the iterator reached the end.
   // If the end was not reached, 'Next' returns the address of the content pointed to by the iterator before the 
   // incrementation ; if the collection contains pointers, 'Next' will return the value of the pointer.
   
   typedef void (*DeleteIterator_t)(void *iter);
   typedef void (*DeleteTwoIterators_t)(void *begin, void *end);

   virtual DeleteIterator_t GetFunctionDeleteIterator(Bool_t read = kTRUE) = 0;
   virtual DeleteTwoIterators_t GetFunctionDeleteTwoIterators(Bool_t read = kTRUE) = 0;
   // If the size of the iterator is greater than fgIteratorArenaSize, call delete on the addresses,
   // Otherwise just call the iterator's destructor.
 
This functions are currently only 'emulated' using the old infrastructure for the collections other than vector ; they
will later one be provided by the dictionaries.

Revision 35970 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Oct 1 08:58:33 2010 UTC (4 years, 3 months ago) by rdm
File length: 83364 byte(s)
Diff to previous 35765
fix coverity 11571.

Revision 35765 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Sep 27 07:49:55 2010 UTC (4 years, 3 months ago) by rdm
File length: 83348 byte(s)
Diff to previous 35527
fix coverity 11571.

Revision 35527 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Sep 21 12:27:01 2010 UTC (4 years, 4 months ago) by brun
File length: 83627 byte(s)
Diff to previous 34910
do not include snprintf.h

Revision 34910 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 20 18:21:43 2010 UTC (4 years, 5 months ago) by pcanal
File length: 83649 byte(s)
Diff to previous 34261
Fix uninitialized data members (coverity)

Revision 34261 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jul 1 06:59:01 2010 UTC (4 years, 6 months ago) by brun
File length: 83272 byte(s)
Diff to previous 34259
Fix formats

Revision 34259 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jul 1 06:53:58 2010 UTC (4 years, 6 months ago) by brun
File length: 83261 byte(s)
Diff to previous 29636
Fix formats

Revision 29636 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jul 30 14:50:00 2009 UTC (5 years, 5 months ago) by rdm
File length: 83248 byte(s)
Diff to previous 29321
fix gcc-3.4 compiler warnings. This compiler does not like it when Long64_t's
are cast to pointers on 32-bit machines without first being cast to Long_t
(gcc 4.x does not complain about this).

Revision 29321 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jul 3 10:42:10 2009 UTC (5 years, 6 months ago) by brun
File length: 83240 byte(s)
Diff to previous 29170
From Sergei Linev:
1. New static methods to set/get time formatting in TOracleServer
2. Move float format constant for TBufferSQL2 to TSQLServer
3. Use that format in several other appropriate places like TODBCStatement, TOracleRow and so on.
4. Replace sprintf to snprintf calls in several places.

Revision 29170 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jun 23 14:09:56 2009 UTC (5 years, 7 months ago) by brun
File length: 82936 byte(s)
Diff to previous 25450
From Sergey:
There was a request to modify XML classes such that formatting of float/double variables should be changed to "%e".
It sounds reasonable - nobody, seems to be, was using small floats with XML. Therefore in patch following changes are implemented:

1. Conversion from float/double to string per default performed with "%e" (exponential) format.
2. Format can be configured with SetFloatFormat methods that one can specify precision, width arguments of printf call
3. sscanf works as before - "%f" accpet both exponential and decimal format
4. Similar changes done for TBufferXML and TBufferSQL2 classes.

Revision 25450 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Sep 18 21:13:42 2008 UTC (6 years, 4 months ago) by pcanal
File length: 82421 byte(s)
Diff to previous 25411
Import the code from the branch dev/datamodelevolution revision 25436

This implements the infrastructure for the new Data Model Evolution Scheme.

This Data Model Evolution is brought to your courtesy of BNL/STAR/ATLAS/Fermi/Cern

Current Capabilities:
  Assign values to transient data members
  Rename classes
  Rename data members
  Change the shape of the data structures or convert one class structure to another
  Change the meaning of data members
  Ability to access the TBuffer directly when needed
  Ensure that the objects in collections are handled in the same way as the ones stored separately
  Supported in object-wise, member-wise and split modes.

Coming soon:
  Make things operational also in bare ROOT mode
  Ability to transform data before writing
  Support for changing the class type of nested object in a split branch
  Support for access to onfile version of nested objects from within the parent rule

LinkDef rule syntax:
  Setting a transient member:

#pragma read sourceClass="ACache" targetClass="ACache" source="" version="[1-]" target="zcalc" \
   code="{ zcalc = false; }"

  Setting a new member from 2 removed members

#pragma read sourceClass="ACache" targetClass="ACache" source="int x; int y; char c"  version="[8]" target="z" \
   code="{ z = onfile.x*1000 + onfile.y*10; }"

   Renaming a class

#pragma read sourceClass="ACache" version="[8]" targetClass="Axis" \
   source="int x; int y;"  target="z" \
   code="{ z = onfile.x*1000 + onfile.y*
#pragma read sourceClass="ACache" version="[9]" targetClass="Axis";

Selection XML syntax

  <read  sourceClass="ACache" targetClass="ACache" source="" version="[1-]" target="zcalc">
  <![CDATA[
   { zcalc = false; }
  ]]></read>


Revision 25411 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Sep 16 06:45:24 2008 UTC (6 years, 4 months ago) by brun
File length: 81999 byte(s)
Diff to previous 24220
From Sergei Linev:
fix bug reported by Peter Speckmayer at https://savannah.cern.ch/bugs/?41600
Problem was caused by non-consitent changes in TBufferFile class.
More precisely, by this one:

http://root.cern.ch/viewcvs?view=rev&revision=23954

Revision 24220 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jun 11 15:39:55 2008 UTC (6 years, 7 months ago) by brun
File length: 81994 byte(s)
Diff to previous 23122
-call TBuffer::ForceWriteInfo instead of TStreamerInfo::ForceWriteInfo

Revision 23122 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Apr 10 14:56:30 2008 UTC (6 years, 9 months ago) by rdm
File length: 82009 byte(s)
Diff to previous 22488
move the following directories into "io":

castor, chrip, dcache, gfal, io, rfio, sql, xml

Revision 22488 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Mar 6 16:04:47 2008 UTC (6 years, 10 months ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 82009 byte(s)
Diff to previous 22419
remove first batch of warning reported by gcc 4.3:
- warning: suggest parentheses around && within ||
- warning: suggest explicit braces to avoid ambiguous if else

Revision 22419 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Mar 3 00:25:01 2008 UTC (6 years, 10 months ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 81903 byte(s)
Diff to previous 20882
From Andrew Savchenko:
ROOT can not be compiled with gcc-4.3.
Some ROOT source files doesn't contain required #include directives,
for example, they use strlen(), but #include <string.h> is missed or
malloc() is used and #include <stdlib.h> is missed. 

Earlier versions of gcc allowed some headers to be included implicitly,
but issued a warning (-Wimplicit-function-declaration). Newer one,
gcc-4.3 denies such silly behaviour: all required headers must be explicitly
included. 

Attached patch fixes this. Also it fixes another issue, which disallows
ROOT to compile under gcc-4.3: C functions don't belong to namespace std,
so expressions like std::memcpy() are no longer valid and plain memcpy()
should be used instead.

Revision 20882 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Nov 19 11:31:26 2007 UTC (7 years, 2 months ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 81883 byte(s)
Diff to previous 20170
Set property svn:eol-style LF on all source and Makefiles. This should avoid
problems with Win32 line endings ending up in the repository. All MS tools
support LF eols fine.

Revision 20170 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Oct 2 09:02:20 2007 UTC (7 years, 3 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 81883 byte(s)
Diff to previous 19826
First batch of changes to support the new data type Float16_t.
For more info about Float16_t see TBufferFile::WriteFloat16.

Revision 19826 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Sep 19 19:56:11 2007 UTC (7 years, 4 months ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 80224 byte(s)
Diff to previous 19825
imported svn:keywords Id property

Revision 19825 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Sep 19 19:49:10 2007 UTC (7 years, 4 months ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 80278 byte(s)
Diff to previous 18128
remove :$ from tag line

Revision 18128 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Mar 1 16:38:36 2007 UTC (7 years, 10 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 80288 byte(s)
Diff to previous 17813
From Sergey Linev:
1. While name of the class is changed, one should use TDirectoryFile class instead of
   TDirectory at the moment, then new directory object is created.
2. Appropriate change done in non-binary part of TDirectoryFile::Streamer() that old version of
   class can be read.

Revision 17813 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Feb 9 08:56:40 2007 UTC (7 years, 11 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 80208 byte(s)
Diff to previous 17574
Change the signatures of IncrementLevel and DecrementLevel to agree with
the recent changes in TBuffer.

Revision 17574 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jan 30 10:11:47 2007 UTC (7 years, 11 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 80178 byte(s)
Diff to previous 17407
-Replace calls to gROOT->GetClass by TClass::GetClass

Revision 17407 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jan 20 09:34:58 2007 UTC (8 years ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 80171 byte(s)
Diff to previous 17404
Move the dummy implementation of ReadString and WriteString to the implementation file.

Revision 17404 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jan 19 18:25:12 2007 UTC (8 years ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 79620 byte(s)
Diff to previous 17402
Call TBufferFile:: instead of TBuffer:: functions

Revision 17402 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jan 19 16:48:00 2007 UTC (8 years ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 79616 byte(s)
Diff to previous 17306
CVs been changed into a pure abstract interface.
The concrete implementation is in the new class TBufferFile.
All classes previously deriving from TBuffer derive now from TBufferFile, ie

  TBuffer  <- TBufferFile  <- TMessage
                           <- TBufferXML
                           <- TBufferSQL
                           <- TBufferSQL2

Because there are several problems with C++ operators overloading,
The I/O operators are defined in TBuffer. These are inline functions
calling C++ virtual functions defined in TBuffer and overloaded
by TBufferFile and all other derived classes when necessary.

The previous implementation of TBuffer.h included <vector> and Bytes.h.
The two include statements have been moved to TBufferFile.h. As a result the
compilation of the ROOT system is now slightly faster and a big bonus
is that changes in TBufferFile or Bytes.h will affect only TBufferFile
and will not force the recompilation of the entire system.
This change has some side-effects. If you assumed that include <vector>
was done by TBuffer.h, you may have to specify this include directly
in your class. This was the case for a few ROOT classes.


 : ----------------------------------------------------------------------

Revision 17306 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jan 12 16:03:17 2007 UTC (8 years ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 79866 byte(s)
Diff to previous 15512
   TMath::Abs, TMath::Min, TMath::Max, TMath::Sign, TMath::Range
These functions are unfortunately not defined in a standard way in std::

This include is referenced by a new version of TMath.h.
As a result, TMath.h is back compatible with the previous version.

TMathBase.h is used in place of TMath.h in all the classes
that will go into the future miniCore library.
TMath.h and the TMath implementation will go into a new math sub-directory.

TString.h uses TMathBase.h instead of TMath.h.
As a result, it was necessary to include "TMath.h" in some classes
assuming that TMath was included via TString and using other functions
than the ones defined in TMathBase.h
 ----------------------------------------------------------------------

Revision 15512 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 22 08:21:23 2006 UTC (8 years, 7 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 79862 byte(s)
Diff to previous 15125
From Sergey Linev:
1. Implementation of TDirectory I/O for TSQLFile and TXMLFile
2. In TSQLFile identifier length is now controled.
   Important for Oracle, where table or column name cannot be more than 32 symbols.
3. Adding usage of TSQLStatement class where possible.
4. Small performance improvment.

Revision 15125 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon May 22 08:55:58 2006 UTC (8 years, 8 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 79781 byte(s)
Diff to previous 14994
From sergei Linev:
1. Streamer info are now stored/read from SQL database.
2. Usage of TSQLStatement class (speed up for Oracle)
3. Tested and adjusted for ODBC plugin

Revision 14994 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu May 11 10:29:45 2006 UTC (8 years, 8 months ago) by brun
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 78838 byte(s)
Diff to previous 14676
Fix coding conventions

Revision 14676 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Apr 12 20:54:30 2006 UTC (8 years, 9 months ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 78792 byte(s)
Diff to previous 13977
fix format for 64 bit values (%lld and not %ld).

Revision 13977 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Feb 1 18:57:41 2006 UTC (8 years, 11 months ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 78869 byte(s)
Diff to previous 13927
From Sergei Linev:
Move CreateKey from TDirectory to TFile
Here is also optimisation of SQL statements and adjustement for Oracle.
Implementation of ClassBegin()/ClassMember()/ClassEnd() methdos for TBufferSQL2 and TBufferXML.
I also implementation for ClassMemeber() method for case of "raw:data" for SQL and XML cases.

Revision 13927 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jan 25 16:00:11 2006 UTC (9 years ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 69316 byte(s)
Diff to previous 13524
From Segei Linev:
Update to sql and xml following the chnage to reduce reliance
on gFile and gDirectory

Revision 13524 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Dec 7 14:59:57 2005 UTC (9 years, 1 month ago) by rdm
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 69804 byte(s)
Diff to previous 13471
fix cvs indentification line: net -> sql.

Revision 13471 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Dec 2 23:23:36 2005 UTC (9 years, 1 month ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 69804 byte(s)
Diff to previous 13435
Implement TBuffer\*::StreamObject(TObject\*)

Revision 13435 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Dec 1 16:30:43 2005 UTC (9 years, 1 month ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 69578 byte(s)
Diff to previous 13383
From Sergei Linev:

This patch allows more clear representation of TClonesArray data in TSQLFile.

It also solves problem of correct saving of array of objects in TSQLFile.
I redefine in TBufferSQL2 following functions:

void WriteFastArray(void* start, const TClass* cl, Int_t n, TMemberStreamer* s)
Int_t WriteFastArray(void** startp, const TClass* cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer* s)
void ReadFastArray(void* start, const TClass* cl, Int_t n = 1, TMemberStreamer* s = 0)
void ReadFastArray(void** startp, const TClass* cl, Int_t n = 1, Bool_t isPreAlloc = kFALSE, TMemberStreamer* s = 0)

In these functions I make replacement which I propose before - instead of cl->Streamer(buf, obj),
I use buf->StreamObject(obj, cl) ("parenthesis" arround cl->Streamer(buf, obj) call)
In case of TBufferSQL2 I treat StreamObject() as WriteObject()/ReadObject()
calls. Therefore, I can solve problem with objects array. Now it is easy to produce one column for
each array element.

Revision 13383 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Nov 28 23:22:31 2005 UTC (9 years, 1 month ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 67691 byte(s)
Diff to previous 13349
From Sergei Linev:
I made following modification:

1. Usage of table indexes. By default, they created only for basic tables: KeysTable and ObjectsTable.
   It is possible to configure TSQLFile to create indexes also for other type of tables or disable indexes at all.

2. Use of transaction. Now by default this option on and protect storage of object data to datatables.
   For some types of MySQL tables transaction are not supported, therefore I include in configurations
   possibility to setup type of table which should be used.

3. Configurations. For all kind of configuration I create small table.
   Configurations can be changed only when TSQLFile is created with option "CREATE" or "RECREATE".
   In that case configurations can be changed until first write operation.

4. Locking. I did not use "native" database locking mechnism while they are very different in MySQL and Oracle and
   may differ also in other SQL database. I put in Configuration table one flag, which says if database is already
   opened for writing by other TSQLFile instance and prevent other TSQLFile to have write access.
   For emergency cases one can use "BREAKLOCK" option in TSQLFile constructor to ignore that locking.
   This is not real locking and any other user with normal sql queries can disturb tables data, but I do not see
   now other solution, which may work for different databases. May be you know better solutions?

Revision 13349 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Nov 24 16:57:23 2005 UTC (9 years, 2 months ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 67687 byte(s)
Diff to previous 13317
From Sergei Linev:
I introduce new function TSQLFile::MakeSelectQuery.
It produces SQL query, which can be used outside ROOT to get all objects data (including data from parent classes)
with single SELECT statement. As result, one table with all data is produced.

Revision 13317 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Nov 22 20:42:37 2005 UTC (9 years, 2 months ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 67225 byte(s)
Diff to previous 13312
From Sergei:
Fix white spaces, add more comment to functions, add CVS tag lines and copyright.
It should now work  for array of objects and most stl classes.
I put limitation for array size. If array with fixed size exceed limit (default 20),
array will be converted to raw data, otherwise each element of array will be presented as
single column.

Revision 13312 - (view) (download) (as text) (annotate) - [select for diffs]
Added Mon Nov 21 17:38:24 2005 UTC (9 years, 2 months ago) by pcanal
Original Path: trunk/sql/src/TBufferSQL2.cxx
File length: 64957 byte(s)
From Sergey:

Introduce a "transparent" access to SQL data base via standard TFile interface.

The main approach that each class (but not each object) has one or two tables
with names like $(CLASSNAME)_ver$(VERSION) and $(CLASSNAME)_streamer_ver$(VERSION)
For example: TAxis_ver8 or TList_streamer_ver5
Second kind of tables appears, when some of class members can not be converted to
normalized form or when class has custom streamer.
For instance, for TH1 class two tables are required: TH1_ver4 and TH1_streamer_ver4
Most of memebers are stored in TH1_ver4 table columnwise, and only memeber:

Double_t*  fBuffer;  //[fBufferSize]

can not be represented as column while size of array is not known apriory.
Therefore, fBuffer will be written as list of values in TH1_streamer_ver4 table.

All objects, stored in the DB, will be registered in table "ObjectsTable".
In this there are following columns:
"key:id"  - key identifier to which belong object
"obj:id"  - object identifier
"Class"   - object class name
"Version" - object class version
Data in each "ObjectsTable" row uniqly identify, in which table
and which column object is stored.

In normal situation all class data should be sorted columnwise.
Up to now following member are supported:
1) Basic data types
Here is everything clear. Column SQL type will be as much as possible
close to the original type of value.
2) Fixed array of basic data types
In this case n columns like fArr[0], fArr[1] and so on will be created.
If there is multidimensional array, names will be fArr2[1][2][1] and so on
3) Parent class
In this case version of parent class is stored and
data of parent class will be stored with the same obj:id in corrspondent table.
There is a special case, when parent store nothing (this is for instance TQObject).
In that case just -1 is written to avoid any extra checks if table exist or not.
4) Object as data member.
In that case object is saved in normal way to data base and column
will contain id of this object.
5) Pointer on object
Same as before. In case if object was already stored, just its id
will be placed in the column. For NULL pointer 0 is used.
6) TString
Now column with limited width like VARCAHR(255) in MySQL is used.
Later this will be improved to support maximum possible strings
7) Anything else.
Data will be converted to raw format and saved in _streamer_ table.
Each row supplied with obj:id and row:id, where row:id indicates
data, corresponding to this particular data member, and column
will contain this raw:id

See the TSQLFile documentation for more details.

example of a session saving data to a SQL data base
=====================================================

const char* dbname = "mysql://host.domain:3306/dbname";
const char* username = "username";
const char* userpass = "userpass";

// Clean data base and create primary tables
TSQLFile* f = new TSQLFile(dbname, "recreate", username, userpass);
// Write with standard I/O functions
arr->Write("arr",TObject::kSingleKey);
h1->Write("histo");
// Close connection to DB
delete f;

example of a session read data from SQL data base
=====================================================

// Open database again in read-only mode
TSQLFile* f = new TSQLFile(dbname, "open", username, userpass);
// Show list of keys
f->ls();
// Read stored object, again standard ROOT I/O
TH1* h1 = (TH1*) f->Get("histo");
if (h1!=0) { h1->SetDirectory(0); h1->Draw(); }
TObject* obj = f->Get("arr");
if (obj!=0) obj->Print("*");
// close connection to DB
delete f;

Known problems and open questions.
1) TTree is not supported by TSQLFile. There is independent development
of TTreeSQL, which allows to store trees directly in SQL database
2) TClonesArray is not tested, will be adjusted soon.
3) TDirectory cannot work. Hopefully, will (changes in ROOT basic I/O is required)
4) Streamer infos are not written to file, therefore schema evolution
is not yet supported. All eforts are done to enable this feature in
the near future

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

Sort log by:

Subversion Admin
ViewVC Help
Powered by ViewVC 1.0.9