Re: [ROOT] MySQL error

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Fri Mar 08 2002 - 19:26:03 MET


Hi Andre,

  simple objects can be stored easily in a BLOB field, TTree's are not
simple objects as they can write many buffers to file and without these
buffers a TTree is not complete. But for simple objects (or purely in
memory TTrees) the recipe is something like:

TH1F *myhist = new TH1F(...);
TMessage mess(kMESS_OBJECT);
mess.WriteObject(myhist);
char *buf = mess.Buffer();
int   len = mess.Length();

store "buf" with length "len" in DB. To read back retrieve BLOB in "buf"
and length in "len" and do:

TMessage mess(buf, len);
TH1F *myhist = (TH1F*) mess.ReadObject(mess.GetClass());


Cheers, Fons.


On Fri, 2002-03-08 at 15:52, André David wrote:
> ps - My bottom line with TSQLServer is to understand if I can put a
> TObject (TTree or TH*) directly in a BLOB field of the DB. Any
> experience/answer/hint to this end is very welcome.
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:45 MET