Re: Updating objects in TFiles

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Nov 07 1997 - 15:49:42 MET


Reid D Rivenburgh wrote:

> Hi,
>
> Pardon what may seem like a dumb question, but say that I have a TFile
> that contains a TList.  The TFile is used to persistently store the
> TList object.  The TList, however, can change quite a bit, with
> objects being added and deleted from program execution to program
> execution.  Is there some efficient way to update an object in a
> TFile?  It seems like if I read in the TList and change it, I'll have
> to delete the TList from the TFile and then write it anew.  If the
> TList has many objects in it, that sounds like it could be
> expensive...  Is there a better way?  (I suppose not writing a
> collection as a single key would be of some help, but I like the idea
> of keeping the collection together as a single object.)
>

Currently, you have the choice to write the TList (or any collection)
as one single object (key) or as many keys as you have objects
in the collection.

If you have  TList *list, you can do:
    list->Write("Collection",1)  ;      // all objects written as a
single key
   list->Write();                                  // each object in the
collection as a separate key

I agree that it would be nice to have an option where you would like to
store
ONLY the difference with respect to a previous collection in the file.
This is not implemented and I have no plans in the short term to
implement
this facility. If somebody is volunteer to provide an algorithm, I can
introduce it obviously in the system.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET